--- xorg-server-1.4.99.906.orig/config/dbus-api +++ xorg-server-1.4.99.906/config/dbus-api @@ -0,0 +1,40 @@ +D-BUS Configuration API v2 +---------------------------- + +The X server will register the bus name org.x.config.displayN, and the +object /org/x/config/N, where N is the display number. + +Currently only hotplugging of input devices is supported. + +org.x.config.input: + org.x.config.input.version: + Returns one unsigned int32, which is the API version. + + org.x.config.input.add: + Takes an argument of key/value option pairs in arrays, e.g.: + [ss][ss][ss][ss] + is the signature for four options. These options will be passed + to the input driver as with any others. + Option names beginning with _ are not allowed; they are reserved + for internal use. + + Returns a number of signed int32s. Positive integers are the + device IDs of new devices; negative numbers are X error codes, + as defined in X.h. BadMatch will be returned if the options + given do not match any device. BadValue is returned for a malformed + message. (Example: 8 is new device ID 8; -8 is BadMatch.) + + Notably, BadAlloc is never returned: the server internally signals + to D-BUS that the attempt failed for lack of memory. + + org.x.config.input.remove: + Takes one uint32 argument, which is the device ID to remove, i.e.: + u + is the signature. + + Returns one signed int32 which represents an X status as defined in + X.h. See org.x.config.input.add. Error codes are negative numbers. + + org.x.config.input.listDevices: + Lists the currently active devices. No argument. + Return value is sequence of [ ] [ ] ..., i.e. [us]. --- xorg-server-1.4.99.906.orig/hw/xquartz/xpr/Xquartz.man.pre +++ xorg-server-1.4.99.906/hw/xquartz/xpr/Xquartz.man.pre @@ -0,0 +1,156 @@ +.TH XQUARTZ 1 __vendorversion__ +.SH NAME +Xquartz \- X window system server for Quartz operating system +.SH SYNOPSIS +.B Xquartz +[ options ] ... +.SH DESCRIPTION +.I Xquartz +is the X window server for Mac OS X provided by Apple. +.I Xquartz +runs in parallel with Aqua in rootless mode. In rootless mode, the X +window system and Mac OS X share your display. The root window of the +X11 display is the size of the screen and contains all the other +windows. The X11 root window is not displayed in rootless mode as Mac +OS X handles the desktop background. +.SH OPTIONS +.PP +In addition to the normal server options described in the \fIXserver(1)\fP +manual page, \fIXquartz\fP accepts the following command line switches: +.TP 8 +.B \-fakebuttons +Emulates a 3 button mouse using modifier keys. By default, the Command modifier +is used to emulate button 2 and Option is used for button 3. Thus, clicking the +first mouse button while holding down Command will act like clicking +button 2. Holding down Option will simulate button 3. +.TP 8 +.B \-nofakebuttons +Do not emulate a 3 button mouse. This is the default. +.TP 8 +.B "\-fakemouse2 \fImodifiers\fP" +Change the modifier keys used to emulate the second mouse button. By default, +Command is used to emulate the second button. Any combination of the following +modifier names may be used: Shift, Option, Control, Command, Fn. For example, +.B \-fakemouse2 """Option,Shift"" +will set holding Option, Shift and clicking on button one as equivalent to +clicking the second mouse button. +.TP 8 +.B "\-fakemouse3 \fImodifiers\fP" +Change the modifier keys used to emulate the third mouse button. By default, +Option is used to emulate the third button. Any combination of the following +modifier names may be used: Shift, Option, Control, Command, Fn. For example, +.B \-fakemouse3 """Control,Shift"" +will set holding Control, Shift and clicking on button one as equivalent to +clicking the third mouse button. +.TP 8 +.B "\-swapAltMeta" +Swaps the meaning of the Alt and Meta modifier keys. +.TP 8 +.B "\-keymap \fIfile\fP" +On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap. +The default is to read this keymapping from USA.keymapping. With this option +the keymapping will be read from \fIfile\fP instead. If the file's path is +not specified, it will be searched for in Library/Keyboards/ underneath the +following directories (in order): ~, /, /Network, /System. +.TP 8 +.B \-nokeymap +On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap. +With this option \fIXquartz\fP queries the kernel for the current keymapping +instead of reading it from a file. This will often fail on newer kernels. +.TP 8 +.B "\-depth \fIdepth\fP" +Specifies the color bit depth to use. Currently only 15, and 24 color +bits per pixel are supported. If not specified, defaults to the depth +of the main display. +.SH CUSTOMIZATION +\fIXquartz\fP can also be customized using the defaults(1) command. The available options are: +.TP 8 +.B defaults write org.x.X11 enable_fake_buttons -boolean true +Equivalent to the \fB-fakebuttons\fP command line option. +.TP 8 +.B defaults write org.x.X11 fake_button2 \fImodifiers\fP +Equivalent to the \fB-fakemouse2\fP option. +.TP 8 +.B defaults write org.x.X11 fake_button3 \fImodifiers\fP +Equivalent to the \fB-fakemouse3\fP option. +.TP 8 +.B defaults write org.x.X11 swap_alt_meta -boolean true +Equivalent to the \fB-swapAltMeta\fP option. +.TP 8 +.B defaults write org.x.X11 keymap_file \fIfilename\fP +Equivalent to the \fB-keymap\fP option. +.TP 8 +.B defaults write org.x.X11 no_quit_alert -boolean true +Disables the alert dialog displayed when attempting to quit X11. +.TP 8 +.B defaults write org.x.X11 no_auth -boolean true +Stops the X server requiring that clients authenticate themselves when +connecting. See Xsecurity(__miscmansuffix__). +.TP 8 +.B defaults write org.x.X11 nolisten_tcp -boolean true +Prevents the X server accepting remote connections. +.TP 8 +.B defaults write org.x.X11 xinit_kills_server -boolean false +Stops the X server exiting when the xinitrc script terminates. +.TP 8 +.B defaults write org.x.X11 fullscreen_hotkeys -boolean false +Allows system hotkeys to be handled while in X11 fullscreen mode. +.TP 8 +.B defaults write org.x.X11 enable_system_beep -boolean false +Don't use the standard system beep effect for X11 alerts. +.TP 8 +.B defaults write org.x.X11 enable_key_equivalents -boolean false +Disable menu keyboard equivalents while X11 windows are focused. +.TP 8 +.B defaults write org.x.X11 depth \fIdepth\fP +Equivalent to the \fB-depth\fP option. +.SH "SEE ALSO" +.PP +X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1) +.PP +.SH AUTHORS +XFree86 was originally ported to Mac OS X Server by John Carmack. Dave +Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0. +Torrey T. Lyons improved and integrated this code into the XFree86 +Project's mainline for the 4.0.2 release. +.PP +The following members of the XonX Team contributed to the following +releases (in alphabetical order): +.TP 4 +XFree86 4.1.0: +.br +Rob Braun - Darwin x86 support +.br +Torrey T. Lyons - Project Lead +.br +Andreas Monitzer - Cocoa version of XDarwin front end +.br +Gregory Robert Parker - Original Quartz implementation +.br +Christoph Pfisterer - Dynamic shared X libraries +.br +Toshimitsu Tanaka - Japanese localization +.TP 4 +XFree86 4.2.0: +.br +Rob Braun - Darwin x86 support +.br +Pablo Di Noto - Spanish localization +.br +Paul Edens - Dutch localization +.br +Kyunghwan Kim - Korean localization +.br +Mario Klebsch - Non-US keyboard support +.br +Torrey T. Lyons - Project Lead +.br +Andreas Monitzer - German localization +.br +Patrik Montgomery - Swedish localization +.br +Greg Parker - Rootless support +.br +Toshimitsu Tanaka - Japanese localization +.br +Olivier Verdier - French localization --- xorg-server-1.4.99.906.orig/hw/xwin/xlaunch/Makefile +++ xorg-server-1.4.99.906/hw/xwin/xlaunch/Makefile @@ -0,0 +1,79 @@ +# +# Copyright (c) 2005 Alexander Gottwald +# +# 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 +# THE ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above 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. +# +WINDRES=windres + +TARGET=mingw +#DEBUG_FLAGS=-D_DEBUG + +OS_FLAGS_mingw=-mno-cygwin +OS_FLAGS=$(OS_FLAGS_$(TARGET)) $(DEBUG_FLAGS) + +X11_DIR_$(TARGET)=/usr/X11R6 +X11_DIR_mingw=../../../../../exports +X11_DIR=$(X11_DIR_$(TARGET)) +X11_INCLUDE=-I$(X11_DIR)/include +X11_LIBDIR=-L$(X11_DIR)/lib +X11_LIBS_$(TARGET)=-lX11 +X11_LIBS_mingw=-lX11 -lwsock32 +X11_LIBS=$(X11_LIBS_$(TARGET)) + +PROGRAMFILES:=$(shell cygpath -u $(PROGRAMFILES)) +#MSXML_DIR=$(PROGRAMFILES)/MSXML 4.0 +MSXML_DIR=$(PROGRAMFILES)/Microsoft XML Parser SDK +MSXML_INCLUDE="-I$(MSXML_DIR)/inc" +MSXML_LIBDIR="-L$(MSXML_DIR)/lib" +MSXML_LIBS= + + +CXXFLAGS=-g $(OS_FLAGS) $(X11_INCLUDE) $(MSXML_INCLUDE) +LDFLAGS=-mwindows $(X11_LIBDIR) $(MSXML_LIBDIR) +LIBS=-lcomctl32 -lole32 -loleaut32 $(X11_LIBS) $(MSXML_LIBS) +all:xlaunch.exe +%.res: %.rc + $(WINDRES) -O coff -o $@ $< + +WINDOW_PARTS=window util dialog wizard +WINDOW_OBJECTS=$(foreach file,$(WINDOW_PARTS),window/$(file).o) + +RESOURCES_IMAGES=resources/multiwindow.bmp resources/fullscreen.bmp \ + resources/windowed.bmp resources/nodecoration.bmp + +resources/resources.res: resources/resources.rc resources/resources.h \ + resources/images.rc resources/dialog.rc resources/strings.rc \ + $(RESOURCES_IMAGES) +xlaunch.exe: $(WINDOW_OBJECTS) main.o config.o resources/resources.res + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) + + +window/dialog.o: window/dialog.cc window/dialog.h window/window.h window/util.h +window/frame.o: window/frame.cc window/frame.h window/window.h +window/util.o: window/util.cc window/util.h +window/window.o: window/window.cc window/window.h window/util.h +window/wizard.o: window/wizard.cc window/wizard.h window/dialog.h \ + window/window.h window/util.h +main.o: main.cc window/util.h window/wizard.h window/dialog.h \ + window/window.h resources/resources.h config.h +config.o: config.cc config.h --- xorg-server-1.4.99.906.orig/hw/xwin/xlaunch/config.h +++ xorg-server-1.4.99.906/hw/xwin/xlaunch/config.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2005 Alexander Gottwald + * + * 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 + * THE ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above 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. + */ +#ifndef __CONFIG_H__ +#define __CONFIG_H__ + +#include +struct CConfig +{ + enum {MultiWindow, Fullscreen, Windowed, Nodecoration} window; + enum {NoClient, StartProgram, XDMCP} client; + bool local; + std::string display; + std::string protocol; + std::string program; + std::string host; + std::string user; + bool broadcast; + bool indirect; + std::string xdmcp_host; + bool clipboard; + std::string extra_params; +#ifdef _DEBUG + CConfig() : window(MultiWindow), client(StartProgram), local(false), display("1"), + protocol("Putty"), program("xterm"), host("lupus"), user("ago"), + broadcast(false), indirect(false), xdmcp_host("lupus"), + clipboard(true), extra_params() {}; +#else + CConfig() : window(MultiWindow), client(StartProgram), local(false), display("0"), + protocol("Putty"), program("xterm"), host(""), user(""), + broadcast(true), indirect(false), xdmcp_host(""), + clipboard(true), extra_params() {}; +#endif + void Load(const char* filename); + void Save(const char* filename); +}; + +#endif --- xorg-server-1.4.99.906.orig/hw/xwin/glx/glwrap.c +++ xorg-server-1.4.99.906/hw/xwin/glx/glwrap.c @@ -0,0 +1,583 @@ +/* + * GLX implementation that uses Win32's OpenGL + * Wrapper functions for Win32's OpenGL + * + * Authors: Alexander Gottwald + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#define RESOLVE_RET(procname, symbol, retval) \ + static Bool init = TRUE; \ + static procname proc = NULL; \ + if (init) { \ + proc = (procname)wglGetProcAddress(symbol); \ + init = FALSE; \ + if (proc == NULL) { \ + ErrorF("glwrap: Can't resolve \"%s\"\n", symbol); \ + } else \ + ErrorF("glwrap: resolved \"%s\"\n", symbol); \ + } \ + if (proc == NULL) { \ + __glXErrorCallBack(NULL, 0); \ + return retval; \ + } +#define RESOLVE(procname, symbol) RESOLVE_RET(procname, symbol,) + + +/* + * GL_ARB_imaging + */ + + +GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat, + GLsizei width, GLenum format, + GLenum type, const GLvoid *table ) +{ + RESOLVE(PFNGLCOLORTABLEPROC, "glColorTable"); + proc(target, internalformat, width, format, type, table); +} + +GLAPI void GLAPIENTRY glColorSubTable( GLenum target, + GLsizei start, GLsizei count, + GLenum format, GLenum type, + const GLvoid *data ) +{ + RESOLVE(PFNGLCOLORSUBTABLEPROC, "glColorSubTable"); + proc(target, start, count, format, type, data); +} + +GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname, + const GLint *params) +{ + RESOLVE(PFNGLCOLORTABLEPARAMETERIVPROC, "glColorTableParameteriv"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname, + const GLfloat *params) +{ + RESOLVE(PFNGLCOLORTABLEPARAMETERFVPROC, "glColorTableParameterfv"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width ) +{ + RESOLVE(PFNGLCOPYCOLORSUBTABLEPROC, "glCopyColorSubTable"); + proc(target, start, x, y, width); +} + +GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width ) +{ + RESOLVE(PFNGLCOPYCOLORTABLEPROC, "glCopyColorTable"); + proc(target, internalformat, x, y, width); +} + + +GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format, + GLenum type, GLvoid *table ) +{ + RESOLVE(PFNGLGETCOLORTABLEPROC, "glGetColorTable"); + proc(target, format, type, table); +} + +GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname, + GLfloat *params ) +{ + RESOLVE(PFNGLGETCOLORTABLEPARAMETERFVPROC, "glGetColorTableParameterfv"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname, + GLint *params ) +{ + RESOLVE(PFNGLGETCOLORTABLEPARAMETERIVPROC, "glGetColorTableParameteriv"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glBlendEquation( GLenum mode ) +{ + RESOLVE(PFNGLBLENDEQUATIONPROC, "glBlendEquation"); + proc(mode); +} + +GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ) +{ + RESOLVE(PFNGLBLENDCOLORPROC, "glBlendColor"); + proc(red, green, blue, alpha); +} + +GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width, + GLenum internalformat, GLboolean sink ) +{ + RESOLVE(PFNGLHISTOGRAMPROC, "glHistogram"); + proc(target, width, internalformat, sink); +} + +GLAPI void GLAPIENTRY glResetHistogram( GLenum target ) +{ + RESOLVE(PFNGLRESETHISTOGRAMPROC, "glResetHistogram"); + proc(target); +} + +GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset, + GLenum format, GLenum type, + GLvoid *values ) +{ + RESOLVE(PFNGLGETHISTOGRAMPROC, "glGetHistogram"); + proc(target, reset, format, type, values); +}; + +GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname, + GLfloat *params ) +{ + RESOLVE(PFNGLGETHISTOGRAMPARAMETERFVPROC, "glGetHistogramParameterfv"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname, + GLint *params ) +{ + RESOLVE(PFNGLGETHISTOGRAMPARAMETERIVPROC, "glGetHistogramParameteriv"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat, + GLboolean sink ) +{ + RESOLVE(PFNGLMINMAXPROC, "glMinmax"); + proc(target, internalformat, sink); +} + +GLAPI void GLAPIENTRY glResetMinmax( GLenum target ) +{ + RESOLVE(PFNGLRESETMINMAXPROC, "glResetMinmax"); + proc(target); +} + +GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset, + GLenum format, GLenum types, + GLvoid *values ) +{ + RESOLVE(PFNGLGETMINMAXPROC, "glGetMinmax"); + proc(target, reset, format, types, values); +} + +GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname, + GLfloat *params ) +{ + RESOLVE(PFNGLGETMINMAXPARAMETERFVPROC, "glGetMinmaxParameterfv"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname, + GLint *params ) +{ + RESOLVE(PFNGLGETMINMAXPARAMETERIVPROC, "glGetMinmaxParameteriv"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target, + GLenum internalformat, GLsizei width, GLenum format, GLenum type, + const GLvoid *image ) +{ + RESOLVE(PFNGLCONVOLUTIONFILTER1DPROC, "glConvolutionFilter1D"); + proc(target, internalformat, width, format, type, image); +} + +GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *image ) +{ + RESOLVE(PFNGLCONVOLUTIONFILTER2DPROC, "glConvolutionFilter2D"); + proc(target, internalformat, width, height, format, type, image); +} + +GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname, + GLfloat params ) +{ + RESOLVE(PFNGLCONVOLUTIONPARAMETERFPROC, "glConvolutionParameterf"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname, + const GLfloat *params ) +{ + RESOLVE(PFNGLCONVOLUTIONPARAMETERFVPROC, "glConvolutionParameterfv"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname, + GLint params ) +{ + RESOLVE(PFNGLCONVOLUTIONPARAMETERIPROC, "glConvolutionParameteri"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname, + const GLint *params ) +{ + RESOLVE(PFNGLCONVOLUTIONPARAMETERIVPROC, "glConvolutionParameteriv"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width ) +{ + RESOLVE(PFNGLCOPYCONVOLUTIONFILTER1DPROC, "glCopyConvolutionFilter1D"); + proc(target, internalformat, x, y, width); +} + +GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width, + GLsizei height) +{ + RESOLVE(PFNGLCOPYCONVOLUTIONFILTER2DPROC, "glCopyConvolutionFilter2D"); + proc(target, internalformat, x, y, width, height); +} + +GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format, + GLenum type, GLvoid *image ) +{ + RESOLVE(PFNGLGETCONVOLUTIONFILTERPROC, "glGetConvolutionFilter"); + proc(target, format, type, image); +} + +GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname, + GLfloat *params ) +{ + RESOLVE(PFNGLGETCONVOLUTIONPARAMETERFVPROC, "glGetConvolutionParameterfv"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname, + GLint *params ) +{ + RESOLVE(PFNGLGETCONVOLUTIONPARAMETERIVPROC, "glGetConvolutionParameteriv"); + proc(target, pname, params); +} + +GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *row, const GLvoid *column ) +{ + RESOLVE(PFNGLSEPARABLEFILTER2DPROC, "glSeparableFilter2D"); + proc(target, internalformat, width, height, format, type, row, column); +} + +GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, + GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ) +{ + RESOLVE(PFNGLGETSEPARABLEFILTERPROC, "glGetSeparableFilter"); + proc(target, format, type, row, column, span); +} + +/* + * OpenGL 1.2 + */ + +GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ) +{ + RESOLVE(PFNGLTEXIMAGE3DPROC, "glTexImage3D"); + proc(target, level, internalFormat, width, height, depth, border, format, type, pixels); +} + +GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, + GLenum type, const GLvoid *pixels) +{ + RESOLVE(PFNGLTEXSUBIMAGE3DPROC, "glTexSubImage3D"); + proc(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); +} + +GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLint x, + GLint y, GLsizei width, + GLsizei height ) +{ + RESOLVE(PFNGLCOPYTEXSUBIMAGE3DPROC, "glCopyTexSubImage3D"); + proc(target, level, xoffset, yoffset, zoffset, x, y, width, height); +} + + +/* + * 20. GL_EXT_texture_object + */ +GLAPI void GLAPIENTRY glGenTexturesEXT( GLsizei n, GLuint *textures ) +{ + glGenTextures(n, textures); +} + +GLAPI void GLAPIENTRY glDeleteTexturesEXT( GLsizei n, const GLuint *textures) +{ + glDeleteTextures(n, textures); +} + +GLAPI void GLAPIENTRY glBindTextureEXT( GLenum target, GLuint texture ) +{ + glBindTexture(target, target); +} + +GLAPI void GLAPIENTRY glPrioritizeTexturesEXT( GLsizei n, const GLuint *textures, const GLclampf *priorities ) +{ + glPrioritizeTextures(n, textures, priorities); +} + +GLAPI GLboolean GLAPIENTRY glAreTexturesResidentEXT( GLsizei n, const GLuint *textures, GLboolean *residences ) +{ + return glAreTexturesResident(n, textures, residences); +} + +GLAPI GLboolean GLAPIENTRY glIsTextureEXT( GLuint texture ) +{ + return glIsTexture(texture); +} + +/* + * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1) + */ + +GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture) +{ + RESOLVE(PFNGLACTIVETEXTUREARBPROC, "glActiveTextureARB"); + proc(texture); +} + +GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v) +{ + RESOLVE(PFNGLMULTITEXCOORD1DVARBPROC, "glMultiTexCoord1dvARB"); + proc(target, v); +} + +GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v) +{ + RESOLVE(PFNGLMULTITEXCOORD1FVARBPROC, "glMultiTexCoord1fvARB"); + proc(target, v); +} + +GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v) +{ + RESOLVE(PFNGLMULTITEXCOORD1IVARBPROC, "glMultiTexCoord1ivARB"); + proc(target, v); +} + +GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v) +{ + RESOLVE(PFNGLMULTITEXCOORD1SVARBPROC, "glMultiTexCoord1svARB"); + proc(target, v); +} +GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v) +{ + RESOLVE(PFNGLMULTITEXCOORD2DVARBPROC, "glMultiTexCoord2dvARB"); + proc(target, v); +} +GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v) +{ + RESOLVE(PFNGLMULTITEXCOORD2FVARBPROC, "glMultiTexCoord2fvARB"); + proc(target, v); +} +GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v) +{ + RESOLVE(PFNGLMULTITEXCOORD2IVARBPROC, "glMultiTexCoord2ivARB"); + proc(target, v); +} +GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v) +{ + RESOLVE(PFNGLMULTITEXCOORD1SVARBPROC, "glMultiTexCoord1svARB"); + proc(target, v); +} +GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v) +{ + RESOLVE(PFNGLMULTITEXCOORD3DVARBPROC, "glMultiTexCoord3dvARB"); + proc(target, v); +} +GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v) +{ + RESOLVE(PFNGLMULTITEXCOORD3FVARBPROC, "glMultiTexCoord3fvARB"); + proc(target, v); +} +GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v) +{ + RESOLVE(PFNGLMULTITEXCOORD3IVARBPROC, "glMultiTexCoord3ivARB"); + proc(target, v); +} +GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v) +{ + RESOLVE(PFNGLMULTITEXCOORD1SVARBPROC, "glMultiTexCoord1svARB"); + proc(target, v); +} +GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v) +{ + RESOLVE(PFNGLMULTITEXCOORD4DVARBPROC, "glMultiTexCoord4dvARB"); + proc(target, v); +} +GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v) +{ + RESOLVE(PFNGLMULTITEXCOORD4FVARBPROC, "glMultiTexCoord4fvARB"); + proc(target, v); +} +GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v) +{ + RESOLVE(PFNGLMULTITEXCOORD4IVARBPROC, "glMultiTexCoord4ivARB"); + proc(target, v); +} +GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v) +{ + RESOLVE(PFNGLMULTITEXCOORD1SVARBPROC, "glMultiTexCoord1svARB"); + proc(target, v); +} + + +GLAPI void GLAPIENTRY glActiveStencilFaceEXT(GLenum face) +{ + RESOLVE(PFNGLACTIVESTENCILFACEEXTPROC, "glActiveStencilFaceEXT"); + proc(face); +} + +GLAPI void APIENTRY glPointParameterfARB(GLenum pname, GLfloat param) +{ + RESOLVE(PFNGLPOINTPARAMETERFARBPROC, "glPointParameterfARB"); + proc(pname, param); +} + +GLAPI void APIENTRY glPointParameterfvARB(GLenum pname, const GLfloat *params) +{ + RESOLVE(PFNGLPOINTPARAMETERFVARBPROC, "glPointParameterfvARB"); + proc(pname, params); +} + + +GLAPI void APIENTRY glWindowPos3fARB(GLfloat x, GLfloat y, GLfloat z) +{ + RESOLVE(PFNGLWINDOWPOS3FARBPROC, "glWindowPos3fARB"); + proc(x, y, z); +} + +GLAPI void APIENTRY glPointParameteri(GLenum pname, GLint param) +{ + RESOLVE(PFNGLPOINTPARAMETERIPROC, "glPointParameteri"); + proc(pname, param); +} + +GLAPI void APIENTRY glPointParameteriv(GLenum pname, const GLint *params) +{ + RESOLVE(PFNGLPOINTPARAMETERIVPROC, "glPointParameteriv"); + proc(pname, params); +} + +GLAPI void APIENTRY glPointParameteriNV(GLenum pname, GLint param) +{ + RESOLVE(PFNGLPOINTPARAMETERINVPROC, "glPointParameteriNV"); + proc(pname, param); +} + +GLAPI void APIENTRY glPointParameterivNV(GLenum pname, const GLint *params) +{ + RESOLVE(PFNGLPOINTPARAMETERIVNVPROC, "glPointParameterivNV"); + proc(pname, params); +} + +GLAPI void APIENTRY glSecondaryColor3bv(const GLbyte *v) +{ + RESOLVE(PFNGLSECONDARYCOLOR3BVPROC, "glSecondaryColor3bv"); + proc(v); +} +GLAPI void APIENTRY glSecondaryColor3dv(const GLdouble *v) +{ + RESOLVE(PFNGLSECONDARYCOLOR3DVPROC, "glSecondaryColor3dv"); + proc(v); +} +GLAPI void APIENTRY glSecondaryColor3fv(const GLfloat *v) +{ + RESOLVE(PFNGLSECONDARYCOLOR3FVPROC, "glSecondaryColor3fv"); + proc(v); +} +GLAPI void APIENTRY glSecondaryColor3iv(const GLint *v) +{ + RESOLVE(PFNGLSECONDARYCOLOR3IVPROC, "glSecondaryColor3iv"); + proc(v); +} +GLAPI void APIENTRY glSecondaryColor3sv(const GLshort *v) +{ + RESOLVE(PFNGLSECONDARYCOLOR3SVPROC, "glSecondaryColor3sv"); + proc(v); +} +GLAPI void APIENTRY glSecondaryColor3ubv(const GLubyte *v) +{ + RESOLVE(PFNGLSECONDARYCOLOR3UBVPROC, "glSecondaryColor3ubv"); + proc(v); +} +GLAPI void APIENTRY glSecondaryColor3uiv(const GLuint *v) +{ + RESOLVE(PFNGLSECONDARYCOLOR3UIVPROC, "glSecondaryColor3uiv"); + proc(v); +} +GLAPI void APIENTRY glSecondaryColor3usv(const GLushort *v) +{ + RESOLVE(PFNGLSECONDARYCOLOR3USVPROC, "glSecondaryColor3usv"); + proc(v); +} +GLAPI void APIENTRY glSecondaryColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ + RESOLVE(PFNGLSECONDARYCOLORPOINTERPROC, "glSecondaryColorPointer"); + proc(size, type, stride, pointer); +} + + +GLAPI void APIENTRY glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) +{ + RESOLVE(PFNGLBLENDFUNCSEPARATEPROC, "glBlendFuncSeparate"); + proc(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); +} +GLAPI void APIENTRY glFogCoordfv(const GLfloat *coord) +{ + RESOLVE(PFNGLFOGCOORDFVPROC, "glFogCoordfv"); + proc(coord); +} +GLAPI void APIENTRY glFogCoorddv(const GLdouble *coord) +{ + RESOLVE(PFNGLFOGCOORDDVPROC, "glFogCoorddv"); + proc(coord); +} +GLAPI void APIENTRY glFogCoordPointer(GLenum type, GLsizei stride, const GLvoid *pointer) +{ + RESOLVE(PFNGLFOGCOORDPOINTERPROC, "glFogCoordPointer"); + proc(type, stride, pointer); +} + + +GLAPI void APIENTRY glSampleCoverageARB(GLclampf value, GLboolean invert) +{ + RESOLVE(PFNGLSAMPLECOVERAGEARBPROC, "glSampleCoverageARB"); + proc(value, invert); +} +GLAPI void APIENTRY glSampleMaskSGIS(GLclampf value, GLboolean invert) +{ + RESOLVE(PFNGLSAMPLEMASKSGISPROC, "glSampleMaskSGIS"); + proc(value, invert); +} +GLAPI void APIENTRY glSamplePatternSGIS(GLenum pattern) +{ + RESOLVE(PFNGLSAMPLEPATTERNSGISPROC, "glSamplePatternSGIS"); + proc(pattern); +} --- xorg-server-1.4.99.906.orig/hw/xwin/glx/indirect.c +++ xorg-server-1.4.99.906/hw/xwin/glx/indirect.c @@ -0,0 +1,1605 @@ +/* + * GLX implementation that uses Windows OpenGL library + * (Indirect rendering path) + * + * Authors: Alexander Gottwald + */ +/* + * Portions of this file are copied from GL/apple/indirect.c, + * which contains the following copyright: + * + * Copyright (c) 2002 Greg Parker. All Rights Reserved. + * Copyright (c) 2002 Apple Computer, Inc. + * + * Portions of this file are copied from xf86glx.c, + * which contains the following copyright: + * + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * 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, 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 + * THE ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above 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. + */ + + + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "glwindows.h" +#include +#include + +#include + +#define GLWIN_DEBUG_HWND(hwnd) \ + if (glWinDebugSettings.dumpHWND) { \ + char buffer[1024]; \ + if (GetWindowText(hwnd, buffer, sizeof(buffer))==0) *buffer=0; \ + GLWIN_DEBUG_MSG("Got HWND %s (%p)\n", buffer, hwnd); \ + } + + +/* ggs: needed to call back to glx with visual configs */ +extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs); + +glWinDebugSettingsRec glWinDebugSettings = { 1, 0, 0, 0, 0}; + +static void glWinInitDebugSettings(void) +{ + char *envptr; + + envptr = getenv("GLWIN_ENABLE_DEBUG"); + if (envptr != NULL) + glWinDebugSettings.enableDebug = (atoi(envptr) == 1); + + envptr = getenv("GLWIN_ENABLE_TRACE"); + if (envptr != NULL) + glWinDebugSettings.enableTrace = (atoi(envptr) == 1); + + envptr = getenv("GLWIN_DUMP_PFD"); + if (envptr != NULL) + glWinDebugSettings.dumpPFD = (atoi(envptr) == 1); + + envptr = getenv("GLWIN_DUMP_HWND"); + if (envptr != NULL) + glWinDebugSettings.dumpHWND = (atoi(envptr) == 1); + + envptr = getenv("GLWIN_DUMP_DC"); + if (envptr != NULL) + glWinDebugSettings.dumpDC = (atoi(envptr) == 1); +} + +static char errorbuffer[1024]; +const char *glWinErrorMessage(void) +{ + if (!FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &errorbuffer, + sizeof(errorbuffer), + NULL )) + { + snprintf(errorbuffer, sizeof(errorbuffer), "Unknown error in FormatMessage: %08x!\n", (unsigned)GetLastError()); + } + return errorbuffer; +} + +/* + * GLX implementation that uses Win32's OpenGL + */ + +/* + * Server-side GLX uses these functions which are normally defined + * in the OpenGL SI. + */ + +GLuint __glFloorLog2(GLuint val) +{ + int c = 0; + + while (val > 1) { + c++; + val >>= 1; + } + return c; +} + +/* some prototypes */ +static Bool glWinScreenProbe(int screen); +static Bool glWinInitVisuals(VisualPtr *visualp, DepthPtr *depthp, + int *nvisualp, int *ndepthp, + int *rootDepthp, VisualID *defaultVisp, + unsigned long sizes, int bitsPerRGB); +static void glWinSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, + void **privates); +static __GLinterface *glWinCreateContext(__GLimports *imports, + __GLcontextModes *mode, + __GLinterface *shareGC); +static void glWinCreateBuffer(__GLXdrawablePrivate *glxPriv); +static void glWinResetExtension(void); + +/* + * This structure is statically allocated in the __glXScreens[] + * structure. This struct is not used anywhere other than in + * __glXScreenInit to initialize each of the active screens + * (__glXActiveScreens[]). Several of the fields must be initialized by + * the screenProbe routine before they are copied to the active screens + * struct. In particular, the contextCreate, pGlxVisual, numVisuals, + * and numUsableVisuals fields must be initialized. + */ +static __GLXscreenInfo __glDDXScreenInfo = { + glWinScreenProbe, /* Must be generic and handle all screens */ + glWinCreateContext, /* Substitute screen's createContext routine */ + glWinCreateBuffer, /* Substitute screen's createBuffer routine */ + NULL, /* Set up pGlxVisual in probe */ + NULL, /* Set up pVisualPriv in probe */ + 0, /* Set up numVisuals in probe */ + 0, /* Set up numUsableVisuals in probe */ + "Vendor String", /* GLXvendor is overwritten by __glXScreenInit */ + "Version String", /* GLXversion is overwritten by __glXScreenInit */ + "Extensions String", /* GLXextensions is overwritten by __glXScreenInit */ + NULL /* WrappedPositionWindow is overwritten */ +}; + +void *__glXglDDXScreenInfo(void) { + return &__glDDXScreenInfo; +} + +static __GLXextensionInfo __glDDXExtensionInfo = { + GL_CORE_WINDOWS, + glWinResetExtension, + glWinInitVisuals, + glWinSetVisualConfigs +}; + +void *__glXglDDXExtensionInfo(void) { + return &__glDDXExtensionInfo; +} + +/* prototypes */ + +static GLboolean glWinDestroyContext(__GLcontext *gc); +static GLboolean glWinLoseCurrent(__GLcontext *gc); +static GLboolean glWinMakeCurrent(__GLcontext *gc); +static GLboolean glWinShareContext(__GLcontext *gc, __GLcontext *gcShare); +static GLboolean glWinCopyContext(__GLcontext *dst, const __GLcontext *src, + GLuint mask); +static GLboolean glWinForceCurrent(__GLcontext *gc); + +/* Drawing surface notification callbacks */ +static GLboolean glWinNotifyResize(__GLcontext *gc); +static void glWinNotifyDestroy(__GLcontext *gc); +static void glWinNotifySwapBuffers(__GLcontext *gc); + +/* Dispatch table override control for external agents like libGLS */ +static struct __GLdispatchStateRec* glWinDispatchExec(__GLcontext *gc); +static void glWinBeginDispatchOverride(__GLcontext *gc); +static void glWinEndDispatchOverride(__GLcontext *gc); + +/* Debug output */ +static void pfdOut(const PIXELFORMATDESCRIPTOR *pfd); + +static __GLexports glWinExports = { + glWinDestroyContext, + glWinLoseCurrent, + glWinMakeCurrent, + glWinShareContext, + glWinCopyContext, + glWinForceCurrent, + + glWinNotifyResize, + glWinNotifyDestroy, + glWinNotifySwapBuffers, + + glWinDispatchExec, + glWinBeginDispatchOverride, + glWinEndDispatchOverride +}; + +glWinScreenRec glWinScreens[MAXSCREENS]; + +/* __GLdrawablePrivate->private */ +typedef struct { + DrawablePtr pDraw; + /* xp_surface_id sid; */ +} GLWinDrawableRec; + +struct __GLcontextRec { + struct __GLinterfaceRec interface; /* required to be first */ + + HGLRC ctx; /* Windows GL Context */ + + HDC dc; /* Windows Device Context */ + winWindowInfoRec winInfo; /* Window info from XWin */ + + PIXELFORMATDESCRIPTOR pfd; /* Pixelformat flags */ + int pixelFormat; /* Pixelformat index */ + + unsigned isAttached :1; /* Flag to track if context is attached */ +}; + +static HDC glWinMakeDC(__GLcontext *gc) +{ + HDC dc; + + /*if (gc->winInfo.hrgn == NULL) + { + GLWIN_DEBUG_MSG("Creating region from RECT(%ld,%ld,%ld,%ld):", + gc->winInfo.rect.left, + gc->winInfo.rect.top, + gc->winInfo.rect.right, + gc->winInfo.rect.bottom); + gc->winInfo.hrgn = CreateRectRgnIndirect(&gc->winInfo.rect); + GLWIN_DEBUG_MSG2("%p\n", gc->winInfo.hrgn); + }*/ + + if (glWinDebugSettings.enableTrace) + GLWIN_DEBUG_HWND(gc->winInfo.hwnd); + + dc = GetDC(gc->winInfo.hwnd); + /*dc = GetDCEx(gc->winInfo.hwnd, gc->winInfo.hrgn, + DCX_WINDOW | DCX_NORESETATTRS ); */ + + if (dc == NULL) + ErrorF("GetDC error: %s\n", glWinErrorMessage()); + return dc; +} + +static void unattach(__GLcontext *gc) +{ + BOOL ret; + GLWIN_DEBUG_MSG("unattach (ctx %p)\n", gc->ctx); + if (!gc->isAttached) + { + ErrorF("called unattach on an unattached context\n"); + return; + } + + if (gc->ctx) + { + ret = wglDeleteContext(gc->ctx); + if (!ret) + ErrorF("wglDeleteContext error: %s\n", glWinErrorMessage()); + gc->ctx = NULL; + } + + if (gc->winInfo.hrgn) + { + ret = DeleteObject(gc->winInfo.hrgn); + if (!ret) + ErrorF("DeleteObject error: %s\n", glWinErrorMessage()); + gc->winInfo.hrgn = NULL; + } + + gc->isAttached = 0; +} + +static BOOL glWinAdjustHWND(__GLcontext *gc, WindowPtr pWin) +{ + HDC dc; + BOOL ret; + HGLRC newctx; + HWND oldhwnd; + + GLWIN_DEBUG_MSG("glWinAdjustHWND (ctx %p, pWin %p)\n", gc->ctx, pWin); + + if (pWin == NULL) + { + GLWIN_DEBUG_MSG("Deferring until window is created\n"); + return FALSE; + } + + oldhwnd = gc->winInfo.hwnd; + winGetWindowInfo(pWin, &gc->winInfo); + + GLWIN_DEBUG_HWND(gc->winInfo.hwnd); + if (gc->winInfo.hwnd == NULL) + { + GLWIN_DEBUG_MSG("Deferring until window is created\n"); + return FALSE; + } + + dc = glWinMakeDC(gc); + + if (glWinDebugSettings.dumpDC) + GLWIN_DEBUG_MSG("Got HDC %p\n", dc); + + gc->pixelFormat = ChoosePixelFormat(dc, &gc->pfd); + if (gc->pixelFormat == 0) + { + ErrorF("ChoosePixelFormat error: %s\n", glWinErrorMessage()); + ReleaseDC(gc->winInfo.hwnd, dc); + return FALSE; + } + + ret = SetPixelFormat(dc, gc->pixelFormat, &gc->pfd); + if (!ret) { + ErrorF("SetPixelFormat error: %s\n", glWinErrorMessage()); + ReleaseDC(gc->winInfo.hwnd, dc); + return FALSE; + } + + newctx = wglCreateContext(dc); + if (newctx == NULL) { + ErrorF("wglCreateContext error: %s\n", glWinErrorMessage()); + ReleaseDC(gc->winInfo.hwnd, dc); + return FALSE; + } + + GLWIN_DEBUG_MSG("wglCreateContext (ctx %p)\n", newctx); + + if (!wglShareLists(gc->ctx, newctx)) + { + ErrorF("wglShareLists error: %s\n", glWinErrorMessage()); + ReleaseDC(gc->winInfo.hwnd, dc); + return FALSE; + } + + if (oldhwnd != gc->winInfo.hwnd) + { + GLWIN_DEBUG_MSG("Trying wglCopyContext\n"); + if (!wglCopyContext(gc->ctx, newctx, GL_ALL_ATTRIB_BITS)) + { + ErrorF("wglCopyContext error: %s\n", glWinErrorMessage()); + ReleaseDC(gc->winInfo.hwnd, dc); + return FALSE; + } + } + + if (!wglDeleteContext(gc->ctx)) + { + ErrorF("wglDeleteContext error: %s\n", glWinErrorMessage()); + } + + gc->ctx = newctx; + + if (!wglMakeCurrent(dc, gc->ctx)) { + ErrorF("glMakeCurrent error: %s\n", glWinErrorMessage()); + ReleaseDC(gc->winInfo.hwnd, dc); + return FALSE; + } + + ReleaseDC(gc->winInfo.hwnd, dc); + + return TRUE; +} + +static BOOL glWinCreateContextReal(__GLcontext *gc, WindowPtr pWin) +{ + HDC dc; + BOOL ret; + + GLWIN_DEBUG_MSG("glWinCreateContextReal (pWin %p)\n", pWin); + + if (pWin == NULL) + { + GLWIN_DEBUG_MSG("Deferring until window is created\n"); + return FALSE; + } + + winGetWindowInfo(pWin, &gc->winInfo); + + GLWIN_DEBUG_HWND(gc->winInfo.hwnd); + if (gc->winInfo.hwnd == NULL) + { + GLWIN_DEBUG_MSG("Deferring until window is created\n"); + return FALSE; + } + + + dc = glWinMakeDC(gc); + + if (glWinDebugSettings.dumpDC) + GLWIN_DEBUG_MSG("Got HDC %p\n", dc); + + gc->pixelFormat = ChoosePixelFormat(dc, &gc->pfd); + if (gc->pixelFormat == 0) + { + ErrorF("ChoosePixelFormat error: %s\n", glWinErrorMessage()); + ReleaseDC(gc->winInfo.hwnd, dc); + return FALSE; + } + + ret = SetPixelFormat(dc, gc->pixelFormat, &gc->pfd); + if (!ret) { + ErrorF("SetPixelFormat error: %s\n", glWinErrorMessage()); + ReleaseDC(gc->winInfo.hwnd, dc); + return FALSE; + } + + gc->ctx = wglCreateContext(dc); + if (gc->ctx == NULL) { + ErrorF("wglCreateContext error: %s\n", glWinErrorMessage()); + ReleaseDC(gc->winInfo.hwnd, dc); + return FALSE; + } + + GLWIN_DEBUG_MSG("glWinCreateContextReal (ctx %p)\n", gc->ctx); + + if (!wglMakeCurrent(dc, gc->ctx)) { + ErrorF("glMakeCurrent error: %s\n", glWinErrorMessage()); + ReleaseDC(gc->winInfo.hwnd, dc); + return FALSE; + } + + ReleaseDC(gc->winInfo.hwnd, dc); + + return TRUE; +} + +static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv) +{ + __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other; + + GLWIN_DEBUG_MSG("attach (ctx %p)\n", gc->ctx); + + if (gc->isAttached) + { + ErrorF("called attach on an attached context\n"); + return; + } + + if (glxPriv->type == DRAWABLE_WINDOW) + { + WindowPtr pWin = (WindowPtr) glxPriv->pDraw; + if (pWin == NULL) + { + GLWIN_DEBUG_MSG("Deferring ChoosePixelFormat until window is created\n"); + } else + { + if (glWinCreateContextReal(gc, pWin)) + { + gc->isAttached = TRUE; + GLWIN_DEBUG_MSG("attached\n"); + } + } + } +} + +static GLboolean glWinLoseCurrent(__GLcontext *gc) +{ + GLWIN_TRACE_MSG("glWinLoseCurrent (ctx %p)\n", gc->ctx); + + __glXLastContext = NULL; /* Mesa does this; why? */ + + return GL_TRUE; +} + +/* Context manipulation; return GL_FALSE on failure */ +static GLboolean glWinDestroyContext(__GLcontext *gc) +{ + GLWIN_DEBUG_MSG("glWinDestroyContext (ctx %p)\n", gc->ctx); + + if (gc != NULL) + { + if (gc->isAttached) + unattach(gc); + if (gc->dc != NULL) + DeleteDC(gc->dc); + free(gc); + } + + return GL_TRUE; +} + +static GLboolean glWinMakeCurrent(__GLcontext *gc) +{ + __GLdrawablePrivate *glPriv = gc->interface.imports.getDrawablePrivate(gc); + BOOL ret; + HDC dc; + + GLWIN_TRACE_MSG(" (ctx %p)\n", gc->ctx); + + if (!gc->isAttached) + attach(gc, glPriv); + + if (gc->ctx == NULL) { + ErrorF("Context is NULL\n"); + return GL_FALSE; + } + + dc = glWinMakeDC(gc); + ret = wglMakeCurrent(dc, gc->ctx); + if (!ret) + ErrorF("glMakeCurrent error: %s\n", glWinErrorMessage()); + ReleaseDC(gc->winInfo.hwnd, dc); + + return ret?GL_TRUE:GL_FALSE; +} + +static GLboolean glWinShareContext(__GLcontext *gc, __GLcontext *gcShare) +{ + GLWIN_DEBUG_MSG("glWinShareContext unimplemented\n"); + + return GL_TRUE; +} + +static GLboolean glWinCopyContext(__GLcontext *dst, const __GLcontext *src, + GLuint mask) +{ + BOOL ret; + + GLWIN_DEBUG_MSG("glWinCopyContext\n"); + + ret = wglCopyContext(src->ctx, dst->ctx, mask); + if (!ret) + { + ErrorF("wglCopyContext error: %s\n", glWinErrorMessage()); + return GL_FALSE; + } + + return GL_TRUE; +} + +static GLboolean glWinForceCurrent(__GLcontext *gc) +{ + GLWIN_TRACE_MSG(" (ctx %p)\n", gc->ctx); + + return GL_TRUE; +} + +/* Drawing surface notification callbacks */ + +static GLboolean glWinNotifyResize(__GLcontext *gc) +{ + GLWIN_DEBUG_MSG("unimplemented glWinNotifyResize"); + return GL_TRUE; +} + +static void glWinNotifyDestroy(__GLcontext *gc) +{ + GLWIN_DEBUG_MSG("unimplemented glWinNotifyDestroy"); +} + +static void glWinNotifySwapBuffers(__GLcontext *gc) +{ + GLWIN_DEBUG_MSG("unimplemented glWinNotifySwapBuffers"); +} + +/* Dispatch table override control for external agents like libGLS */ +static struct __GLdispatchStateRec* glWinDispatchExec(__GLcontext *gc) +{ + GLWIN_DEBUG_MSG("unimplemented glWinDispatchExec"); + return NULL; +} + +static void glWinBeginDispatchOverride(__GLcontext *gc) +{ + GLWIN_DEBUG_MSG("unimplemented glWinBeginDispatchOverride"); +} + +static void glWinEndDispatchOverride(__GLcontext *gc) +{ + GLWIN_DEBUG_MSG("unimplemented glWinEndDispatchOverride"); +} + +#define DUMP_PFD_FLAG(flag) \ + if (pfd->dwFlags & flag) { \ + ErrorF("%s%s", pipesym, #flag); \ + pipesym = " | "; \ + } + +static void pfdOut(const PIXELFORMATDESCRIPTOR *pfd) +{ + const char *pipesym = ""; /* will be set after first flag dump */ + ErrorF("PIXELFORMATDESCRIPTOR:\n"); + ErrorF("nSize = %u\n", pfd->nSize); + ErrorF("nVersion = %u\n", pfd->nVersion); + ErrorF("dwFlags = %lu = {", pfd->dwFlags); + DUMP_PFD_FLAG(PFD_MAIN_PLANE); + DUMP_PFD_FLAG(PFD_OVERLAY_PLANE); + DUMP_PFD_FLAG(PFD_UNDERLAY_PLANE); + DUMP_PFD_FLAG(PFD_DOUBLEBUFFER); + DUMP_PFD_FLAG(PFD_STEREO); + DUMP_PFD_FLAG(PFD_DRAW_TO_WINDOW); + DUMP_PFD_FLAG(PFD_DRAW_TO_BITMAP); + DUMP_PFD_FLAG(PFD_SUPPORT_GDI); + DUMP_PFD_FLAG(PFD_SUPPORT_OPENGL); + DUMP_PFD_FLAG(PFD_GENERIC_FORMAT); + DUMP_PFD_FLAG(PFD_NEED_PALETTE); + DUMP_PFD_FLAG(PFD_NEED_SYSTEM_PALETTE); + DUMP_PFD_FLAG(PFD_SWAP_EXCHANGE); + DUMP_PFD_FLAG(PFD_SWAP_COPY); + DUMP_PFD_FLAG(PFD_SWAP_LAYER_BUFFERS); + DUMP_PFD_FLAG(PFD_GENERIC_ACCELERATED); + DUMP_PFD_FLAG(PFD_DEPTH_DONTCARE); + DUMP_PFD_FLAG(PFD_DOUBLEBUFFER_DONTCARE); + DUMP_PFD_FLAG(PFD_STEREO_DONTCARE); + ErrorF("}\n"); + + ErrorF("iPixelType = %hu = %s\n", pfd->iPixelType, + (pfd->iPixelType == PFD_TYPE_RGBA ? "PFD_TYPE_RGBA" : "PFD_TYPE_COLORINDEX")); + ErrorF("cColorBits = %hhu\n", pfd->cColorBits); + ErrorF("cRedBits = %hhu\n", pfd->cRedBits); + ErrorF("cRedShift = %hhu\n", pfd->cRedShift); + ErrorF("cGreenBits = %hhu\n", pfd->cGreenBits); + ErrorF("cGreenShift = %hhu\n", pfd->cGreenShift); + ErrorF("cBlueBits = %hhu\n", pfd->cBlueBits); + ErrorF("cBlueShift = %hhu\n", pfd->cBlueShift); + ErrorF("cAlphaBits = %hhu\n", pfd->cAlphaBits); + ErrorF("cAlphaShift = %hhu\n", pfd->cAlphaShift); + ErrorF("cAccumBits = %hhu\n", pfd->cAccumBits); + ErrorF("cAccumRedBits = %hhu\n", pfd->cAccumRedBits); + ErrorF("cAccumGreenBits = %hhu\n", pfd->cAccumGreenBits); + ErrorF("cAccumBlueBits = %hhu\n", pfd->cAccumBlueBits); + ErrorF("cAccumAlphaBits = %hhu\n", pfd->cAccumAlphaBits); + ErrorF("cDepthBits = %hhu\n", pfd->cDepthBits); + ErrorF("cStencilBits = %hhu\n", pfd->cStencilBits); + ErrorF("cAuxBuffers = %hhu\n", pfd->cAuxBuffers); + ErrorF("iLayerType = %hhu\n", pfd->iLayerType); + ErrorF("bReserved = %hhu\n", pfd->bReserved); + ErrorF("dwLayerMask = %lu\n", pfd->dwLayerMask); + ErrorF("dwVisibleMask = %lu\n", pfd->dwVisibleMask); + ErrorF("dwDamageMask = %lu\n", pfd->dwDamageMask); + ErrorF("\n"); +} + +static int makeFormat(__GLcontextModes *mode, PIXELFORMATDESCRIPTOR *pfdret) +{ + PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), /* size of this pfd */ + 1, /* version number */ + PFD_DRAW_TO_WINDOW | /* support window */ + PFD_SUPPORT_OPENGL, /* support OpenGL */ + PFD_TYPE_RGBA, /* RGBA type */ + 24, /* 24-bit color depth */ + 0, 0, 0, 0, 0, 0, /* color bits ignored */ + 0, /* no alpha buffer */ + 0, /* shift bit ignored */ + 0, /* no accumulation buffer */ + 0, 0, 0, 0, /* accum bits ignored */ + 0, /* 32-bit z-buffer */ + 0, /* no stencil buffer */ + 0, /* no auxiliary buffer */ + PFD_MAIN_PLANE, /* main layer */ + 0, /* reserved */ + 0, 0, 0 /* layer masks ignored */ + }, *result = &pfd; + + /* disable anything but rgba. must get rgba to work first */ + if (!mode->rgbMode) + return -1; + + if (mode->stereoMode) { + result->dwFlags |= PFD_STEREO; + } + if (mode->doubleBufferMode) { + result->dwFlags |= PFD_DOUBLEBUFFER; + } + + if (mode->colorIndexMode) { + /* ignored, see above */ + result->iPixelType = PFD_TYPE_COLORINDEX; + result->cColorBits = mode->redBits + mode->greenBits + mode->blueBits; + result->cRedBits = mode->redBits; + result->cRedShift = 0; /* FIXME */ + result->cGreenBits = mode->greenBits; + result->cGreenShift = 0; /* FIXME */ + result->cBlueBits = mode->blueBits; + result->cBlueShift = 0; /* FIXME */ + result->cAlphaBits = mode->alphaBits; + result->cAlphaShift = 0; /* FIXME */ + } + + if (mode->rgbMode) { + result->iPixelType = PFD_TYPE_RGBA; + result->cColorBits = mode->redBits + mode->greenBits + mode->blueBits; + result->cRedBits = mode->redBits; + result->cRedShift = 0; /* FIXME */ + result->cGreenBits = mode->greenBits; + result->cGreenShift = 0; /* FIXME */ + result->cBlueBits = mode->blueBits; + result->cBlueShift = 0; /* FIXME */ + result->cAlphaBits = mode->alphaBits; + result->cAlphaShift = 0; /* FIXME */ + } + + if (mode->haveAccumBuffer) { + result->cAccumBits = mode->accumRedBits + mode->accumGreenBits + + mode->accumBlueBits + mode->accumAlphaBits; + result->cAccumRedBits = mode->accumRedBits; + result->cAccumGreenBits = mode->accumGreenBits; + result->cAccumBlueBits = mode->accumBlueBits; + result->cAccumAlphaBits = mode->accumAlphaBits; + } + + if (mode->haveDepthBuffer) { + result->cDepthBits = mode->depthBits; + } + if (mode->haveStencilBuffer) { + result->cStencilBits = mode->stencilBits; + } + + /* result->cAuxBuffers = mode->numAuxBuffers; */ + + /* mode->level ignored */ + + /* mode->pixmapMode ? */ + + *pfdret = pfd; + + return 0; +} + +static __GLinterface *glWinCreateContext(__GLimports *imports, + __GLcontextModes *mode, + __GLinterface *shareGC) +{ + __GLcontext *result; + + GLWIN_DEBUG_MSG("glWinCreateContext\n"); + + result = (__GLcontext *)calloc(1, sizeof(__GLcontext)); + if (!result) + return NULL; + + result->interface.imports = *imports; + result->interface.exports = glWinExports; + + if (makeFormat(mode, &result->pfd)) + { + ErrorF("makeFormat failed\n"); + free(result); + return NULL; + } + + if (glWinDebugSettings.dumpPFD) + pfdOut(&result->pfd); + + GLWIN_DEBUG_MSG("glWinCreateContext done\n"); + return (__GLinterface *)result; +} + +Bool +glWinRealizeWindow(WindowPtr pWin) +{ + /* If this window has GL contexts, tell them to reattach */ + /* reattaching is bad: display lists and parameters get lost */ + Bool result; + ScreenPtr pScreen = pWin->drawable.pScreen; + glWinScreenRec *screenPriv = &glWinScreens[pScreen->myNum]; + __GLXdrawablePrivate *glxPriv; + + GLWIN_DEBUG_MSG("glWinRealizeWindow\n"); + + /* Allow the window to be created (RootlessRealizeWindow is inside our wrap) */ + pScreen->RealizeWindow = screenPriv->RealizeWindow; + result = pScreen->RealizeWindow(pWin); + pScreen->RealizeWindow = glWinRealizeWindow; + + /* Re-attach this window's GL contexts, if any. */ + glxPriv = __glXFindDrawablePrivate(pWin->drawable.id); + if (glxPriv) { + __GLXcontext *gx; + __GLcontext *gc; + __GLdrawablePrivate *glPriv = &glxPriv->glPriv; + GLWIN_DEBUG_MSG("glWinRealizeWindow is GL drawable!\n"); + + /* GL contexts bound to this window for drawing */ + for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) { + gc = (__GLcontext *)gx->gc; + if (gc->isAttached) +#if 1 + { + GLWIN_DEBUG_MSG("context is already bound! Adjusting HWND.\n"); + glWinAdjustHWND(gc, pWin); + continue; + } +#else + unattach(gc); +#endif + attach(gc, glPriv); + } + + /* GL contexts bound to this window for reading */ + for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) { + gc = (__GLcontext *)gx->gc; + if (gc->isAttached) +#if 1 + { + GLWIN_DEBUG_MSG("context is already bound! Adjusting HWND.\n"); + glWinAdjustHWND(gc, pWin); + continue; + } +#else + unattach(gc); +#endif + attach(gc, glPriv); + } + } + + return result; +} + + +void +glWinCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) +{ + ScreenPtr pScreen = pWindow->drawable.pScreen; + glWinScreenRec *screenPriv = &glWinScreens[pScreen->myNum]; + __GLXdrawablePrivate *glxPriv; + + GLWIN_TRACE_MSG(" (pWindow %p)\n", pWindow); + + /* Check if the window is attached and discard any drawing request */ + glxPriv = __glXFindDrawablePrivate(pWindow->drawable.id); + if (glxPriv) { + __GLXcontext *gx; + + /* GL contexts bound to this window for drawing */ + for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) { +/* + GLWIN_DEBUG_MSG("glWinCopyWindow - calling glDrawBuffer\n"); + glDrawBuffer(GL_FRONT); + */ + + return; + } + + /* GL contexts bound to this window for reading */ + for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) { + return; + } + } + + GLWIN_DEBUG_MSG("glWinCopyWindow - passing to hw layer\n"); + + pScreen->CopyWindow = screenPriv->CopyWindow; + pScreen->CopyWindow(pWindow, ptOldOrg, prgnSrc); + pScreen->CopyWindow = glWinCopyWindow; +} + +Bool +glWinUnrealizeWindow(WindowPtr pWin) +{ + /* If this window has GL contexts, tell them to unattach */ + Bool result; + ScreenPtr pScreen = pWin->drawable.pScreen; + glWinScreenRec *screenPriv = &glWinScreens[pScreen->myNum]; + __GLXdrawablePrivate *glxPriv; + + GLWIN_DEBUG_MSG("glWinUnrealizeWindow\n"); + + /* The Aqua window may have already been destroyed (windows + * are unrealized from top down) + */ + + /* Unattach this window's GL contexts, if any. */ + glxPriv = __glXFindDrawablePrivate(pWin->drawable.id); + if (glxPriv) { + __GLXcontext *gx; + __GLcontext *gc; + GLWIN_DEBUG_MSG("glWinUnealizeWindow is GL drawable!\n"); + + /* GL contexts bound to this window for drawing */ + for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) { + gc = (__GLcontext *)gx->gc; + unattach(gc); + } + + /* GL contexts bound to this window for reading */ + for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) { + gc = (__GLcontext *)gx->gc; + unattach(gc); + } + } + + pScreen->UnrealizeWindow = screenPriv->UnrealizeWindow; + result = pScreen->UnrealizeWindow(pWin); + pScreen->UnrealizeWindow = glWinUnrealizeWindow; + + return result; +} + + +/* + * In the case the driver has no GLX visuals we'll use these. + * [0] = RGB, double buffered + * [1] = RGB, double buffered, stencil, accum + */ +/* Originally copied from Mesa */ + +static int numConfigs = 0; +static __GLXvisualConfig *visualConfigs = NULL; +static void **visualPrivates = NULL; + +#define NUM_FALLBACK_CONFIGS 2 +static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = { + { + -1, /* vid */ + -1, /* class */ + True, /* rgba */ + -1, -1, -1, 0, /* rgba sizes */ + -1, -1, -1, 0, /* rgba masks */ + 0, 0, 0, 0, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 0, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE_EXT, /* visualRating */ + 0, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, + { + -1, /* vid */ + -1, /* class */ + True, /* rgba */ + -1, -1, -1, 0, /* rgba sizes */ + -1, -1, -1, 0, /* rgba masks */ + 16, 16, 16, 0, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 8, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE_EXT, /* visualRating */ + 0, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + } +}; + +static __GLXvisualConfig NullConfig = { + -1, /* vid */ + -1, /* class */ + False, /* rgba */ + -1, -1, -1, 0, /* rgba sizes */ + -1, -1, -1, 0, /* rgba masks */ + 0, 0, 0, 0, /* rgba accum sizes */ + False, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 0, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE_EXT, /* visualRating */ + 0, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ +}; + +static inline int count_bits(uint32_t x) +{ + x = x - ((x >> 1) & 0x55555555); + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + x = (x + (x >> 4)) & 0x0f0f0f0f; + x = x + (x >> 8); + x = x + (x >> 16); + return x & 63; +} + +/* Mostly copied from Mesa's xf86glx.c */ +static Bool init_visuals(int *nvisualp, VisualPtr *visualp, + VisualID *defaultVisp, + int ndepth, DepthPtr pdepth, + int rootDepth) +{ + int numRGBconfigs; + int numCIconfigs; + int numVisuals = *nvisualp; + int numNewVisuals; + int numNewConfigs; + VisualPtr pVisual = *visualp; + VisualPtr pVisualNew = NULL; + VisualID *orig_vid = NULL; + __GLcontextModes *modes = NULL; + __GLXvisualConfig *pNewVisualConfigs = NULL; + void **glXVisualPriv; + void **pNewVisualPriv; + int found_default; + int i, j, k; + + GLWIN_DEBUG_MSG("init_visuals\n"); + + if (numConfigs > 0) + numNewConfigs = numConfigs; + else + numNewConfigs = NUM_FALLBACK_CONFIGS; + + /* Alloc space for the list of new GLX visuals */ + pNewVisualConfigs = (__GLXvisualConfig *) + __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig)); + if (!pNewVisualConfigs) { + return FALSE; + } + + /* Alloc space for the list of new GLX visual privates */ + pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *)); + if (!pNewVisualPriv) { + __glXFree(pNewVisualConfigs); + return FALSE; + } + + /* + ** If SetVisualConfigs was not called, then use default GLX + ** visual configs. + */ + if (numConfigs == 0) { + memcpy(pNewVisualConfigs, FallbackConfigs, + NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig)); + memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *)); + } + else { + /* copy driver's visual config info */ + for (i = 0; i < numConfigs; i++) { + pNewVisualConfigs[i] = visualConfigs[i]; + pNewVisualPriv[i] = visualPrivates[i]; + } + } + + /* Count the number of RGB and CI visual configs */ + numRGBconfigs = 0; + numCIconfigs = 0; + for (i = 0; i < numNewConfigs; i++) { + if (pNewVisualConfigs[i].rgba) + numRGBconfigs++; + else + numCIconfigs++; + } + + /* Count the total number of visuals to compute */ + numNewVisuals = 0; + for (i = 0; i < numVisuals; i++) { + int count; + + count = ((pVisual[i].class == TrueColor + || pVisual[i].class == DirectColor) + ? numRGBconfigs : numCIconfigs); + if (count == 0) + count = 1; /* preserve the existing visual */ + + numNewVisuals += count; + } + + /* Reset variables for use with the next screen/driver's visual configs */ + visualConfigs = NULL; + numConfigs = 0; + + /* Alloc temp space for the list of orig VisualIDs for each new visual */ + orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID)); + if (!orig_vid) { + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; + } + + /* Alloc space for the list of glXVisuals */ + modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes)); + if (modes == NULL) { + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; + } + + /* Alloc space for the list of glXVisualPrivates */ + glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *)); + if (!glXVisualPriv) { + _gl_context_modes_destroy( modes ); + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; + } + + /* Alloc space for the new list of the X server's visuals */ + pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec)); + if (!pVisualNew) { + __glXFree(glXVisualPriv); + _gl_context_modes_destroy( modes ); + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; + } + + /* Initialize the new visuals */ + found_default = FALSE; + glWinScreens[screenInfo.numScreens-1].modes = modes; + for (i = j = 0; i < numVisuals; i++) { + int is_rgb = (pVisual[i].class == TrueColor || + pVisual[i].class == DirectColor); + + if (!is_rgb) + { + /* We don't support non-rgb visuals for GL. But we don't + want to remove them either, so just pass them through + with null glX configs */ + + pVisualNew[j] = pVisual[i]; + pVisualNew[j].vid = FakeClientID(0); + + /* Check for the default visual */ + if (!found_default && pVisual[i].vid == *defaultVisp) { + *defaultVisp = pVisualNew[j].vid; + found_default = TRUE; + } + + /* Save the old VisualID */ + orig_vid[j] = pVisual[i].vid; + + /* Initialize the glXVisual */ + _gl_copy_visual_to_context_mode( modes, & NullConfig ); + modes->visualID = pVisualNew[j].vid; + + j++; + + continue; + } + + for (k = 0; k < numNewConfigs; k++) { + if (pNewVisualConfigs[k].rgba != is_rgb) + continue; + + assert( modes != NULL ); + + /* Initialize the new visual */ + pVisualNew[j] = pVisual[i]; + pVisualNew[j].vid = FakeClientID(0); + + /* Check for the default visual */ + if (!found_default && pVisual[i].vid == *defaultVisp) { + *defaultVisp = pVisualNew[j].vid; + found_default = TRUE; + } + + /* Save the old VisualID */ + orig_vid[j] = pVisual[i].vid; + + /* Initialize the glXVisual */ + _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] ); + modes->visualID = pVisualNew[j].vid; + + /* + * If the class is -1, then assume the X visual information + * is identical to what GLX needs, and take them from the X + * visual. NOTE: if class != -1, then all other fields MUST + * be initialized. + */ + if (modes->visualType == GLX_NONE) { + modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class ); + modes->redBits = count_bits(pVisual[i].redMask); + modes->greenBits = count_bits(pVisual[i].greenMask); + modes->blueBits = count_bits(pVisual[i].blueMask); + modes->alphaBits = modes->alphaBits; + modes->redMask = pVisual[i].redMask; + modes->greenMask = pVisual[i].greenMask; + modes->blueMask = pVisual[i].blueMask; + modes->alphaMask = modes->alphaMask; + modes->rgbBits = (is_rgb) + ? (modes->redBits + modes->greenBits + + modes->blueBits + modes->alphaBits) + : rootDepth; + } + + /* Save the device-dependent private for this visual */ + glXVisualPriv[j] = pNewVisualPriv[k]; + + j++; + modes = modes->next; + } + } + + assert(j <= numNewVisuals); + + /* Save the GLX visuals in the screen structure */ + glWinScreens[screenInfo.numScreens-1].num_vis = numNewVisuals; + glWinScreens[screenInfo.numScreens-1].priv = glXVisualPriv; + + /* Set up depth's VisualIDs */ + for (i = 0; i < ndepth; i++) { + int numVids = 0; + VisualID *pVids = NULL; + int k, n = 0; + + /* Count the new number of VisualIDs at this depth */ + for (j = 0; j < pdepth[i].numVids; j++) + for (k = 0; k < numNewVisuals; k++) + if (pdepth[i].vids[j] == orig_vid[k]) + numVids++; + + /* Allocate a new list of VisualIDs for this depth */ + pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID)); + + /* Initialize the new list of VisualIDs for this depth */ + for (j = 0; j < pdepth[i].numVids; j++) + for (k = 0; k < numNewVisuals; k++) + if (pdepth[i].vids[j] == orig_vid[k]) + pVids[n++] = pVisualNew[k].vid; + + /* Update this depth's list of VisualIDs */ + __glXFree(pdepth[i].vids); + pdepth[i].vids = pVids; + pdepth[i].numVids = numVids; + } + + /* Update the X server's visuals */ + *nvisualp = numNewVisuals; + *visualp = pVisualNew; + + /* Free the old list of the X server's visuals */ + __glXFree(pVisual); + + /* Clean up temporary allocations */ + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + + /* Free the private list created by DDX HW driver */ + if (visualPrivates) + xfree(visualPrivates); + visualPrivates = NULL; + + return TRUE; +} + + +static void fixup_visuals(int screen) +{ + ScreenPtr pScreen = screenInfo.screens[screen]; + glWinScreenRec *pScr = &glWinScreens[screen]; + __GLcontextModes *modes; + int j; + + GLWIN_DEBUG_MSG("fixup_visuals\n"); + + for (modes = pScr->modes; modes != NULL; modes = modes->next ) { + const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); + const int nplanes = (modes->rgbBits - modes->alphaBits); + VisualPtr pVis = pScreen->visuals; + + /* Find a visual that matches the GLX visual's class and size */ + for (j = 0; j < pScreen->numVisuals; j++) { + if (pVis[j].class == vis_class && + pVis[j].nplanes == nplanes) { + + /* Fixup the masks */ + modes->redMask = pVis[j].redMask; + modes->greenMask = pVis[j].greenMask; + modes->blueMask = pVis[j].blueMask; + + /* Recalc the sizes */ + modes->redBits = count_bits(modes->redMask); + modes->greenBits = count_bits(modes->greenMask); + modes->blueBits = count_bits(modes->blueMask); + } + } + } +} + +static void init_screen_visuals(int screen) +{ + ScreenPtr pScreen = screenInfo.screens[screen]; + __GLcontextModes *modes; + int *used; + int i, j; + + GLWIN_DEBUG_MSG("init_screen_visuals\n"); + + used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int)); + __glXMemset(used, 0, pScreen->numVisuals * sizeof(int)); + + i = 0; + for ( modes = glWinScreens[screen].modes + ; modes != NULL + ; modes = modes->next) { + const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); + const int nplanes = (modes->rgbBits - modes->alphaBits); + const VisualPtr pVis = pScreen->visuals; + + for (j = 0; j < pScreen->numVisuals; j++) { + + if (pVis[j].class == vis_class && + pVis[j].nplanes == nplanes && + pVis[j].redMask == modes->redMask && + pVis[j].greenMask == modes->greenMask && + pVis[j].blueMask == modes->blueMask && + !used[j]) { + +#if 0 + /* Create the XMesa visual */ + pXMesaVisual[i] = + XMesaCreateVisual(pScreen, + pVis, + modes->rgbMode, + (modes->alphaBits > 0), + modes->doubleBufferMode, + modes->stereoMode, + GL_TRUE, /* ximage_flag */ + modes->depthBits, + modes->stencilBits, + modes->accumRedBits, + modes->accumGreenBits, + modes->accumBlueBits, + modes->accumAlphaBits, + modes->samples, + modes->level, + modes->visualRating); +#endif + + /* Set the VisualID */ + modes->visualID = pVis[j].vid; + + /* Mark this visual used */ + used[j] = 1; + break; + } + } + + if ( j == pScreen->numVisuals ) { + ErrorF("No matching visual for __GLcontextMode with " + "visual class = %d (%d), nplanes = %u\n", + vis_class, + modes->visualType, + (modes->rgbBits - modes->alphaBits) ); + } + else if ( modes->visualID == -1 ) { + FatalError( "Matching visual found, but visualID still -1!\n" ); + } + + i++; + + } + + __glXFree(used); + + /* glWinScreens[screen].xm_vis = pXMesaVisual; */ +} + +static Bool glWinScreenProbe(int screen) +{ + ScreenPtr pScreen; + glWinScreenRec *screenPriv; + + GLWIN_DEBUG_MSG("glWinScreenProbe\n"); + + /* + * Set up the current screen's visuals. + */ + __glDDXScreenInfo.modes = glWinScreens[screen].modes; + __glDDXScreenInfo.pVisualPriv = glWinScreens[screen].priv; + __glDDXScreenInfo.numVisuals = + __glDDXScreenInfo.numUsableVisuals = glWinScreens[screen].num_vis; + + /* + * Set the current screen's createContext routine. This could be + * wrapped by a DDX GLX context creation routine. + */ + __glDDXScreenInfo.createContext = glWinCreateContext; + + /* + * The ordering of the rgb compenents might have been changed by the + * driver after mi initialized them. + */ + fixup_visuals(screen); + + /* + * Find the GLX visuals that are supported by this screen and create + * XMesa's visuals. + */ + init_screen_visuals(screen); + + /* Wrap RealizeWindow and UnrealizeWindow on this screen */ + pScreen = screenInfo.screens[screen]; + screenPriv = &glWinScreens[screen]; + screenPriv->RealizeWindow = pScreen->RealizeWindow; + pScreen->RealizeWindow = glWinRealizeWindow; + screenPriv->UnrealizeWindow = pScreen->UnrealizeWindow; + pScreen->UnrealizeWindow = glWinUnrealizeWindow; + screenPriv->CopyWindow = pScreen->CopyWindow; + pScreen->CopyWindow = glWinCopyWindow; + + return TRUE; +} + +static GLboolean glWinSwapBuffers(__GLXdrawablePrivate *glxPriv) +{ + /* swap buffers on only *one* of the contexts + * (e.g. the last one for drawing) + */ + __GLcontext *gc = (__GLcontext *)glxPriv->drawGlxc->gc; + HDC dc; + BOOL ret; + + GLWIN_TRACE_MSG("glWinSwapBuffers (ctx %p)\n", (gc!=NULL?gc->ctx:NULL)); + + if (gc != NULL && gc->ctx != NULL) + { + dc = glWinMakeDC(gc); + if (dc == NULL) + return GL_FALSE; + + ret = SwapBuffers(dc); + if (!ret) + ErrorF("SwapBuffers failed: %s\n", glWinErrorMessage()); + + ReleaseDC(gc->winInfo.hwnd, dc); + if (!ret) + return GL_FALSE; + } + + return GL_TRUE; +} + +static void glWinDestroyDrawablePrivate(__GLdrawablePrivate *glPriv) +{ + GLWIN_DEBUG_MSG("glWinDestroyDrawablePrivate\n"); + + /* It doesn't work to call DRIDestroySurface here, the drawable's + already gone.. But dri.c notices the window destruction and + frees the surface itself. */ + + free(glPriv->private); + glPriv->private = NULL; +} + + +static void glWinCreateBuffer(__GLXdrawablePrivate *glxPriv) +{ + GLWinDrawableRec *winPriv = malloc(sizeof(GLWinDrawableRec)); + __GLdrawablePrivate *glPriv = &glxPriv->glPriv; + + /*winPriv->sid = 0; */ + winPriv->pDraw = NULL; + + GLWIN_DEBUG_MSG("glWinCreateBuffer\n"); + + /* replace swapBuffers (original is never called) */ + glxPriv->swapBuffers = glWinSwapBuffers; + + /* stash private data */ + glPriv->private = winPriv; + glPriv->freePrivate = glWinDestroyDrawablePrivate; +} + +static void glWinResetExtension(void) +{ + GLWIN_DEBUG_MSG("glWinResetExtension\n"); +} + +/* based on code in apples/indirect.c which is based on i830_dri.c */ +static void +glWinInitVisualConfigs(void) +{ + int lclNumConfigs = 0; + __GLXvisualConfig *lclVisualConfigs = NULL; + void **lclVisualPrivates = NULL; + + int depth, aux, buffers, stencil, accum; + int i = 0; + + GLWIN_DEBUG_MSG("glWinInitVisualConfigs "); + + /* count num configs: + 2 Z buffer (0, 24 bit) + 2 AUX buffer (0, 2) + 2 buffers (single, double) + 2 stencil (0, 8 bit) + 2 accum (0, 64 bit) + = 32 configs */ + + lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */ + + /* alloc */ + lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs); + lclVisualPrivates = xcalloc(sizeof(void *), lclNumConfigs); + + /* fill in configs */ + if (NULL != lclVisualConfigs) { + i = 0; /* current buffer */ + for (depth = 0; depth < 2; depth++) { + for (aux = 0; aux < 2; aux++) { + for (buffers = 0; buffers < 2; buffers++) { + for (stencil = 0; stencil < 2; stencil++) { + for (accum = 0; accum < 2; accum++) { + lclVisualConfigs[i].vid = -1; + lclVisualConfigs[i].class = -1; + lclVisualConfigs[i].rgba = TRUE; + lclVisualConfigs[i].redSize = -1; + lclVisualConfigs[i].greenSize = -1; + lclVisualConfigs[i].blueSize = -1; + lclVisualConfigs[i].redMask = -1; + lclVisualConfigs[i].greenMask = -1; + lclVisualConfigs[i].blueMask = -1; + lclVisualConfigs[i].alphaMask = 0; + if (accum) { + lclVisualConfigs[i].accumRedSize = 16; + lclVisualConfigs[i].accumGreenSize = 16; + lclVisualConfigs[i].accumBlueSize = 16; + lclVisualConfigs[i].accumAlphaSize = 16; + } + else { + lclVisualConfigs[i].accumRedSize = 0; + lclVisualConfigs[i].accumGreenSize = 0; + lclVisualConfigs[i].accumBlueSize = 0; + lclVisualConfigs[i].accumAlphaSize = 0; + } + lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE; + lclVisualConfigs[i].stereo = FALSE; + lclVisualConfigs[i].bufferSize = -1; + + lclVisualConfigs[i].depthSize = depth? 24 : 0; + lclVisualConfigs[i].stencilSize = stencil ? 8 : 0; + lclVisualConfigs[i].auxBuffers = aux ? 2 : 0; + lclVisualConfigs[i].level = 0; + lclVisualConfigs[i].visualRating = GLX_NONE_EXT; + lclVisualConfigs[i].transparentPixel = 0; + lclVisualConfigs[i].transparentRed = 0; + lclVisualConfigs[i].transparentGreen = 0; + lclVisualConfigs[i].transparentBlue = 0; + lclVisualConfigs[i].transparentAlpha = 0; + lclVisualConfigs[i].transparentIndex = 0; + i++; + } + } + } + } + } + } + if (i != lclNumConfigs) + GLWIN_DEBUG_MSG("glWinInitVisualConfigs failed to alloc visual configs"); + + GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates); +} + +/* Copied from Mesa */ +static void glWinSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, + void **privates) +{ + GLWIN_DEBUG_MSG("glWinSetVisualConfigs\n"); + + numConfigs = nconfigs; + visualConfigs = configs; + visualPrivates = privates; +} + +/* Copied from Mesa */ +static Bool glWinInitVisuals(VisualPtr *visualp, DepthPtr *depthp, + int *nvisualp, int *ndepthp, + int *rootDepthp, VisualID *defaultVisp, + unsigned long sizes, int bitsPerRGB) +{ + glWinInitDebugSettings(); + + GLWIN_DEBUG_MSG("glWinInitVisuals\n"); + + if (0 == numConfigs) /* if no configs */ + glWinInitVisualConfigs(); /* ensure the visula configs are setup */ + + /* + * Setup the visuals supported by this particular screen. + */ + return init_visuals(nvisualp, visualp, defaultVisp, + *ndepthp, *depthp, *rootDepthp); +} --- xorg-server-1.4.99.906.orig/hw/xwin/glx/ChangeLog +++ xorg-server-1.4.99.906/hw/xwin/glx/ChangeLog @@ -0,0 +1,64 @@ +2005-09-27 Ian Romanick + + * indirect.c: + Remove __glEvalComputeK. It is no longer used. + + +2005-04-09 Alexander Gottwald + + * indirect.c: + Fix passing of non-RGB visuals. The old code did not initialize the + structure properly which lead to a crash in 8bpp mode + +2005-03-01 Alexander Gottwald + + * indirect.c: + * glwindows.h: + If a context is already attached copy it instead of reattaching to keep + displaylists and share displaylists + Enable tracing of often called functions with GLWIN_ENABLE_TRACE + ForceCurrent is a no-op now + +2005-02-02 Alexander Gottwald + + * Imakefile: + Bugzilla #1866 (https://bugs.freedesktop.org/show_bug.cgi?id=1866) + attachment #1819 (https://bugs.freedesktop.org/attachment.cgi?id=1819): + Define APIENTRY on windows to prevent from loading + +2005-02-02 Alexander Gottwald + + * glwrap.c: + * glwindows.h: + Bugzilla #1866 (https://bugs.freedesktop.org/show_bug.cgi?id=1866) + attachment #1818 (https://bugs.freedesktop.org/attachment.cgi?id=1818): + Include Xwindows.h before GL/gl.h to prevent loading windows.h which + pollutes our namespace with some symbols. + +2005-01-27 Alexander Gottwald + + * glwrap.c: + Functions like glGenTextures and glBindTexture are in OpenGL 1.1 + and can be resolved at linktime. + +2004-11-15 Alexander Gottwald + + * indirect.c: + Bugzilla #1802, http://freedesktop.org/bugzilla/show_bug.cgi?id=1802 + Added mingw (Win32) port + +2004-08-13 Alexander Gottwald + + * Imakefile: Added $(MESASRCDIR)/src/mesa/glapi to INCLUDES. + Removed $(SERVERSRC)/mi from INCLUDES. + Rearranged INCLUDES for better readability. + * glwindows.h: Removed mipointrst.h and miscstruct.h from #include + since they are not used anymore. + +2004-05-27 Alexander Gottwald + + * glwindows.h: write current function and line in debug output + * indirect.c: moved actual setup and creation of windows GL context to + glWinCreateContextReal. + * indirect.c (glWinCreateContext): Deferred context creation to attach. + * indirect.c (glWinMakeCurrent): Check if context is NULL. Fixes segfault. --- xorg-server-1.4.99.906.orig/hw/xwin/glx/glwindows.h +++ xorg-server-1.4.99.906/hw/xwin/glx/glwindows.h @@ -0,0 +1,64 @@ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +typedef struct { + unsigned enableDebug : 1; + unsigned enableTrace : 1; + unsigned dumpPFD : 1; + unsigned dumpHWND : 1; + unsigned dumpDC : 1; +} glWinDebugSettingsRec, *glWinDebugSettingsPtr; +extern glWinDebugSettingsRec glWinDebugSettings; + +typedef struct { + int num_vis; + __GLcontextModes *modes; + void **priv; + + /* wrapped screen functions */ + RealizeWindowProcPtr RealizeWindow; + UnrealizeWindowProcPtr UnrealizeWindow; + CopyWindowProcPtr CopyWindow; +} glWinScreenRec; + +extern glWinScreenRec glWinScreens[MAXSCREENS]; + +#define glWinGetScreenPriv(pScreen) &glWinScreens[pScreen->myNum] +#define glWinScreenPriv(pScreen) glWinScreenRec *pScreenPriv = glWinGetScreenPriv(pScreen); + +#if 1 +#define GLWIN_TRACE() if (glWinDebugSettings.enableTrace) ErrorF("%s:%d: Trace\n", __FUNCTION__, __LINE__ ) +#define GLWIN_TRACE_MSG(msg, args...) if (glWinDebugSettings.enableTrace) ErrorF("%s:%d: " msg, __FUNCTION__, __LINE__, ##args ) +#define GLWIN_DEBUG_MSG(msg, args...) if (glWinDebugSettings.enableDebug) ErrorF("%s:%d: " msg, __FUNCTION__, __LINE__, ##args ) +#define GLWIN_DEBUG_MSG2(msg, args...) if (glWinDebugSettings.enableDebug) ErrorF(msg, ##args ) +#else +#define GLWIN_TRACE() +#define GLWIN_TRACE_MSG(a, ...) +#define GLWIN_DEBUG_MSG(a, ...) +#define GLWIN_DEBUG_MSG2(a, ...) +#endif + --- xorg-server-1.4.99.906.orig/hw/kdrive/trident/trident.c +++ xorg-server-1.4.99.906/hw/kdrive/trident/trident.c @@ -0,0 +1,612 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "trident.h" +#include + +#undef TRI_DEBUG + +int trident_clk = 0; +int trident_mclk = 0; + +#define CLOCK 14318 /* KHz */ +#define CLK_N(a,b) (a & 0xff) +#define CLK_M(a,b) ((b) & 0x3f) +#define CLK_K(a,b) (((b) >> 6) & 3) +#define CLK_FREQ(a,b) (((CLK_N(a,b) + 8) * CLOCK) / ((CLK_M(a,b)+2) << CLK_K(a,b))) + +Bool +tridentCardInit (KdCardInfo *card) +{ + int k; + char *pixels; + TridentCardInfo *tridentc; + CARD8 r39; + + tridentc = (TridentCardInfo *) xalloc (sizeof (TridentCardInfo)); + if (!tridentc) + return FALSE; + + iopl (3); + tridentc->cop_base = (CARD8 *) KdMapDevice (TRIDENT_COP_BASE(card), + TRIDENT_COP_SIZE(card)); + + if (tridentc->cop_base) + { + KdSetMappedMode (TRIDENT_COP_BASE(card), + TRIDENT_COP_SIZE(card), + KD_MAPPED_MODE_REGISTERS); + } + tridentc->cop = (Cop *) (tridentc->cop_base + TRIDENT_COP_OFF(card)); + tridentc->mmio = FALSE; + r39 = tridentReadIndex (tridentc, 0x3d4, 0x39); + if (r39 & 1) + { + tridentc->mmio = TRUE; + r39 = tridentReadIndex (tridentc, 0x3d4, 0x39); + if ((r39 & 1) == 0) + { + ErrorF ("Trident: inconsisent IO mapping values\n"); + return FALSE; + } + } + +#ifdef VESA + if (!vesaInitialize (card, &tridentc->vesa)) +#else + if (!fbdevInitialize (card, &tridentc->fb)) +#endif + { + xfree (tridentc); + return FALSE; + } + +#ifdef USE_PCI + tridentc->window = (CARD32 *) (tridentc->cop_base + 0x10000); +#else + tridentc->window = 0; +#endif + card->driver = tridentc; + + return TRUE; +} + +Bool +tridentScreenInit (KdScreenInfo *screen) +{ + TridentCardInfo *tridentc = screen->card->driver; + TridentScreenInfo *tridents; + int screen_size, memory; + + tridents = (TridentScreenInfo *) xalloc (sizeof (TridentScreenInfo)); + if (!tridents) + return FALSE; + memset (tridents, '\0', sizeof (TridentScreenInfo)); +#ifdef VESA + if (!vesaScreenInitialize (screen, &tridents->vesa)) +#else + if (!fbdevScreenInitialize (screen, &tridents->fbdev)) +#endif + { + xfree (tridents); + return FALSE; + } + if (!tridentc->cop) + screen->dumb = TRUE; +#ifdef VESA + if (tridents->vesa.mapping != VESA_LINEAR) + screen->dumb = TRUE; + tridents->screen = tridents->vesa.fb; + memory = tridents->vesa.fb_size; +#else + tridents->screen = tridentc->fb.fb; + memory = (2048 + 512) * 1024; +#endif + screen_size = screen->fb[0].byteStride * screen->height; + if (tridents->screen && memory >= screen_size + 2048) + { + memory -= 2048; + tridents->cursor_base = tridents->screen + memory - 2048; + } + else + tridents->cursor_base = 0; + memory -= screen_size; + if (memory > screen->fb[0].byteStride) + { + tridents->off_screen = tridents->screen + screen_size; + tridents->off_screen_size = memory; + } + else + { + tridents->off_screen = 0; + tridents->off_screen_size = 0; + } + screen->driver = tridents; + return TRUE; +} + +Bool +tridentInitScreen (ScreenPtr pScreen) +{ +#ifdef VESA + return vesaInitScreen (pScreen); +#else + return fbdevInitScreen (pScreen); +#endif +} + +Bool +tridentFinishInitScreen (ScreenPtr pScreen) +{ +#ifdef VESA + return vesaFinishInitScreen (pScreen); +#endif +} + +CARD8 +tridentReadIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index) +{ + CARD8 value; + + if (tridentc->mmio) + { + tridentc->cop_base[port] = index; + value = tridentc->cop_base[port+1]; + } + else + { + outb (index, port); + value = inb (port+1); + } + return value; +} + +void +tridentWriteIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index, CARD8 value) +{ + if (tridentc->mmio) + { + tridentc->cop_base[port] = index; + tridentc->cop_base[port+1] = value; + } + else + { + outb (index, port); + outb (value, port+1); + } +} + +CARD8 +tridentReadReg (TridentCardInfo *tridentc, CARD16 port) +{ + CARD8 value; + + if (tridentc->mmio) + { + value = tridentc->cop_base[port]; + } + else + { + value = inb (port); + } + return value; +} + +void +tridentWriteReg (TridentCardInfo *tridentc, CARD16 port, CARD8 value) +{ + if (tridentc->mmio) + { + tridentc->cop_base[port] = value; + } + else + { + outb (value, port); + } +} + + +void +tridentPause () +{ + struct timeval tv; + + tv.tv_sec = 0; + tv.tv_usec = 50 * 1000; + select (1, 0, 0, 0, &tv); +} + +void +tridentPreserve (KdCardInfo *card) +{ + TridentCardInfo *tridentc = card->driver; + +#ifdef VESA + vesaPreserve(card); +#else + fbdevPreserve (card); +#endif + tridentPause (); + tridentc->save.reg_3c4_0e = tridentReadIndex (tridentc, 0x3c4, 0x0e); + tridentc->save.reg_3d4_36 = tridentReadIndex (tridentc, 0x3d4, 0x36); + tridentc->save.reg_3d4_39 = tridentReadIndex (tridentc, 0x3d4, 0x39); + tridentc->save.reg_3d4_62 = tridentReadIndex (tridentc, 0x3d4, 0x62); + tridentc->save.reg_3ce_21 = tridentReadIndex (tridentc, 0x3ce, 0x21); + tridentc->save.reg_3c2 = tridentReadReg (tridentc, 0x3cc); + tridentc->save.reg_3c4_16 = tridentReadIndex (tridentc, 0x3c4, 0x16); + tridentc->save.reg_3c4_17 = tridentReadIndex (tridentc, 0x3c4, 0x17); + tridentc->save.reg_3c4_18 = tridentReadIndex (tridentc, 0x3c4, 0x18); + tridentc->save.reg_3c4_19 = tridentReadIndex (tridentc, 0x3c4, 0x19); + ErrorF ("clk low 0x%x high 0x%x freq %d\n", + tridentc->save.reg_3c4_18, + tridentc->save.reg_3c4_19, + CLK_FREQ(tridentc->save.reg_3c4_18, + tridentc->save.reg_3c4_19)); +#ifdef TRI_DEBUG + fprintf (stderr, "3c4 0e: %02x\n", tridentc->save.reg_3c4_0e); + fprintf (stderr, "3d4 36: %02x\n", tridentc->save.reg_3d4_36); + fprintf (stderr, "3d4 39: %02x\n", tridentc->save.reg_3d4_39); + fprintf (stderr, "3d4 62: %02x\n", tridentc->save.reg_3d4_62); + fprintf (stderr, "3ce 21: %02x\n", tridentc->save.reg_3ce_21); + fflush (stderr); +#endif + tridentPause (); +} + +void +tridentSetCLK(int clock, CARD8 *a, CARD8 *b) +{ + int powerup[4] = { 1,2,4,8 }; + int clock_diff = 750; + int freq, ffreq; + int m, n, k; + int p, q, r, s; + int startn, endn; + int endm, endk; + + p = q = r = s = 0; + + startn = 64; + endn = 255; + endm = 63; + endk = 3; + + freq = clock; + + for (k=0;k<=endk;k++) + for (n=startn;n<=endn;n++) + for (m=1;m<=endm;m++) + { + ffreq = ( ( ((n + 8) * CLOCK) / ((m + 2) * powerup[k]) )); + if ((ffreq > freq - clock_diff) && (ffreq < freq + clock_diff)) + { + clock_diff = (freq > ffreq) ? freq - ffreq : ffreq - freq; + p = n; q = m; r = k; s = ffreq; + } + } + + ErrorF ("ffreq %d clock %d\n", s, clock); + if (s == 0) + { + FatalError("Unable to set programmable clock.\n" + "Frequency %d is not a valid clock.\n" + "Please modify XF86Config for a new clock.\n", + freq); + } + + /* N is all 8bits */ + *a = p; + /* M is first 6bits, with K last 2bits */ + *b = (q & 0x3F) | (r << 6); +} + +void +tridentSetMCLK(int clock, CARD8 *a, CARD8 *b) +{ + int powerup[4] = { 1,2,4,8 }; + int clock_diff = 750; + int freq, ffreq; + int m,n,k; + int p, q, r, s; + int startn, endn; + int endm, endk; + + p = q = r = s = 0; + + startn = 64; + endn = 255; + endm = 63; + endk = 3; + + freq = clock; + + for (k=0;k<=endk;k++) + for (n=startn;n<=endn;n++) + for (m=1;m<=endm;m++) { + ffreq = ((((n+8)*CLOCK)/((m+2)*powerup[k]))); + if ((ffreq > freq - clock_diff) && (ffreq < freq + clock_diff)) + { + clock_diff = (freq > ffreq) ? freq - ffreq : ffreq - freq; + p = n; q = m; r = k; s = ffreq; + } + } + + if (s == 0) + { + FatalError("Unable to set memory clock.\n" + "Frequency %d is not a valid clock.\n" + "Please modify XF86Config for a new clock.\n", + freq); + } + + /* N is all 8bits */ + *a = p; + /* M is first 6bits, with K last 2bits */ + *b = (q & 0x3F) | (r << 6); +} + +void +tridentSetMMIO (TridentCardInfo *tridentc) +{ + int tries; + CARD8 v; + +#ifdef TRI_DEBUG + fprintf (stderr, "Set MMIO\n"); +#endif + /* enable config port writes */ + for (tries = 0; tries < 3; tries++) + { + /* enable direct read when GE busy, enable PCI retries */ + tridentWriteIndex (tridentc, 0x3d4, 0x62, + tridentc->save.reg_3d4_62 | 0x70); + /* make sure the chip is in new mode */ + tridentReadIndex (tridentc, 0x3c4, 0xb); + /* enable access to upper registers */ + tridentWriteIndex (tridentc, 0x3c4, 0xe, + tridentc->save.reg_3c4_0e | 0x80); + v = tridentReadIndex (tridentc, 0x3c4, 0xe); + if (!(v & 0x80)) + { + fprintf (stderr, "Trident GE not enabled 0x%x\n", v); + continue; + } + /* enable screen */ + tridentWriteIndex (tridentc, 0x3ce, 0x21, 0x80); +#ifdef USE_PCI + /* enable burst r/w, enable memory mapped ports */ + tridentWriteIndex (tridentc, 0x3d4, 0x39, 7); + tridentc->mmio = TRUE; + /* reset GE, enable GE, set GE to pci 1 */ + tridentWriteIndex (tridentc, 0x3d4, 0x36, 0x90); +#else + /* enable burst r/w, disable memory mapped ports */ + tridentWriteIndex (tridentc, 0x3d4, 0x39, 0x6); + /* reset GE, enable GE, set GE to 0xbff00 */ + tridentWriteIndex (tridentc, 0x3d4, 0x36, 0x92); +#endif + /* set clock */ + if (trident_clk) + { + CARD8 a, b; + + a = tridentReadIndex (tridentc, 0x3c4, 0x18); + b = tridentReadIndex (tridentc, 0x3c4, 0x19); + ErrorF ("old clock 0x%x 0x%x %d\n", + a, b, CLK_FREQ(a,b)); + tridentSetCLK (trident_clk, &a, &b); + ErrorF ("clk %d-> 0x%x 0x%x %d\n", trident_clk, a, b, + CLK_FREQ(a,b)); +#if 1 + tridentWriteIndex (tridentc, 0x3c4, 0x18, a); + tridentWriteIndex (tridentc, 0x3c4, 0x19, b); +#endif + } + if (trident_mclk) + { + CARD8 a, b; + + tridentSetMCLK (trident_mclk, &a, &b); + ErrorF ("mclk %d -> 0x%x 0x%x\n", trident_mclk, a, b); +#if 0 + tridentWriteIndex (tridentc, 0x3c4, 0x16, a); + tridentWriteIndex (tridentc, 0x3c4, 0x17, b); +#endif + } + if (trident_clk || trident_mclk) + { + CARD8 mode; + + mode = tridentReadReg (tridentc, 0x3cc); + ErrorF ("old mode 0x%x\n", mode); + mode = (mode & 0xf3) | 0x08; + ErrorF ("new mode 0x%x\n", mode); +#if 1 + tridentWriteReg (tridentc, 0x3c2, mode); +#endif + } +#ifdef TRI_DEBUG + fprintf (stderr, "0x36: 0x%02x\n", + tridentReadIndex (tridentc, 0x3d4, 0x36)); +#endif + if (tridentc->cop->status != 0xffffffff) + break; + } +#ifdef TRI_DEBUG + fprintf (stderr, "COP status 0x%x\n", tridentc->cop->status); +#endif + if (tridentc->cop->status == 0xffffffff) + FatalError ("Trident COP not visible\n"); +} + +void +tridentResetMMIO (TridentCardInfo *tridentc) +{ +#ifdef TRI_DEBUG + fprintf (stderr, "Reset MMIO\n"); +#endif + tridentPause (); +#if 0 + tridentWriteIndex (tridentc, 0x3c4, 0x16, tridentc->save.reg_3c4_16); + tridentWriteIndex (tridentc, 0x3c4, 0x17, tridentc->save.reg_3c4_17); +#endif + tridentWriteIndex (tridentc, 0x3c4, 0x18, tridentc->save.reg_3c4_18); + tridentWriteIndex (tridentc, 0x3c4, 0x19, tridentc->save.reg_3c4_19); + tridentWriteReg (tridentc, 0x3c2, tridentc->save.reg_3c2); + tridentPause (); + tridentWriteIndex (tridentc, 0x3ce, 0x21, tridentc->save.reg_3ce_21); + tridentPause (); + tridentWriteIndex (tridentc, 0x3d4, 0x62, tridentc->save.reg_3d4_62); + tridentWriteIndex (tridentc, 0x3d4, 0x39, tridentc->save.reg_3d4_39); + tridentc->mmio = FALSE; + tridentWriteIndex (tridentc, 0x3d4, 0x36, tridentc->save.reg_3d4_36); + tridentWriteIndex (tridentc, 0x3c4, 0x0e, tridentc->save.reg_3c4_0e); + tridentPause (); +} + +Bool +tridentEnable (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + TridentCardInfo *tridentc = pScreenPriv->card->driver; + +#ifdef VESA + if (!vesaEnable (pScreen)) + return FALSE; +#else + if (!fbdevEnable (pScreen)) + return FALSE; +#endif + tridentSetMMIO (tridentc); + return TRUE; +} + +void +tridentDisable (ScreenPtr pScreen) +{ +#ifdef VESA + vesaDisable (pScreen); +#else + fbdevDisable (pScreen); +#endif +} + +const CARD8 tridentDPMSModes[4] = { + 0x80, /* KD_DPMS_NORMAL */ + 0x8c, /* KD_DPMS_STANDBY */ + 0x8c, /* KD_DPMS_STANDBY */ + 0x8c, /* KD_DPMS_STANDBY */ +/* 0xb0, /* KD_DPMS_SUSPEND */ +/* 0xbc, /* KD_DPMS_POWERDOWN */ +}; + +Bool +tridentDPMS (ScreenPtr pScreen, int mode) +{ + KdScreenPriv(pScreen); + TridentCardInfo *tridentc = pScreenPriv->card->driver; + + tridentWriteIndex (tridentc, 0x3ce, 0x21, tridentDPMSModes[mode]); + tridentPause (); + return TRUE; +} + +void +tridentRestore (KdCardInfo *card) +{ + TridentCardInfo *tridentc = card->driver; + + tridentResetMMIO (tridentc); +#ifdef VESA + vesaRestore (card); +#else + fbdevRestore (card); +#endif +} + +void +tridentScreenFini (KdScreenInfo *screen) +{ + TridentScreenInfo *tridents = (TridentScreenInfo *) screen->driver; + +#ifdef VESA + vesaScreenFini (screen); +#endif + xfree (tridents); + screen->driver = 0; +} + +void +tridentCardFini (KdCardInfo *card) +{ + TridentCardInfo *tridentc = card->driver; + + if (tridentc->cop_base) + { + KdUnmapDevice ((void *) tridentc->cop_base, TRIDENT_COP_SIZE(card)); + KdResetMappedMode (TRIDENT_COP_BASE(card), + TRIDENT_COP_SIZE(card), + KD_MAPPED_MODE_REGISTERS); + } +#ifdef VESA + vesaCardFini (card); +#else + fbdevCardFini (card); +#endif +} + +KdCardFuncs tridentFuncs = { + tridentCardInit, /* cardinit */ + tridentScreenInit, /* scrinit */ + tridentInitScreen, /* initScreen */ + tridentPreserve, /* preserve */ + tridentEnable, /* enable */ + tridentDPMS, /* dpms */ + tridentDisable, /* disable */ + tridentRestore, /* restore */ + tridentScreenFini, /* scrfini */ + tridentCardFini, /* cardfini */ + + tridentCursorInit, /* initCursor */ + tridentCursorEnable, /* enableCursor */ + tridentCursorDisable, /* disableCursor */ + tridentCursorFini, /* finiCursor */ + tridentRecolorCursor, /* recolorCursor */ + + tridentDrawInit, /* initAccel */ + tridentDrawEnable, /* enableAccel */ + tridentDrawSync, /* syncAccel */ + tridentDrawDisable, /* disableAccel */ + tridentDrawFini, /* finiAccel */ + +#ifdef VESA + vesaGetColors, /* getColors */ + vesaPutColors, /* putColors */ +#else + fbdevGetColors, /* getColors */ + fbdevPutColors, /* putColors */ +#endif + tridentFinishInitScreen /* finishInitScreen */ +}; --- xorg-server-1.4.99.906.orig/hw/kdrive/trident/tridentdraw.h +++ xorg-server-1.4.99.906/hw/kdrive/trident/tridentdraw.h @@ -0,0 +1,69 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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. + */ + +#ifndef _TRIDENTDRAW_H_ +#define _TRIDENTDRAW_H_ + +#define SetupTrident(s) KdScreenPriv(s); \ + tridentCardInfo(pScreenPriv); \ + Cop *cop = tridentc->cop + +#define TridentAlpha (COP_MULTI_ALPHA|COP_ALPHA_WRITE_ENABLE) + +#define _tridentInit(cop,tridentc) { \ + if ((cop)->status == 0xffffffff) tridentSetMMIO(tridentc); \ + (cop)->multi = (tridentc)->cop_depth; \ + (cop)->multi = (tridentc)->cop_stride; \ + (cop)->multi = TridentAlpha; \ +} \ + +#define _tridentSetSolidRect(cop,pix,alu,cmd) {\ + cop->multi = COP_MULTI_PATTERN; \ + cop->multi = COP_MULTI_ROP | tridentRop[alu]; \ + cop->fg = (pix); \ + cmd = COP_OP_BLT | COP_SCL_OPAQUE | COP_OP_ROP | COP_OP_FG; \ +} + +#define _tridentRect(cop,x1,y1,x2,y2,cmd) { \ + (cop)->dst_start_xy = TRI_XY (x1,y1); \ + (cop)->dst_end_xy = TRI_XY(x2,y2); \ + _tridentWaitDone(cop); \ + (cop)->command = (cmd); \ +} + +#define COP_STATUS_BUSY (COP_STATUS_BE_BUSY | \ + COP_STATUS_DPE_BUSY | \ + COP_STATUS_MI_BUSY) + +#define _tridentWaitDone(cop) { \ + int __q__ = 500000; \ + while (__q__-- && (cop)->status & COP_STATUS_BUSY) \ + ; \ + if (!__q__) \ + (cop)->status = 0; \ +} + +#define _tridentWaitIdleEmpty(cop) _tridentWaitDone(cop) + +#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3)) + +#endif --- xorg-server-1.4.99.906.orig/hw/kdrive/trident/tridentcurs.c +++ xorg-server-1.4.99.906/hw/kdrive/trident/tridentcurs.c @@ -0,0 +1,389 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "trident.h" +#include "cursorstr.h" + +#define SetupCursor(s) KdScreenPriv(s); \ + tridentCardInfo(pScreenPriv); \ + tridentScreenInfo(pScreenPriv); \ + TridentCursor *pCurPriv = &tridents->cursor + +static void +_tridentMoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CARD8 xlow, xhigh, ylow, yhigh; + CARD8 xoff, yoff; + + x -= pCurPriv->xhot; + xoff = 0; + if (x < 0) + { + xoff = -x; + x = 0; + } + y -= pCurPriv->yhot; + yoff = 0; + if (y < 0) + { + yoff = -y; + y = 0; + } + xlow = (CARD8) x; + xhigh = (CARD8) (x >> 8); + ylow = (CARD8) y; + yhigh = (CARD8) (y >> 8); + + + /* This is the recommended order to move the cursor */ + + tridentWriteIndex (tridentc, 0x3d4, 0x41, xhigh); + tridentWriteIndex (tridentc, 0x3d4, 0x40, xlow); + tridentWriteIndex (tridentc, 0x3d4, 0x42, ylow); + tridentWriteIndex (tridentc, 0x3d4, 0x46, xoff); + tridentWriteIndex (tridentc, 0x3d4, 0x47, yoff); + tridentWriteIndex (tridentc, 0x3d4, 0x43, yhigh); +} + +static void +tridentMoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor (pScreen); + + if (!pCurPriv->has_cursor) + return; + + if (!pScreenPriv->enabled) + return; + + _tridentMoveCursor (pScreen, x, y); +} + +static void +tridentAllocCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + + KdAllocateCursorPixels (pScreen, 0, pCursor, + &pCurPriv->source, &pCurPriv->mask); + switch (pScreenPriv->screen->fb[0].bitsPerPixel) { + case 4: + pCurPriv->source |= pCurPriv->source << 4; + pCurPriv->mask |= pCurPriv->mask << 4; + case 8: + pCurPriv->source |= pCurPriv->source << 8; + pCurPriv->mask |= pCurPriv->mask << 8; + case 16: + pCurPriv->source |= pCurPriv->source << 16; + pCurPriv->mask |= pCurPriv->mask << 16; + } +} + +static void +tridentSetCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + CARD32 fg, bg; + + fg = pCurPriv->source; + bg = pCurPriv->mask; + tridentWriteIndex (tridentc, 0x3d4, 0x48, fg); + tridentWriteIndex (tridentc, 0x3d4, 0x49, fg >> 8); + tridentWriteIndex (tridentc, 0x3d4, 0x4a, fg >> 16); + + tridentWriteIndex (tridentc, 0x3d4, 0x4c, bg); + tridentWriteIndex (tridentc, 0x3d4, 0x4d, bg >> 8); + tridentWriteIndex (tridentc, 0x3d4, 0x4e, bg >> 16); +} + +void +tridentRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + xColorItem sourceColor, maskColor; + + if (!pCurPriv->has_cursor || !pCursor) + return; + + if (!pScreenPriv->enabled) + return; + + if (pdef) + { + while (ndef) + { + if (pdef->pixel == pCurPriv->source || + pdef->pixel == pCurPriv->mask) + break; + ndef--; + } + if (!ndef) + return; + } + tridentAllocCursorColors (pScreen); + tridentSetCursorColors (pScreen); +} + +#define InvertBits32(v) { \ + v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ + v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ + v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ +} + +static void +tridentLoadCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + CursorBitsPtr bits = pCursor->bits; + int w, h; + CARD32 *ram, *msk, *mskLine, *src, *srcLine; + int i, j; + int cursor_address; + int lwsrc; + unsigned char ramdac_control_; + CARD32 offset; + + /* + * Allocate new colors + */ + tridentAllocCursorColors (pScreen); + + pCurPriv->pCursor = pCursor; + pCurPriv->xhot = pCursor->bits->xhot; + pCurPriv->yhot = pCursor->bits->yhot; + + /* + * Stick new image into cursor memory + */ + ram = (CARD32 *) tridents->cursor_base; + mskLine = (CARD32 *) bits->mask; + srcLine = (CARD32 *) bits->source; + + h = bits->height; + if (h > TRIDENT_CURSOR_HEIGHT) + h = TRIDENT_CURSOR_HEIGHT; + + lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */ + + for (i = 0; i < TRIDENT_CURSOR_HEIGHT; i++) { + msk = mskLine; + src = srcLine; + mskLine += lwsrc; + srcLine += lwsrc; + for (j = 0; j < TRIDENT_CURSOR_WIDTH / 32; j++) { + + CARD32 m, s; + +#if 1 + if (i < h && j < lwsrc) + { + m = *msk++; + s = *src++; + InvertBits32(m); + InvertBits32(s); + } + else + { + m = 0; + s = 0; + } +#endif + *ram++ = m; + *ram++ = s; + } + } + + /* Set address for cursor bits */ + offset = tridents->cursor_base - (CARD8 *) tridents->screen; + offset >>= 10; + tridentWriteIndex (tridentc, 0x3d4, 0x44, (CARD8) (offset & 0xff)); + tridentWriteIndex (tridentc, 0x3d4, 0x45, (CARD8) (offset >> 8)); + + /* Set new color */ + tridentSetCursorColors (pScreen); + + /* Enable the cursor */ + tridentWriteIndex (tridentc, 0x3d4, 0x50, 0xc1); + + /* Move to new position */ + tridentMoveCursor (pScreen, x, y); +} + +static void +tridentUnloadCursor (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + /* Disable cursor */ + tridentWriteIndex (tridentc, 0x3d4, 0x50, 0); +} + +static Bool +tridentRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + SetupCursor(pScreen); + + if (!pScreenPriv->enabled) + return TRUE; + + /* miRecolorCursor does this */ + if (pCurPriv->pCursor == pCursor) + { + if (pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + tridentLoadCursor (pScreen, x, y); + } + } + return TRUE; +} + +static Bool +tridentUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + return TRUE; +} + +static void +tridentSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +{ + SetupCursor(pScreen); + + pCurPriv->pCursor = pCursor; + + if (!pScreenPriv->enabled) + return; + + if (pCursor) + tridentLoadCursor (pScreen, x, y); + else + tridentUnloadCursor (pScreen); +} + +miPointerSpriteFuncRec tridentPointerSpriteFuncs = { + tridentRealizeCursor, + tridentUnrealizeCursor, + tridentSetCursor, + tridentMoveCursor, +}; + +static void +tridentQueryBestSize (int class, + unsigned short *pwidth, unsigned short *pheight, + ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + switch (class) + { + case CursorShape: + if (*pwidth > pCurPriv->width) + *pwidth = pCurPriv->width; + if (*pheight > pCurPriv->height) + *pheight = pCurPriv->height; + if (*pwidth > pScreen->width) + *pwidth = pScreen->width; + if (*pheight > pScreen->height) + *pheight = pScreen->height; + break; + default: + fbQueryBestSize (class, pwidth, pheight, pScreen); + break; + } +} + +Bool +tridentCursorInit (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!tridents->cursor_base) + { + pCurPriv->has_cursor = FALSE; + return FALSE; + } + + pCurPriv->width = TRIDENT_CURSOR_WIDTH; + pCurPriv->height= TRIDENT_CURSOR_HEIGHT; + pScreen->QueryBestSize = tridentQueryBestSize; + miPointerInitialize (pScreen, + &tridentPointerSpriteFuncs, + &kdPointerScreenFuncs, + FALSE); + pCurPriv->has_cursor = TRUE; + pCurPriv->pCursor = NULL; + return TRUE; +} + +void +tridentCursorEnable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + tridentLoadCursor (pScreen, x, y); + } + else + tridentUnloadCursor (pScreen); + } +} + +void +tridentCursorDisable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!pScreenPriv->enabled) + return; + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + tridentUnloadCursor (pScreen); + } + } +} + +void +tridentCursorFini (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + pCurPriv->pCursor = NULL; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/trident/trident.h +++ xorg-server-1.4.99.906/hw/kdrive/trident/trident.h @@ -0,0 +1,269 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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. + */ + +#ifndef _TRIDENT_H_ +#define _TRIDENT_H_ +#ifdef VESA +#include +#else +#include +#endif + +/* + * offset from ioport beginning + */ + +#ifdef USE_PCI +#define TRIDENT_COP_BASE(c) (c->attr.address[1]) +#define TRIDENT_COP_OFF(c) 0x2100 +#define TRIDENT_COP_SIZE(c) 0x20000 +#else +#define TRIDENT_COP_BASE(c) 0xbf000 +#define TRIDENT_COP_OFF(c) 0x00f00 +#define TRIDENT_COP_SIZE(c) (0x2000) +#endif + +typedef volatile CARD8 VOL8; +typedef volatile CARD16 VOL16; +typedef volatile CARD32 VOL32; + +typedef struct _cop { + VOL32 src_start_xy; /* 0x00 */ + VOL32 src_end_xy; /* 0x04 */ + VOL32 dst_start_xy; /* 0x08 */ + VOL32 dst_end_xy; /* 0x0c */ + VOL32 alpha; /* 0x10 */ + CARD8 pad14[0xc]; /* 0x14 */ + VOL32 multi; /* 0x20 */ + +#define COP_MULTI_CLIP_TOP_LEFT 0x10000000 +#define COP_MULTI_DEPTH 0x40000000 +#define COP_MULTI_COLOR_KEY 0x70000000 +#define COP_MULTI_STYLE 0x50000000 +#define COP_MULTI_PATTERN 0x80000000 +#define COP_MULTI_ROP 0x90000000 +#define COP_MULTI_STRIDE 0x60000000 +#define COP_MULTI_Z 0xa0000000 +#define COP_MULTI_ALPHA 0xb0000000 +#define COP_MULTI_TEXTURE 0xd0000000 +#define COP_MULTI_TEXTURE_BOUND 0xe0000000 +#define COP_MULTI_TEXTURE_ADVANCED 0x20000000 +#define COP_MULTI_MASK 0xf0000000 + +#define COP_DEPTH_8 0x00000000 +#define COP_DEPTH_16 0x00000001 +#define COP_DEPTH_24_32 0x00000002 +#define COP_DEPTH_15 0x00000005 +#define COP_DEPTH_DITHER_DISABLE 0x00000008 + + +#define COP_ALPHA_SRC_BLEND_0 0x00000000 +#define COP_ALPHA_SRC_BLEND_1 0x00000001 +#define COP_ALPHA_SRC_BLEND_SRC_C 0x00000002 +#define COP_ALPHA_SRC_BLEND_1_SRC_C 0x00000003 +#define COP_ALPHA_SRC_BLEND_SRC_A 0x00000004 +#define COP_ALPHA_SRC_BLEND_1_SRC_A 0x00000005 +#define COP_ALPHA_SRC_BLEND_DST_A 0x00000006 +#define COP_ALPHA_SRC_BLEND_1_DST_A 0x00000007 +#define COP_ALPHA_SRC_BLEND_DST_C 0x00000008 +#define COP_ALPHA_SRC_BLEND_1_DST_C 0x00000009 +#define COP_ALPHA_SRC_BLEND_SAT 0x0000000A +#define COP_ALPHA_SRC_BLEND_BG 0x0000000B + +#define COP_ALPHA_DST_BLEND_0 0x00000000 +#define COP_ALPHA_DST_BLEND_1 0x00000010 +#define COP_ALPHA_DST_BLEND_SRC_C 0x00000020 +#define COP_ALPHA_DST_BLEND_1_SRC_C 0x00000030 +#define COP_ALPHA_DST_BLEND_SRC_A 0x00000040 +#define COP_ALPHA_DST_BLEND_1_SRC_A 0x00000050 +#define COP_ALPHA_DST_BLEND_DST_A 0x00000060 +#define COP_ALPHA_DST_BLEND_1_DST_A 0x00000070 +#define COP_ALPHA_DST_BLEND_DST_C 0x00000080 +#define COP_ALPHA_DST_BLEND_1_DST_C 0x00000090 +#define COP_ALPHA_DST_BLEND_OTHER 0x000000A0 + +#define COP_ALPHA_RESULT_ALPHA 0x00100000 +#define COP_ALPHA_DEST_ALPHA 0x00200000 +#define COP_ALPHA_SOURCE_ALPHA 0x00400000 +#define COP_ALPHA_WRITE_ENABLE 0x00800000 +#define COP_ALPHA_TEST_ENABLE 0x01000000 +#define COP_ALPHA_BLEND_ENABLE 0x02000000 +#define COP_ALPHA_DEST_VALUE 0x04000000 +#define COP_ALPHA_SOURCE_VALUE 0x08000000 + + VOL32 command; /* 0x24 */ +#define COP_OP_NULL 0x00000000 +#define COP_OP_LINE 0x20000000 +#define COP_OP_BLT 0x80000000 +#define COP_OP_TEXT 0x90000000 +#define COP_OP_POLY 0xb0000000 +#define COP_OP_POLY2 0xe0000000 +#define COP_SCL_EXPAND 0x00800000 +#define COP_SCL_OPAQUE 0x00400000 +#define COP_SCL_REVERSE 0x00200000 +#define COP_SCL_MONO_OFF 0x001c0000 +#define COP_LIT_TEXTURE 0x00004000 +#define COP_BILINEAR 0x00002000 +#define COP_OP_ZBUF 0x00000800 +#define COP_OP_ROP 0x00000400 +#define COP_OP_FG 0x00000200 +#define COP_OP_FB 0x00000080 +#define COP_X_REVERSE 0x00000004 +#define COP_CLIP 0x00000001 + VOL32 texture_format; /* 0x28 */ + CARD8 pad2c[0x4]; /* 0x2c */ + + VOL32 clip_bottom_right; /* 0x30 */ + VOL32 dataIII; /* 0x34 */ + VOL32 dataIV; /* 0x38 */ + CARD8 pad3c[0x8]; /* 0x3c */ + + VOL32 fg; /* 0x44 */ + VOL32 bg; /* 0x48 */ + CARD8 pad4c[0x4]; /* 0x4c */ + + VOL32 pattern_fg; /* 0x50 */ + VOL32 pattern_bg; /* 0x54 */ + CARD8 pad58[0xc]; /* 0x58 */ + + VOL32 status; /* 0x64 */ +#define COP_STATUS_BE_BUSY 0x80000000 +#define COP_STATUS_DPE_BUSY 0x20000000 +#define COP_STATUS_MI_BUSY 0x10000000 +#define COP_STATUS_FIFO_BUSY 0x08000000 +#define COP_STATUS_WB_BUSY 0x00800000 +#define COP_STATUS_Z_FAILED 0x00400000 +#define COP_STATUS_EFFECTIVE 0x00200000 +#define COP_STATUS_LEFT_VIEW 0x00080000 + + CARD8 pad68[0x4]; /* 0x68 */ + + VOL32 src_offset; /* 0x6c */ + VOL32 z_offset; /* 0x70 */ + CARD8 pad74[0x4]; /* 0x74 */ + + VOL32 display_offset; /* 0x78 */ + VOL32 dst_offset; /* 0x7c */ + CARD8 pad80[0x34]; /* 0x80 */ + + VOL32 semaphore; /* 0xb4 */ +} Cop; + +#define TRI_XY(x,y) ((y) << 16 | (x)) + +typedef struct _tridentSave { + CARD8 reg_3c4_0e; /* config port value */ + CARD8 reg_3d4_36; + CARD8 reg_3d4_39; + CARD8 reg_3d4_62; /* GE setup */ + CARD8 reg_3ce_21; /* DPMS */ + CARD8 reg_3c2; /* clock config */ + CARD8 reg_3c4_16; /* MCLKLow */ + CARD8 reg_3c4_17; /* MCLKHigh */ + CARD8 reg_3c4_18; /* ClockLow */ + CARD8 reg_3c4_19; /* ClockHigh */ +} TridentSave; + +typedef struct _tridentCardInfo { +#ifdef VESA + VesaCardPrivRec vesa; +#else + FbdevPriv fb; +#endif + CARD8 *cop_base; + Cop *cop; + CARD32 *window; + CARD32 cop_depth; + CARD32 cop_stride; + Bool mmio; + TridentSave save; +} TridentCardInfo; + +#define getTridentCardInfo(kd) ((TridentCardInfo *) ((kd)->card->driver)) +#define tridentCardInfo(kd) TridentCardInfo *tridentc = getTridentCardInfo(kd) + +typedef struct _tridentCursor { + int width, height; + int xhot, yhot; + Bool has_cursor; + CursorPtr pCursor; + Pixel source, mask; +} TridentCursor; + +#define TRIDENT_CURSOR_WIDTH 64 +#define TRIDENT_CURSOR_HEIGHT 64 + +typedef struct _tridentScreenInfo { +#ifdef VESA + VesaScreenPrivRec vesa; +#else + FbdevScrPriv fbdev; +#endif + CARD8 *cursor_base; + CARD8 *screen; + CARD8 *off_screen; + int off_screen_size; + TridentCursor cursor; +} TridentScreenInfo; + +#define getTridentScreenInfo(kd) ((TridentScreenInfo *) ((kd)->screen->driver)) +#define tridentScreenInfo(kd) TridentScreenInfo *tridents = getTridentScreenInfo(kd) + +Bool +tridentDrawInit (ScreenPtr pScreen); + +void +tridentDrawEnable (ScreenPtr pScreen); + +void +tridentDrawSync (ScreenPtr pScreen); + +void +tridentDrawDisable (ScreenPtr pScreen); + +void +tridentDrawFini (ScreenPtr pScreen); + +CARD8 +tridentReadIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index); + +void +tridentWriteIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index, CARD8 value); + +Bool +tridentCursorInit (ScreenPtr pScreen); + +void +tridentCursorEnable (ScreenPtr pScreen); + +void +tridentCursorDisable (ScreenPtr pScreen); + +void +tridentCursorFini (ScreenPtr pScreen); + +void +tridentRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef); + +extern KdCardFuncs tridentFuncs; + +#endif /* _TRIDENT_H_ */ --- xorg-server-1.4.99.906.orig/hw/kdrive/trident/tridentdraw.c +++ xorg-server-1.4.99.906/hw/kdrive/trident/tridentdraw.c @@ -0,0 +1,496 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "trident.h" +#include "tridentdraw.h" + +#include "Xmd.h" +#include "gcstruct.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "regionstr.h" +#include "mistruct.h" +#include "fontstruct.h" +#include "dixfontstr.h" +#include "fb.h" +#include "migc.h" +#include "miline.h" +#include "picturestr.h" + +CARD8 tridentRop[16] = { + /* GXclear */ 0x00, /* 0 */ + /* GXand */ 0x88, /* src AND dst */ + /* GXandReverse */ 0x44, /* src AND NOT dst */ + /* GXcopy */ 0xcc, /* src */ + /* GXandInverted*/ 0x22, /* NOT src AND dst */ + /* GXnoop */ 0xaa, /* dst */ + /* GXxor */ 0x66, /* src XOR dst */ + /* GXor */ 0xee, /* src OR dst */ + /* GXnor */ 0x11, /* NOT src AND NOT dst */ + /* GXequiv */ 0x99, /* NOT src XOR dst */ + /* GXinvert */ 0x55, /* NOT dst */ + /* GXorReverse */ 0xdd, /* src OR NOT dst */ + /* GXcopyInverted*/ 0x33, /* NOT src */ + /* GXorInverted */ 0xbb, /* NOT src OR dst */ + /* GXnand */ 0x77, /* NOT src OR NOT dst */ + /* GXset */ 0xff, /* 1 */ +}; + +#define tridentFillPix(bpp,pixel) {\ + if (bpp == 8) \ + { \ + pixel = pixel & 0xff; \ + pixel = pixel | pixel << 8; \ + } \ + if (bpp <= 16) \ + { \ + pixel = pixel & 0xffff; \ + pixel = pixel | pixel << 16; \ + } \ +} + +static Cop *cop; +static CARD32 cmd; + +Bool +tridentPrepareSolid (DrawablePtr pDrawable, + int alu, + Pixel pm, + Pixel fg) +{ + FbBits depthMask = FbFullMask(pDrawable->depth); + + if ((pm & depthMask) != depthMask) + return FALSE; + else + { + KdScreenPriv(pDrawable->pScreen); + tridentCardInfo(pScreenPriv); + cop = tridentc->cop; + + tridentFillPix(pDrawable->bitsPerPixel,fg); + _tridentInit(cop,tridentc); + _tridentSetSolidRect(cop,fg,alu,cmd); + return TRUE; + } +} + +void +tridentSolid (int x1, int y1, int x2, int y2) +{ + _tridentRect (cop, x1, y1, x2 - 1, y2 - 1, cmd); +} + +void +tridentDoneSolid (void) +{ +} + +Bool +tridentPrepareCopy (DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + int dx, + int dy, + int alu, + Pixel pm) +{ + FbBits depthMask = FbFullMask(pDstDrawable->depth); + + if ((pm & depthMask) == depthMask) + { + KdScreenPriv(pDstDrawable->pScreen); + tridentCardInfo(pScreenPriv); + cop = tridentc->cop; + _tridentInit(cop,tridentc); + cop->multi = COP_MULTI_PATTERN; + cop->multi = COP_MULTI_ROP | tridentRop[alu]; + cmd = COP_OP_BLT | COP_SCL_OPAQUE | COP_OP_ROP | COP_OP_FB; + if (dx < 0 || dy < 0) + cmd |= COP_X_REVERSE; + return TRUE; + } + else + return FALSE; +} + +void +tridentCopy (int srcX, + int srcY, + int dstX, + int dstY, + int w, + int h) +{ + if (cmd & COP_X_REVERSE) + { + cop->src_start_xy = TRI_XY (srcX + w - 1, srcY + h - 1); + cop->src_end_xy = TRI_XY (srcX, srcY); + cop->dst_start_xy = TRI_XY (dstX + w - 1, dstY + h - 1); + cop->dst_end_xy = TRI_XY (dstX, dstY); + } + else + { + cop->src_start_xy = TRI_XY (srcX, srcY); + cop->src_end_xy = TRI_XY (srcX + w - 1, srcY + h - 1); + cop->dst_start_xy = TRI_XY (dstX, dstY); + cop->dst_end_xy = TRI_XY (dstX + w - 1, dstY + h - 1); + } + _tridentWaitDone (cop); + cop->command = cmd; +} + +void +tridentDoneCopy (void) +{ +} + +void +tridentComposite (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + SetupTrident (pDst->pDrawable->pScreen); + tridentScreenInfo(pScreenPriv); + RegionRec region; + int n; + BoxPtr pbox; + CARD32 rgb; + CARD8 *msk, *mskLine; + FbBits *mskBits; + FbStride mskStride; + int mskBpp; + int mskXoff, mskYoff; + CARD32 *src, *srcLine; + CARD32 *off, *offLine; + FbBits *srcBits; + FbStride srcStride; + int srcXoff, srcYoff; + FbStride offStride; + int srcBpp; + int x_msk, y_msk, x_src, y_src, x_dst, y_dst; + int x2; + int w, h, w_this, h_this, w_remain; + CARD32 *off_screen; + int off_size = tridents->off_screen_size >> 2; + int off_width, off_height; + int stride = pScreenPriv->screen->fb[0].pixelStride; + int mskExtra; + CARD32 off_screen_offset = tridents->off_screen - tridents->screen; + int mode; + +#define MODE_NONE 0 +#define MODE_IMAGE 1 +#define MODE_MASK 2 + + rgb = *((CARD32 *) ((PixmapPtr) (pSrc->pDrawable))->devPrivate.ptr); + if (pMask && + !pMask->repeat && + pMask->format == PICT_a8 && + op == PictOpOver && + pSrc->repeat && + pSrc->pDrawable->width == 1 && + pSrc->pDrawable->height == 1 && + PICT_FORMAT_BPP(pSrc->format) == 32 && + (PICT_FORMAT_A(pSrc->format) == 0 || + (rgb & 0xff000000) == 0xff000000) && + pDst->pDrawable->bitsPerPixel == 32 && + pDst->pDrawable->type == DRAWABLE_WINDOW) + { + mode = MODE_MASK; + } + else if (!pMask && + op == PictOpOver && + !pSrc->repeat && + PICT_FORMAT_A(pSrc->format) == 8 && + PICT_FORMAT_BPP(pSrc->format) == 32 && + pDst->pDrawable->bitsPerPixel == 32 && + pDst->pDrawable->type == DRAWABLE_WINDOW) + { + mode = MODE_IMAGE; + } + else + mode = MODE_NONE; + + if (mode != MODE_NONE) + { + xDst += pDst->pDrawable->x; + yDst += pDst->pDrawable->y; + xSrc += pSrc->pDrawable->x; + ySrc += pSrc->pDrawable->y; + + fbGetDrawable (pSrc->pDrawable, srcBits, srcStride, srcBpp, srcXoff, srcYoff); + + if (pMask) + { + xMask += pMask->pDrawable->x; + yMask += pMask->pDrawable->y; + fbGetDrawable (pMask->pDrawable, mskBits, mskStride, mskBpp, mskXoff, mskYoff); + mskStride = mskStride * sizeof (FbBits) / sizeof (CARD8); + } + + if (!miComputeCompositeRegion (®ion, + pSrc, + pMask, + pDst, + xSrc, + ySrc, + xMask, + yMask, + xDst, + yDst, + width, + height)) + return; + + _tridentInit(cop,tridentc); + + cop->multi = COP_MULTI_PATTERN; + cop->src_offset = off_screen_offset; + + if (mode == MODE_IMAGE) + { + cop->multi = (COP_MULTI_ALPHA | + COP_ALPHA_BLEND_ENABLE | + COP_ALPHA_WRITE_ENABLE | + 0x7 << 16 | + COP_ALPHA_DST_BLEND_1_SRC_A | + COP_ALPHA_SRC_BLEND_1); + } + else + { + rgb &= 0xffffff; + cop->multi = (COP_MULTI_ALPHA | + COP_ALPHA_BLEND_ENABLE | + COP_ALPHA_WRITE_ENABLE | + 0x7 << 16 | + COP_ALPHA_DST_BLEND_1_SRC_A | + COP_ALPHA_SRC_BLEND_SRC_A); + } + + n = REGION_NUM_RECTS (®ion); + pbox = REGION_RECTS (®ion); + + while (n--) + { + h = pbox->y2 - pbox->y1; + w = pbox->x2 - pbox->x1; + + offStride = (w + 7) & ~7; + off_height = off_size / offStride; + if (off_height > h) + off_height = h; + + cop->multi = COP_MULTI_STRIDE | (stride << 16) | offStride; + + y_dst = pbox->y1; + y_src = y_dst - yDst + ySrc; + y_msk = y_dst - yDst + yMask; + + x_dst = pbox->x1; + x_src = x_dst - xDst + xSrc; + x_msk = x_dst - xDst + xMask; + + if (mode == MODE_IMAGE) + srcLine = (CARD32 *) srcBits + (y_src - srcYoff) * srcStride + (x_src - srcXoff); + else + mskLine = (CARD8 *) mskBits + (y_msk - mskYoff) * mskStride + (x_msk - mskXoff); + + while (h) + { + h_this = h; + if (h_this > off_height) + h_this = off_height; + h -= h_this; + + offLine = (CARD32 *) tridents->off_screen; + + _tridentWaitDone(cop); + + cop->dst_start_xy = TRI_XY(x_dst, y_dst); + cop->dst_end_xy = TRI_XY(x_dst + w - 1, y_dst + h_this - 1); + cop->src_start_xy = TRI_XY(0,0); + cop->src_end_xy = TRI_XY(w - 1, h_this - 1); + + if (mode == MODE_IMAGE) + { + while (h_this--) + { + w_remain = w; + src = srcLine; + srcLine += srcStride; + off = offLine; + offLine += offStride; + while (w_remain--) + *off++ = *src++; + } + } + else + { + while (h_this--) + { + w_remain = w; + msk = mskLine; + mskLine += mskStride; + off = offLine; + offLine += offStride; + while (w_remain--) + *off++ = rgb | (*msk++ << 24); + } + } + + cop->command = (COP_OP_BLT | + COP_SCL_OPAQUE | + COP_OP_FB); + } + pbox++; + } + cop->src_offset = 0; + + KdMarkSync (pDst->pDrawable->pScreen); + } + else + { + KdCheckComposite (op, + pSrc, + pMask, + pDst, + xSrc, + ySrc, + xMask, + yMask, + xDst, + yDst, + width, + height); + } +} + +KaaScreenPrivRec tridentKaa = { + tridentPrepareSolid, + tridentSolid, + tridentDoneSolid, + + tridentPrepareCopy, + tridentCopy, + tridentDoneCopy, +}; + +Bool +tridentDrawInit (ScreenPtr pScreen) +{ + SetupTrident(pScreen); + tridentScreenInfo(pScreenPriv); + PictureScreenPtr ps = GetPictureScreen(pScreen); + + if (!kaaDrawInit (pScreen, &tridentKaa)) + return FALSE; + + if (ps && tridents->off_screen) + ps->Composite = tridentComposite; + + return TRUE; +} + +void +tridentDrawEnable (ScreenPtr pScreen) +{ + SetupTrident(pScreen); + CARD32 cmd; + CARD32 base; + CARD16 stride; + CARD32 format; + CARD32 alpha; + int tries; + int nwrite; + + stride = pScreenPriv->screen->fb[0].pixelStride; + switch (pScreenPriv->screen->fb[0].bitsPerPixel) { + case 8: + format = COP_DEPTH_8; + break; + case 16: + format = COP_DEPTH_16; + break; + case 24: + format = COP_DEPTH_24_32; + break; + case 32: + format = COP_DEPTH_24_32; + break; + } + /* + * compute a few things which will be set every time the + * accelerator is used; this avoids problems with APM + */ + tridentc->cop_depth = COP_MULTI_DEPTH | format; + tridentc->cop_stride = COP_MULTI_STRIDE | (stride << 16) | (stride); + +#define NUM_TRIES 100000 + for (tries = 0; tries < NUM_TRIES; tries++) + if (!(cop->status & COP_STATUS_BUSY)) + break; + if (cop->status & COP_STATUS_BUSY) + FatalError ("Can't initialize graphics coprocessor"); + cop->multi = COP_MULTI_CLIP_TOP_LEFT; + cop->multi = COP_MULTI_MASK | 0; + cop->src_offset = 0; + cop->dst_offset = 0; + cop->z_offset = 0; + cop->clip_bottom_right = 0x0fff0fff; + + _tridentInit(cop,tridentc); + _tridentSetSolidRect(cop, pScreen->blackPixel, GXcopy, cmd); + _tridentRect (cop, 0, 0, + pScreenPriv->screen->width, pScreenPriv->screen->height, + cmd); + KdMarkSync (pScreen); +} + +void +tridentDrawDisable (ScreenPtr pScreen) +{ +} + +void +tridentDrawFini (ScreenPtr pScreen) +{ +} + +void +tridentDrawSync (ScreenPtr pScreen) +{ + SetupTrident(pScreen); + + _tridentWaitIdleEmpty(cop); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/trident/tridentstub.c +++ xorg-server-1.4.99.906/hw/kdrive/trident/tridentstub.c @@ -0,0 +1,94 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "trident.h" + +extern int trident_clk, trident_mclk; + +void +InitCard (char *name) +{ + KdCardAttr attr; + + if (LinuxFindPci (0x1023, 0x9525, 0, &attr)) + KdCardInfoAdd (&tridentFuncs, &attr, 0); +} + +void +InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) +{ + KdInitOutput (pScreenInfo, argc, argv); +} + +void +InitInput (int argc, char **argv) +{ + KdOsAddInputDrivers (); + KdInitInput (); +} + +void +ddxUseMsg (void) +{ +#if 0 + ErrorF("\nTrident Driver Options:\n"); + ErrorF("-clk XXX: what's this?\n"); + ErrorF("-mclk XXX: what's this?\n"); +#endif + KdUseMsg(); +#ifdef VESA + vesaUseMsg() +#endif +} + +int +ddxProcessArgument (int argc, char **argv, int i) +{ + int ret; + + if (!strcmp (argv[i], "-clk")) + { + if (i+1 < argc) + trident_clk = atoi (argv[i+1]); + else + UseMsg (); + return 2; + } + if (!strcmp (argv[i], "-mclk")) + { + if (i+1 < argc) + trident_mclk = atoi (argv[i+1]); + else + UseMsg (); + return 2; + } + +#ifdef VESA + if (!(ret = vesaProcessArgument (argc, argv, i))) +#endif + ret = KdProcessArgument(argc, argv, i); + return ret; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/itsy/itsy.c +++ xorg-server-1.4.99.906/hw/kdrive/itsy/itsy.c @@ -0,0 +1,325 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "itsy.h" + +/* struct with LCD characteristics defined in fb_brutus.h */ +static struct FbLcdParamsStruct fbLcdParams; +static int fb_d; +static int fbn; +Bool +itsyCardInit (KdCardInfo *card) +{ + int k; + char *fb; + char *pixels; + + if ((fb_d = open("/dev/fbclone", O_RDWR)) < 0) { + perror("Error opening /dev/fb\n"); + return FALSE; + } + if ((k=ioctl(fb_d, FB_LCD_PARAMS, &fbLcdParams)) != 0) { + perror("Error with /dev/fb ioctl FB_LCD_PARAMS call"); + return FALSE; + } + + fb = (char *) mmap ((caddr_t) NULL, fbLcdParams.frameBufferSize, + PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fb_d, 0); + + fprintf (stderr, "fb mapped at 0x%x\n", fb); + if (fb == (char *)-1) { + perror("ERROR: mmap framebuffer fails!"); + return FALSE; + } + + card->driver = fb; + + return TRUE; +} + +Bool +itsyScreenInit (KdScreenInfo *screen) +{ + CARD8 *fb = screen->card->driver; + + screen->width = fbLcdParams.screenSizeH; + screen->height = fbLcdParams.screenSizeV; + screen->depth = fbLcdParams.bitsPerPixel; + screen->bitsPerPixel = fbLcdParams.bitsPerPixel; + screen->byteStride = fbLcdParams.frameBufferSizeH; + screen->pixelStride = (fbLcdParams.frameBufferSizeH * 8 / + fbLcdParams.bitsPerPixel); + fprintf (stderr, "width %d height %d depth %d pstride %d bstride %d\n", + screen->width, screen->height, screen->depth, + screen->pixelStride, screen->byteStride); + screen->dumb = FALSE; + screen->softCursor = TRUE; + screen->blueMask = 0; + screen->greenMask = 0; + screen->redMask = 0; + screen->visuals = 1 << StaticGray; + screen->rate = 72; + screen->frameBuffer = (CARD8 *) (fb + + fbLcdParams.pixelDataOffset + + (fbLcdParams.reserveTopRows * + screen->byteStride)); + fprintf (stderr, "Frame buffer 0x%x\n", screen->frameBuffer); + return TRUE; +} + +static unsigned short itsyIntensity[16] = { + 0xffff, + 0xffff, + 0xedb6, + 0xdb6d, + 0xc924, + 0xb6db, + 0xa492, + 0x9249, + 0x8000, + 0x6db6, + 0x5b6d, + 0x4924, + 0x36db, + 0x2492, + 0x1249, + 0x0000, +}; + +Bool +itsyCreateColormap (ColormapPtr pmap) +{ + int i; + + for (i = 0; i < 16; i++) + { + pmap->red[i].co.local.red = itsyIntensity[i]; + pmap->red[i].co.local.green = itsyIntensity[i]; + pmap->red[i].co.local.blue = itsyIntensity[i]; + } + return TRUE; +} + +Bool +itsyInitScreen (ScreenPtr pScreen) +{ + pScreen->CreateColormap = itsyCreateColormap; + return TRUE; +} + +void +itsyPreserve (KdCardInfo *card) +{ +} + +void +itsyEnable (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + + fprintf (stderr, "Enabling LCD display\n"); + /* display it on the LCD */ + ioctl(fb_d, FB_LCD_SHOW, 0); +} + +Bool +itsyDPMS (ScreenPtr pScreen, int mode) +{ + if (mode) + ioctl (fb_d, FB_LCD_OFF, 0); + else + ioctl (fb_d, FB_LCD_ON, 0); + return TRUE; +} + +void +itsyDisable (ScreenPtr pScreen) +{ +/* ioctl (fb_d, FB_LCD_SWITCH, 0); */ +/* fprintf (stderr, "Disabling LCD display\n");*/ +} + +void +itsyRestore (KdCardInfo *card) +{ +} + +void +itsyScreenFini (KdScreenInfo *screen) +{ +} + +void +itsyCardFini (KdCardInfo *card) +{ + int k; + + fprintf (stderr, "Unmapping driver at 0x%x\n", card->driver); + munmap (card->driver, fbLcdParams.frameBufferSize); + fprintf (stderr, "Releasing fbn %d\n", fbn); + /* release it */ + if (ioctl(fb_d, FB_LCD_FREE, fbn) != 0) { + printf("FB_LCD_FREE of %d fails!\n", fbn); + } + close (fb_d); + fprintf (stderr, "itsyFini done\n"); +} + +KdCardFuncs itsyFuncs = { + itsyCardInit, /* cardinit */ + itsyScreenInit, /* scrinit */ + itsyInitScreen, /* initScreen */ + itsyPreserve, /* preserve */ + itsyEnable, /* enable */ + itsyDPMS, /* dpms */ + itsyDisable, /* disable */ + itsyRestore, /* restore */ + itsyScreenFini, /* scrfini */ + itsyCardFini, /* cardfini */ + + 0, /* initCursor */ + 0, /* enableCursor */ + 0, /* disableCursor */ + 0, /* finiCursor */ + 0, /* recolorCursor */ + + 0, /* initAccel */ + 0, /* enableAccel */ + 0, /* disableAccel */ + 0, /* finiAccel */ + + 0, /* getColors */ + 0, /* putColors */ +}; + +void +InitCard (void) +{ + KdCardAttr attr; + + KdCardInfoAdd (&itsyFuncs, &attr, 0); +} + +void +InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) +{ + KdInitOutput (pScreenInfo, argc, argv); +} + +void +InitInput (int argc, char **argv) +{ + KdInitInput (&itsyTsMouseFuncs, &itsyKeyboardFuncs); +} + +int itsySessionFd = -1; + +int +ItsyOsInit (void) +{ + pid_t sid; + int i; + itsy_session_info info; + + if (itsySessionFd < 0) + { + itsySessionFd = open ("/dev/session", 0); + ErrorF("itsySessionFD %d\n", itsySessionFd); + } + + (void) setsid (); + sid = getsid (0); + ErrorF ("Session ID %d PID %d\n", sid, getpid ()); + info.sid = sid; + strcpy (info.name, "X"); + if (itsySessionFd >= 0) + { + i = ioctl (itsySessionFd, SESSION_SET_INFO, &info); + if (i < 0) + perror ("SESSION_SET_INFO"); + } + return 1; +} + +void +ItsyOsEnable (void) +{ + itsy_session_request req; + int i; + +#define MANAGER_SID_TO_FOREGROUND 2 + + req.operation = MANAGER_SID_TO_FOREGROUND; + req.data = 0; + if (itsySessionFd >= 0) + { + i = ioctl (itsySessionFd, SESSION_MANAGER_REQUEST, &req); + if (i < 0) + perror ("SESSION_MANAGER_REQUEST"); + } +} + +Bool +ItsyOsSpecialKey (KeySym sym) +{ + return FALSE; +} + +void +ItsyOsDisable (void) +{ +} + +void +ItsyOsFini (void) +{ +} + +KdOsFuncs ItsyOsFuncs = { + ItsyOsInit, + ItsyOsEnable, + ItsyOsSpecialKey, + ItsyOsDisable, + ItsyOsFini, + 0 +}; + +void +OsVendorInit (void) +{ + KdOsInit (&ItsyOsFuncs); +} + +void +ddxUseMsg (void) +{ + KdUseMsg(); +} + +int +ddxProcessArgument (int argc, char **argv, int i) +{ + return KdProcessArgument (argc, argv, i); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/itsy/kbd.c +++ xorg-server-1.4.99.906/hw/kdrive/itsy/kbd.c @@ -0,0 +1,251 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "itsy.h" +#include +#include + +#define ITSY_WIDTH 2 + +KeySym ItsyKeymap[] = { +/* 1 8 */ XK_Escape, NoSymbol, +/* 2 9 */ XK_1, XK_exclam, +/* 3 10 */ XK_2, XK_at, +/* 4 11 */ XK_3, XK_numbersign, +/* 5 12 */ XK_4, XK_dollar, +/* 6 13 */ XK_5, XK_percent, +/* 7 14 */ XK_6, XK_asciicircum, +/* 8 15 */ XK_7, XK_ampersand, +/* 9 16 */ XK_8, XK_asterisk, +/* 10 17 */ XK_9, XK_parenleft, +/* 11 18 */ XK_0, XK_parenright, +/* 12 19 */ XK_minus, XK_underscore, +/* 13 20 */ XK_equal, XK_plus, +/* 14 21 */ XK_BackSpace, NoSymbol, +/* 15 22 */ XK_Tab, NoSymbol, +/* 16 23 */ XK_Q, NoSymbol, +/* 17 24 */ XK_W, NoSymbol, +/* 18 25 */ XK_E, NoSymbol, +/* 19 26 */ XK_R, NoSymbol, +/* 20 27 */ XK_T, NoSymbol, +/* 21 28 */ XK_Y, NoSymbol, +/* 22 29 */ XK_U, NoSymbol, +/* 23 30 */ XK_I, NoSymbol, +/* 24 31 */ XK_O, NoSymbol, +/* 25 32 */ XK_P, NoSymbol, +/* 26 33 */ XK_bracketleft, XK_braceleft, +/* 27 34 */ XK_bracketright, XK_braceright, +/* 28 35 */ XK_Return, NoSymbol, +/* 29 36 */ XK_Control_L, NoSymbol, +/* 30 37 */ XK_A, NoSymbol, +/* 31 38 */ XK_S, NoSymbol, +/* 32 39 */ XK_D, NoSymbol, +/* 33 40 */ XK_F, NoSymbol, +/* 34 41 */ XK_G, NoSymbol, +/* 35 42 */ XK_H, NoSymbol, +/* 36 43 */ XK_J, NoSymbol, +/* 37 44 */ XK_K, NoSymbol, +/* 38 45 */ XK_L, NoSymbol, +/* 39 46 */ XK_semicolon, XK_colon, +/* 40 47 */ XK_apostrophe, XK_quotedbl, +/* 41 48 */ XK_grave, XK_asciitilde, +/* 42 49 */ XK_Shift_L, NoSymbol, +/* 43 50 */ XK_backslash, XK_bar, +/* 44 51 */ XK_Z, NoSymbol, +/* 45 52 */ XK_X, NoSymbol, +/* 46 53 */ XK_C, NoSymbol, +/* 47 54 */ XK_V, NoSymbol, +/* 48 55 */ XK_B, NoSymbol, +/* 49 56 */ XK_N, NoSymbol, +/* 50 57 */ XK_M, NoSymbol, +/* 51 58 */ XK_comma, XK_less, +/* 52 59 */ XK_period, XK_greater, +/* 53 60 */ XK_slash, XK_question, +/* 54 61 */ XK_Shift_R, NoSymbol, +/* 55 62 */ XK_KP_Multiply, NoSymbol, +/* 56 63 */ XK_Alt_L, XK_Meta_L, +/* 57 64 */ XK_space, NoSymbol, +/* 58 65 */ XK_Caps_Lock, NoSymbol, +/* 59 66 */ XK_F1, NoSymbol, +/* 60 67 */ XK_F2, NoSymbol, +/* 61 68 */ XK_F3, NoSymbol, +/* 62 69 */ XK_F4, NoSymbol, +/* 63 70 */ XK_F5, NoSymbol, +/* 64 71 */ XK_F6, NoSymbol, +/* 65 72 */ XK_F7, NoSymbol, +/* 66 73 */ XK_F8, NoSymbol, +/* 67 74 */ XK_F9, NoSymbol, +/* 68 75 */ XK_F10, NoSymbol, +/* 69 76 */ XK_Break, XK_Pause, +/* 70 77 */ XK_Scroll_Lock, NoSymbol, +/* 71 78 */ XK_KP_Home, XK_KP_7, +/* 72 79 */ XK_KP_Up, XK_KP_8, +/* 73 80 */ XK_KP_Page_Up, XK_KP_9, +/* 74 81 */ XK_KP_Subtract, NoSymbol, +/* 75 82 */ XK_KP_Left, XK_KP_4, +/* 76 83 */ XK_KP_5, NoSymbol, +/* 77 84 */ XK_KP_Right, XK_KP_6, +/* 78 85 */ XK_KP_Add, NoSymbol, +/* 79 86 */ XK_KP_End, XK_KP_1, +/* 80 87 */ XK_KP_Down, XK_KP_2, +/* 81 88 */ XK_KP_Page_Down, XK_KP_3, +/* 82 89 */ XK_KP_Insert, XK_KP_0, +/* 83 90 */ XK_KP_Delete, XK_KP_Decimal, +/* 84 91 */ NoSymbol, NoSymbol, +/* 85 92 */ NoSymbol, NoSymbol, +/* 86 93 */ NoSymbol, NoSymbol, +/* 87 94 */ XK_F11, NoSymbol, +/* 88 95 */ XK_F12, NoSymbol, + +/* These are remapped from the extended set (using ExtendMap) */ + +/* 89 96 */ XK_Control_R, NoSymbol, +/* 90 97 */ XK_KP_Enter, NoSymbol, +/* 91 98 */ XK_KP_Divide, NoSymbol, +/* 92 99 */ XK_Sys_Req, XK_Print, +/* 93 100 */ XK_Alt_R, XK_Meta_R, +/* 94 101 */ XK_Num_Lock, NoSymbol, +/* 95 102 */ XK_Home, NoSymbol, +/* 96 103 */ XK_Up, NoSymbol, +/* 97 104 */ XK_Page_Up, NoSymbol, +/* 98 105 */ XK_Left, NoSymbol, +/* 99 106 */ XK_Right, NoSymbol, +/* 100 107 */ XK_End, NoSymbol, +/* 101 108 */ XK_Down, NoSymbol, +/* 102 109 */ XK_Page_Down, NoSymbol, +/* 103 110 */ XK_Insert, NoSymbol, +/* 104 111 */ XK_Delete, NoSymbol, +/* 105 112 */ XK_Super_L, NoSymbol, +/* 106 113 */ XK_Super_R, NoSymbol, +/* 107 114 */ XK_Menu, NoSymbol, + +/* Itsy hardware buttons */ +#define ITSY_BUTTON_FIRST 108 +#define ITSY_BUTTON_LAST 116 + +/* 108 115 */ XK_Next, NoSymbol, /* right button on side */ +/* 109 116 */ XK_Prior, NoSymbol, /* left button on side */ +/* 110 117 */ XK_Up, NoSymbol, /* joypad */ +/* 111 118 */ XK_Down, NoSymbol, +/* 112 119 */ XK_Left, NoSymbol, +/* 113 120 */ XK_Right, NoSymbol, +/* 114 121 */ NoSymbol, NoSymbol, /* left near speaker */ +/* 115 122 */ NoSymbol, NoSymbol, /* right near speaker */ +/* 116 123 */ NoSymbol, NoSymbol, /* tiny button */ +}; + +static unsigned long itsyButtonState; + +void +ItsyKeyboardLoad (void) +{ + KeySym *k; + +} + +static Status +ItsyKeyboardInit (KdKeyboardInfo *ki) +{ + if (!ki) + return BadImplementation; + + ki->driverPrivate = open ("/dev/buttons", 0); + + itsyButtonState = 0; + ki->keySyms.minKeyCode = 1; + ki->keySyms.maxKeyCode = (sizeof (ItsyKeymap) / sizeof (ItsyKeymap[0])) / ITSY_WIDTH; + ki->minScanCode = ki->keySyms.minKeyCode; + ki->maxScanCode = ki->keySyms.maxKeyCode; + ki->keySyms.mapWidth = ITSY_WIDTH; + + if (ki->keySyms.map) + xfree(ki->keySyms.map); + ki->keySyms.map = xalloc(sizeof(ItsyKeymap)); + if (!ki->keySyms.map) + return BadAlloc; + memcpy (kdKeymap, ItsyKeymap, sizeof (ItsyKeymap)); + + return Success; +} + +static void +ItsyKeyboardDisable (KdKeybdInfo *ki) +{ + if (fd >= 0) + close ((int)ki->driverPrivate); +} + +static void +ItsyKeyboardFini (KdKeybdInfo *ki) +{ + return; +} + +void +ItsyKeyboardRead (int fd) +{ + itsy_buttons_event event; + int b; + unsigned long bit; + unsigned long change; + unsigned long buttons; + + if (read (fd, &event, sizeof (event)) == sizeof (event)) + { + buttons = event.state; + change = buttons ^ itsyButtonState; + if (!change) + return; + for (b = ITSY_BUTTON_FIRST; b <= ITSY_BUTTON_LAST; b++) + { + bit = (1 << (b - ITSY_BUTTON_FIRST)); + if (change & bit) + KdEnqueueKeyboardEvent (b, (buttons & bit) == 0); + } + itsyButtonState = buttons; + } +} + +void +ItsyKeyboardLeds (int leds) +{ +} + +void +ItsyKeyboardBell (int volume, int frequency, int duration) +{ +} + +KdKeyboardFuncs itsyKeyboardFuncs = { + "itsy", + ItsyKeyboardInit, + ItsyKeyboardEnable, + ItsyKeyboardRead, + ItsyKeyboardLeds, + ItsyKeyboardBell, + ItsyKeyboardDisable + ItsyKeyboardFini, + NULL, +}; --- xorg-server-1.4.99.906.orig/hw/kdrive/itsy/ts.c +++ xorg-server-1.4.99.906/hw/kdrive/itsy/ts.c @@ -0,0 +1,210 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#define NEED_EVENTS +#include "itsy.h" +#include +#include "inputstr.h" +#include "Xpoll.h" + +int +itsyTsReadBytes (int fd, char *buf, int len, int min) +{ + int n, tot; + fd_set set; + struct timeval tv; + + tot = 0; + while (len) + { + n = read (fd, buf, len); + if (n > 0) + { + tot += n; + buf += n; + len -= n; + } + if (tot % min == 0) + break; + FD_ZERO (&set); + FD_SET (fd, &set); + tv.tv_sec = 0; + tv.tv_usec = 100 * 1000; + n = select (fd + 1, &set, 0, 0, &tv); + if (n <= 0) + break; + } + return tot; +} + +void +itsyTsRead (KdPointerInfo *pi, int tsPort) +{ + ts_event event; + long buf[3]; + int n; + long pressure; + long x, y; + unsigned long flags; + unsigned long buttons; + + n = itsyTsReadBytes (tsPort, (char *) &event, + sizeof (event), sizeof (event)); + if (n == sizeof (event)) + { + if (event.pressure) + { + flags = KD_BUTTON_1; + x = event.point.x; + y = event.point.y; + } + else + { + flags = KD_MOUSE_DELTA; + x = 0; + y = 0; + } + KdEnqueuePointerEvent (pi, flags, x, y, 0); + } +} + +#if 0 +#define ITSY_DEBUG_LOW 1 + +// +// Touch screen parameters are stored +// in the flash. This code is taken from 'wm1'. +// +void itsySetTouchCalibration (int mou_filedsc, + int xs, int xt, int ys, int yt, int xys) +{ + int k, ibuf[10]; + + ibuf[0] = xs; + ibuf[1] = xt; + ibuf[2] = ys; + ibuf[3] = yt; + ibuf[4] = xys; + if ((k=ioctl(mou_filedsc, TS_SET_CALM, ibuf)) != 0) { + fprintf(stderr, "ERROR: ioctl TS_SET_CALM returns %d\n", k); + } +} + + +int itsyReadFlashBlock(int location, signed char *data, int dbytes) +{ + int offset, bytes; + int flashfd; + + flashfd = open("/dev/flash1", O_RDONLY); + if (flashfd < 0) return(0); + + offset = lseek(flashfd, location, SEEK_SET); + if (offset != location) { + close(flashfd); + return(0); + } + + bytes = read(flashfd, data, dbytes); + if (bytes != dbytes) { + close(flashfd); + return(0); + } + + close(flashfd); + return(1); +} + +/**********************************************************************/ +#define RAMSIZE (0x400000) +#define MONITOR_BLOCKSIZE (32) +/**********************************************************************/ + +/* code for storing calibration into flash */ + +#define CALIBRATE_BLOCKSIZE (32) +#define CALIBRATE_OFFSET (RAMSIZE-MONITOR_BLOCKSIZE-CALIBRATE_BLOCKSIZE) +#define CALIBRATE_MAGIC_NUM (0x0babedee) + + +static int check_if_calibrated_and_set(int mou_filedsc) +{ + signed char cal_data[CALIBRATE_BLOCKSIZE]; + int *iptr; + + if (itsyReadFlashBlock(CALIBRATE_OFFSET, + cal_data, CALIBRATE_BLOCKSIZE) == 0) { + if ( ITSY_DEBUG_LOW ) { + fprintf(stderr,"unable to read calibration data for touch screen\n"); + } + return(0); + } + + iptr = (int *) cal_data; + if (iptr[0] == CALIBRATE_MAGIC_NUM) { + if ( ITSY_DEBUG_LOW ) { + fprintf(stderr,"Calibrating touch screen using %d, %d, %d, %d, %d\n", + iptr[1], iptr[2], iptr[3], iptr[4], iptr[5]); + } + itsySetTouchCalibration(mou_filedsc, iptr[1], iptr[2], iptr[3], iptr[4], iptr[5]); + return(1); + } + else { + if ( ITSY_DEBUG_LOW ) { + fprintf(stderr,"Couldn't calibrate screen\n"); + } + return(0); + } +} +#endif + +int +itsyTsInit (void) +{ + int tsPort; + + tsPort = open ("/dev/ts", 0); + fprintf (stderr, "tsPort %d\n", tsPort); +#if 0 + if (tsPort >= 0) + check_if_calibrated_and_set (tsPort); +#endif + return tsPort; +} + +void +itsyTsFini (int tsPort) +{ + if (tsPort >= 0) + close (tsPort); +} + +KdPointerDriver itsyTsMouseDriver = { + "itsyts", + itsyTsInit, + itsyTsRead, + itsyTsFini +}; + --- xorg-server-1.4.99.906.orig/hw/kdrive/itsy/itsy.h +++ xorg-server-1.4.99.906/hw/kdrive/itsy/itsy.h @@ -0,0 +1,39 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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. + */ + +#include "kdrive.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#define FB_HEIGHT 200 +#define FB_WIDTH 320 +#define FB_DEPTH 4 +#define FB_PALETTE_SIZE 16 + +extern KdMouseFuncs itsyTsMouseFuncs; +extern KdKeyboardFuncs itsyKeyboardFuncs; --- xorg-server-1.4.99.906.orig/hw/kdrive/vesa/Xvesa.man +++ xorg-server-1.4.99.906/hw/kdrive/vesa/Xvesa.man @@ -0,0 +1,105 @@ +.\" $RCSId: xc/programs/Xserver/hw/kdrive/vesa/Xvesa.man,v 1.5 2001/01/24 00:06:10 dawes Exp $ +.TH Xvesa 1 __vendorversion__ +.SH NAME +Xvesa \- VESA Bios Extensions tiny X server +.SH SYNOPSIS +.B Xvesa +.RI [ :display ] +.RI [ option ...] +.SH DESCRIPTION +.B Xvesa +is a generic X server for Linux on the x86 platform. +.B Xvesa +doesn't know about any particular hardware, and sets the video mode by +running the video BIOS in VM86 mode. +.B Xvesa +can use both standard VGA BIOS modes and any modes advertised by a +VESA BIOS if available. + +.B Xvesa +runs untrusted code with full privileges, and is therefore a fairly +insecure X server. +.B Run at your own risk. +.SH OPTIONS +In addition to the normal KDrive server's options (see Xkdrive(1)), +.B Xvesa +accepts the following command line switches: +.TP 8 +.B -mode \fIn\fB +specifies the VESA video mode to use. If mode +.I n +is not supported by your BIOS and hardware, +.B Xvesa +will fail, hang your system, damage your hardware, or cause a global +thermonuclear war; you are on your own. This option overrides any +.B -screen +options. +.TP 8 +.B -listmodes +list all supported video modes. If +.B -force +was specified before +.BR -listmodes , +lists all the modes that your BIOS claims to support, even those that +the +.B Xvesa +server won't be able to use. +.TP 8 +.B -force +disable some sanity checks and use the specified mode even if the +BIOS claims not to support it. +.TP 8 +.B -shadow +use a shadow framebuffer even if it is not strictly necessary. This +may dramatically improve performance on some hardware. +.TP 8 +.B -nolinear +don't use a linear framebuffer even if one is available. You don't +want to use this option. +.TP 8 +.B -swaprgb +pass RGB values in the order that works on broken BIOSes. Use this if +the colours are wrong in PseudoColor and 16 colour modes. +.TP 8 +.B -map-holes +use a contiguous (hole-less) memory map. This fixes a segmentation +violation with some rare BIOSes that violate the VESA specification, +but may cause slightly higher memory usage on systems that overcommit +memory. +.TP 8 +.B -force-text +ignore saved video mode and switch back to regular 25x80 text mode +on server exit or VT switch. +.TP 8 +.B -verbose +emit diagnostic messages during BIOS initialization and teardown. +.SH KEYBOARD +Multiple key presses recognized directly by +.B Xvesa +are: +.TP 8 +.B Ctrl+Alt+Backspace +Immediately kill the server. +.TP 8 +.B Ctrl+Alt+F1...F12 +Switch to virtual console 1 through 12. +.SH BUGS +.B Xvesa +opens all IO ports and runs your VESA BIOS, which may be assumed to be +buggy. Allowing your users to run +.B Xvesa +is probably a security hole. + +.B Xvesa +records the current BIOS mode when it starts and restores that mode on +termination; if the video card has been reprogrammed by another application, +the display will almost certainly be trashed. The alternative of saving and +restoring the complete video card state has proven unreliable on most video +cards. +.SH SEE ALSO +X(__miscmansuffix__), Xserver(1), Xkdrive(1), xdm(1), xinit(1). +.SH AUTHORS +The VESA driver was written by Juliusz Chroboczek who didn't realise +what he was doing until it was too late. Keith Packard then added +support for standard VGA BIOS modes and is especially proud of 320x200 +16 colour mode. --- xorg-server-1.4.99.906.orig/hw/kdrive/ati/ati_drawtmp.h +++ xorg-server-1.4.99.906/hw/kdrive/ati/ati_drawtmp.h @@ -0,0 +1,237 @@ +/* + * Copyright © 2003 Eric Anholt + * + * 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 Eric Anholt not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Eric Anholt makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ERIC ANHOLT 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 USE_DMA +#define TAG(x) x##DMA +#define LOCALS RING_LOCALS; \ + (void)atic +#define BEGIN(x) BEGIN_RING(x * 2) +#define OUT_REG(reg, val) OUT_RING_REG(reg, val) +#define END() ADVANCE_RING() +#else +#define TAG(x) x##MMIO +#define LOCALS char *mmio = atic->reg_base; \ + (void)atis +#define BEGIN(x) ATIWaitAvailMMIO(x) +#define OUT_REG(reg, val) MMIO_OUT32((mmio), (reg), (val)) +#define END() +#endif + +static Bool +TAG(ATISetup)(PixmapPtr pDst, PixmapPtr pSrc) +{ + KdScreenPriv(pDst->drawable.pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo(pScreenPriv); + int dst_offset, dst_pitch; + int bpp = pDst->drawable.bitsPerPixel; + LOCALS; + + accel_atis = atis; + + dst_pitch = pDst->devKind; + dst_offset = ((CARD8 *)pDst->devPrivate.ptr - + pScreenPriv->screen->memory_base); + if ((dst_pitch & (atis->kaa.offscreenPitch - 1)) != 0) + ATI_FALLBACK(("Bad dst pitch 0x%x\n", dst_pitch)); + if ((dst_offset & (atis->kaa.offscreenByteAlign - 1)) != 0) + ATI_FALLBACK(("Bad dst offset 0x%x\n", dst_offset)); + + if (pSrc != NULL) { + src_pitch = pSrc->devKind; + src_offset = ((CARD8 *)pSrc->devPrivate.ptr - + pScreenPriv->screen->memory_base); + if ((src_pitch & (atis->kaa.offscreenPitch - 1)) != 0) + ATI_FALLBACK(("Bad src pitch 0x%x\n", src_pitch)); + if ((src_offset & (atis->kaa.offscreenByteAlign - 1)) != 0) + ATI_FALLBACK(("Bad src offset 0x%x\n", src_offset)); + } + +#ifdef USE_DMA + if (atic->is_radeon && !atic->is_r200) + RadeonSwitchTo2D(); +#endif + BEGIN((pSrc != NULL) ? 3 : 2); + if (atic->is_radeon) { + OUT_REG(RADEON_REG_DST_PITCH_OFFSET, + ((dst_pitch >> 6) << 22) | (dst_offset >> 10)); + if (pSrc != NULL) { + OUT_REG(RADEON_REG_SRC_PITCH_OFFSET, + ((src_pitch >> 6) << 22) | (src_offset >> 10)); + } + } else { + if (is_24bpp) { + dst_pitch *= 3; + src_pitch *= 3; + } + /* R128 pitch is in units of 8 pixels, offset in 32 bytes */ + OUT_REG(RADEON_REG_DST_PITCH_OFFSET, + ((dst_pitch/bpp) << 21) | (dst_offset >> 5)); + if (pSrc != NULL) { + OUT_REG(RADEON_REG_SRC_PITCH_OFFSET, + ((src_pitch/bpp) << 21) | (src_offset >> 5)); + } + } + OUT_REG(RADEON_REG_DEFAULT_SC_BOTTOM_RIGHT, + (RADEON_DEFAULT_SC_RIGHT_MAX | RADEON_DEFAULT_SC_BOTTOM_MAX)); + END(); + + return TRUE; +} + +static Bool +TAG(ATIPrepareSolid)(PixmapPtr pPixmap, int alu, Pixel pm, Pixel fg) +{ + KdScreenPriv(pPixmap->drawable.pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo(pScreenPriv); + CARD32 datatype; + LOCALS; + + if (is_24bpp) { + /* Solid fills in fake-24bpp mode only work if the pixel color + * and planemask are all the same byte. + */ + if ((fg & 0xffffff) != (((fg & 0xff) << 16) | ((fg >> 8) & + 0xffff))) + ATI_FALLBACK(("Can't do solid color %d in 24bpp\n")); + if ((pm & 0xffffff) != (((pm & 0xff) << 16) | ((pm >> 8) & + 0xffff))) + ATI_FALLBACK(("Can't do planemask %d in 24bpp\n")); + } + + if (!ATIGetDatatypeBpp(pPixmap->drawable.bitsPerPixel, &datatype)) + return FALSE; + if (!TAG(ATISetup)(pPixmap, NULL)) + return FALSE; + + BEGIN(4); + OUT_REG(RADEON_REG_DP_GUI_MASTER_CNTL, + (datatype << 8) | + RADEON_GMC_CLR_CMP_CNTL_DIS | + RADEON_GMC_AUX_CLIP_DIS | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_SRC_DATATYPE_COLOR | + (ATISolidRop[alu] << 16)); + OUT_REG(RADEON_REG_DP_BRUSH_FRGD_CLR, fg); + OUT_REG(RADEON_REG_DP_WRITE_MASK, pm); + OUT_REG(RADEON_REG_DP_CNTL, RADEON_DST_X_LEFT_TO_RIGHT | + RADEON_DST_Y_TOP_TO_BOTTOM); + END(); + + return TRUE; +} + +static void +TAG(ATISolid)(int x1, int y1, int x2, int y2) +{ + ATIScreenInfo *atis = accel_atis; + ATICardInfo *atic = atis->atic; + LOCALS; + + if (is_24bpp) { + x1 *= 3; + x2 *= 3; + } + BEGIN(2); + OUT_REG(RADEON_REG_DST_Y_X, (y1 << 16) | x1); + OUT_REG(RADEON_REG_DST_WIDTH_HEIGHT, ((x2 - x1) << 16) | (y2 - y1)); + END(); +} + +static Bool +TAG(ATIPrepareCopy)(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm) +{ + KdScreenPriv(pDst->drawable.pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo(pScreenPriv); + CARD32 datatype; + LOCALS; + + copydx = dx; + copydy = dy; + + if (is_24bpp && ((pm & 0xffffff) != (((pm & 0xff) << 16) | ((pm >> 8) & + 0xffff)))) + ATI_FALLBACK(("Can't do planemask %d in 24bpp\n")); + + if (!ATIGetDatatypeBpp(pDst->drawable.bitsPerPixel, &datatype)) + return FALSE; + if (!TAG(ATISetup)(pDst, pSrc)) + return FALSE; + + BEGIN(3); + OUT_REG(RADEON_REG_DP_GUI_MASTER_CNTL, + (datatype << 8) | + RADEON_GMC_CLR_CMP_CNTL_DIS | + RADEON_GMC_AUX_CLIP_DIS | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_SRC_DATATYPE_COLOR | + (ATIBltRop[alu] << 16) | + RADEON_GMC_SRC_PITCH_OFFSET_CNTL | + RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_DP_SRC_SOURCE_MEMORY); + OUT_REG(RADEON_REG_DP_WRITE_MASK, pm); + OUT_REG(RADEON_REG_DP_CNTL, + (dx >= 0 ? RADEON_DST_X_LEFT_TO_RIGHT : 0) | + (dy >= 0 ? RADEON_DST_Y_TOP_TO_BOTTOM : 0)); + END(); + + return TRUE; +} + +static void +TAG(ATICopy)(int srcX, int srcY, int dstX, int dstY, int w, int h) +{ + ATIScreenInfo *atis = accel_atis; + ATICardInfo *atic = atis->atic; + LOCALS; + + if (is_24bpp) { + srcX *= 3; + dstX *= 3; + w *= 3; + } + + if (copydx < 0) { + srcX += w - 1; + dstX += w - 1; + } + + if (copydy < 0) { + srcY += h - 1; + dstY += h - 1; + } + + BEGIN(3); + OUT_REG(RADEON_REG_SRC_Y_X, (srcY << 16) | srcX); + OUT_REG(RADEON_REG_DST_Y_X, (dstY << 16) | dstX); + OUT_REG(RADEON_REG_DST_HEIGHT_WIDTH, (h << 16) | w); + END(); +} + +#undef TAG +#undef LOCALS +#undef BEGIN +#undef OUT_REG +#undef END --- xorg-server-1.4.99.906.orig/hw/kdrive/ati/ati_dripriv.h +++ xorg-server-1.4.99.906/hw/kdrive/ati/ati_dripriv.h @@ -0,0 +1,57 @@ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, + * Precision Insight, Inc., Cedar Park, Texas, and + * VA Linux Systems Inc., Fremont, California. + * + * 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 on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS 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. + */ + +/* + * Authors: + * Rickard E. Faith + * Kevin E. Martin + * + */ + +#ifndef _ATI_DRIPRIV_H_ +#define _ATI_DRIPRIV_H_ + +#ifdef GLXEXT +#include "GL/glxint.h" + +extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, + void **configprivs); +#endif + +typedef struct { + /* Nothing here yet */ + int dummy; +} ATIConfigPrivRec, *ATIConfigPrivPtr; + +typedef struct { + /* Nothing here yet */ + int dummy; +} ATIDRIContextRec, *ATIDRIContextPtr; + +#endif --- xorg-server-1.4.99.906.orig/hw/kdrive/ati/r128_blendtmp.h +++ xorg-server-1.4.99.906/hw/kdrive/ati/r128_blendtmp.h @@ -0,0 +1,134 @@ +/* + * Copyright © 2003 Eric Anholt, Anders Carlsson + * + * 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 Eric Anholt not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Eric Anholt makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ERIC ANHOLT 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 USE_DMA +#define TAG(x) x##DMA +#define LOCALS RING_LOCALS; \ + (void)atic +#define BEGIN(x) BEGIN_RING(x * 2) +#define OUT_REG(reg, val) OUT_RING_REG(reg, val) +#define END() ADVANCE_RING() +#else +#define TAG(x) x##MMIO +#define LOCALS char *mmio = atic->reg_base +#define BEGIN(x) ATIWaitAvailMMIO(x) +#define OUT_REG(reg, val) MMIO_OUT32(mmio, (reg), (val)) +#define END() +#endif + +static Bool +TAG(R128PrepareBlend)(int op, PicturePtr pSrcPicture, PicturePtr pDstPicture, + PixmapPtr pSrc, PixmapPtr pDst) +{ + KdScreenPriv(pDst->drawable.pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo(pScreenPriv); + CARD32 dstDatatype, srcDatatype; + LOCALS; + + accel_atis = atis; + + if (!TAG(ATISetup)(pDst, pSrc)) + return FALSE; + + src_bpp = pSrc->drawable.bitsPerPixel; + is_repeat = pSrcPicture->repeat; + + if (op >= sizeof(R128BlendOp)/sizeof(R128BlendOp[0])) + ATI_FALLBACK(("Unsupported op 0x%x\n", op)); + if (pSrcPicture->repeat && (pSrc->drawable.width != 1 || + pSrc->drawable.height != 1)) + ATI_FALLBACK(("repeat unsupported\n")); + if (pSrcPicture->transform != NULL) + ATI_FALLBACK(("transform unsupported\n")); + if (!R128GetDatatypePict(pDstPicture->format, &dstDatatype)) + ATI_FALLBACK(("Unsupported dest format 0x%x\n", + pDstPicture->format)); + if (!R128GetDatatypePict(pSrcPicture->format, &srcDatatype)) + ATI_FALLBACK(("Unsupported src format 0x%x\n", + pSrcPicture->format)); + + BEGIN(11); + OUT_REG(RADEON_REG_DP_GUI_MASTER_CNTL, + (dstDatatype << 8) | + RADEON_GMC_SRC_DATATYPE_COLOR | + RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_CLR_CMP_CNTL_DIS | + RADEON_GMC_AUX_CLIP_DIS | + (ATIBltRop[3] << 16) | + RADEON_GMC_3D_FCN_EN); + OUT_REG(R128_REG_TEX_CNTL_C, R128_TEX_ALPHA_EN | R128_TEX_CACHE_FLUSH); + OUT_REG(R128_REG_PRIM_TEXTURE_COMBINE_CNTL_C, 0); + OUT_REG(R128_REG_SCALE_3D_CNTL, + R128_SCALE_3D_SCALE | + R128BlendOp[op] | + R128_TEX_MAP_ALPHA_IN_TEXTURE); + OUT_REG(R128_REG_SCALE_3D_DATATYPE, srcDatatype); + OUT_REG(R128_REG_SCALE_PITCH, src_pitch / src_bpp); + /* 4.16 fixed point scaling factor? */ + if (is_repeat) { + OUT_REG(R128_REG_SCALE_X_INC, 0); + OUT_REG(R128_REG_SCALE_Y_INC, 0); + } else { + OUT_REG(R128_REG_SCALE_X_INC, 65536); + OUT_REG(R128_REG_SCALE_Y_INC, 65536); + } + OUT_REG(R128_REG_SCALE_HACC, 0x00000000); + OUT_REG(R128_REG_SCALE_VACC, 0x00000000); + OUT_REG(RADEON_REG_DP_CNTL, + RADEON_DST_X_LEFT_TO_RIGHT | RADEON_DST_Y_TOP_TO_BOTTOM ); + END(); + + return TRUE; +} + +static void +TAG(R128Blend)(int srcX, int srcY, int dstX, int dstY, int width, int height) +{ + ATIScreenInfo *atis = accel_atis; + ATICardInfo *atic = atis->atic; + LOCALS; + + if (is_repeat) { + srcX = 0; + srcY = 0; + } + + BEGIN(4); + OUT_REG(R128_REG_SCALE_OFFSET_0, src_offset + srcY * src_pitch + srcX * + (src_bpp >> 3)); + OUT_REG(R128_REG_SCALE_SRC_HEIGHT_WIDTH, (height << 16) | width); + OUT_REG(R128_REG_SCALE_DST_X_Y, (dstX << 16) | dstY); + OUT_REG(R128_REG_SCALE_DST_HEIGHT_WIDTH, (height << 16) | width); + END(); +} + +static void +TAG(R128DoneBlend)(void) +{ +} + +#undef TAG +#undef LOCALS +#undef BEGIN +#undef OUT_REG +#undef END --- xorg-server-1.4.99.906.orig/hw/kdrive/ati/ati_sarea.h +++ xorg-server-1.4.99.906/hw/kdrive/ati/ati_sarea.h @@ -0,0 +1,38 @@ +/* + * Copyright © 2003 Eric Anholt + * + * 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 Eric Anholt not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Eric Anholt makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ERIC ANHOLT 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. + */ + +#ifndef _ATI_SAREA_H_ +#define _ATI_SAREA_H_ + +/* There are 2 heaps (local/AGP). Each region within a heap is a + * minimum of 64k, and there are at most 64 of them per heap. + */ +#define ATI_CARD_HEAP 0 +#define ATI_GART_HEAP 1 +#define ATI_NR_TEX_HEAPS 2 +#define ATI_NR_TEX_REGIONS 64 +#define ATI_LOG_TEX_GRANULARITY 16 + +#include "r128_sarea.h" +#include "radeon_sarea.h" + +#endif /* _ATI_SAREA_H_ */ --- xorg-server-1.4.99.906.orig/hw/kdrive/ati/ati_dri.h +++ xorg-server-1.4.99.906/hw/kdrive/ati/ati_dri.h @@ -0,0 +1,97 @@ +/* + * Copyright © 2003 Eric Anholt + * + * 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 Eric Anholt not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Eric Anholt makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ERIC ANHOLT 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. + */ + +#ifndef _ATI_DRI_H_ +#define _ATI_DRI_H_ + +typedef struct { + /* DRI screen private data */ + int deviceID; /* PCI device ID */ + int width; /* Width in pixels of display */ + int height; /* Height in scanlines of display */ + int depth; /* Depth of display (8, 15, 16, 24) */ + int bpp; /* Bit depth of display (8, 16, 24, 32) */ + + int IsPCI; /* Current card is a PCI card */ + int AGPMode; + + int frontOffset; /* Start of front buffer */ + int frontPitch; + int backOffset; /* Start of shared back buffer */ + int backPitch; + int depthOffset; /* Start of shared depth buffer */ + int depthPitch; + int spanOffset; /* Start of scratch spanline */ + int textureOffset; /* Start of texture data in frame buffer */ + int textureSize; + int log2TexGran; + + /* MMIO register data */ + drmHandle registerHandle; + drmSize registerSize; + + /* CCE AGP Texture data */ + drmHandle gartTexHandle; + drmSize gartTexMapSize; + int log2AGPTexGran; + int gartTexOffset; + unsigned int sarea_priv_offset; +} R128DRIRec, *R128DRIPtr; + +typedef struct { + /* DRI screen private data */ + int deviceID; /* PCI device ID */ + int width; /* Width in pixels of display */ + int height; /* Height in scanlines of display */ + int depth; /* Depth of display (8, 15, 16, 24) */ + int bpp; /* Bit depth of display (8, 16, 24, 32) */ + + int IsPCI; /* Current card is a PCI card */ + int AGPMode; + + int frontOffset; /* Start of front buffer */ + int frontPitch; + int backOffset; /* Start of shared back buffer */ + int backPitch; + int depthOffset; /* Start of shared depth buffer */ + int depthPitch; + int textureOffset; /* Start of texture data in frame buffer */ + int textureSize; + int log2TexGran; + + /* MMIO register data */ + drmHandle registerHandle; + drmSize registerSize; + + /* CP in-memory status information */ + drmHandle statusHandle; + drmSize statusSize; + + /* CP GART Texture data */ + drmHandle gartTexHandle; + drmSize gartTexMapSize; + int log2GARTTexGran; + int gartTexOffset; + unsigned int sarea_priv_offset; +} RADEONDRIRec, *RADEONDRIPtr; + +#endif /* _ATI_DRI_H_ */ --- xorg-server-1.4.99.906.orig/hw/kdrive/ati/r128_sarea.h +++ xorg-server-1.4.99.906/hw/kdrive/ati/r128_sarea.h @@ -0,0 +1,185 @@ +/* + * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, + * Precision Insight, Inc., Cedar Park, Texas, and + * VA Linux Systems Inc., Fremont, California. + * + * 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 on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX + * SYSTEMS AND/OR THEIR SUPPLIERS 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. + */ + +/* + * Authors: + * Kevin E. Martin + * Gareth Hughes + * + */ + +#ifndef _R128_SAREA_H_ +#define _R128_SAREA_H_ + +/* WARNING: If you change any of these defines, make sure to change the + * defines in the kernel file (r128_drm.h) + */ +#ifndef __R128_SAREA_DEFINES__ +#define __R128_SAREA_DEFINES__ + +/* What needs to be changed for the current vertex buffer? + */ +#define R128_UPLOAD_CONTEXT 0x001 +#define R128_UPLOAD_SETUP 0x002 +#define R128_UPLOAD_TEX0 0x004 +#define R128_UPLOAD_TEX1 0x008 +#define R128_UPLOAD_TEX0IMAGES 0x010 +#define R128_UPLOAD_TEX1IMAGES 0x020 +#define R128_UPLOAD_CORE 0x040 +#define R128_UPLOAD_MASKS 0x080 +#define R128_UPLOAD_WINDOW 0x100 +#define R128_UPLOAD_CLIPRECTS 0x200 /* handled client-side */ +#define R128_REQUIRE_QUIESCENCE 0x400 +#define R128_UPLOAD_ALL 0x7ff + +#define R128_FRONT 0x1 +#define R128_BACK 0x2 +#define R128_DEPTH 0x4 + +/* Primitive types + */ +#define R128_POINTS 0x1 +#define R128_LINES 0x2 +#define R128_LINE_STRIP 0x3 +#define R128_TRIANGLES 0x4 +#define R128_TRIANGLE_FAN 0x5 +#define R128_TRIANGLE_STRIP 0x6 + +/* Vertex/indirect buffer size + */ +#define R128_BUFFER_SIZE 16384 + +/* Byte offsets for indirect buffer data + */ +#define R128_INDEX_PRIM_OFFSET 20 +#define R128_HOSTDATA_BLIT_OFFSET 32 + +/* Keep these small for testing + */ +#define R128_NR_SAREA_CLIPRECTS 12 + +#define R128_NR_CONTEXT_REGS 12 + +#define R128_MAX_TEXTURE_LEVELS 11 +#define R128_MAX_TEXTURE_UNITS 2 + +#endif /* __R128_SAREA_DEFINES__ */ + +typedef struct { + /* Context state - can be written in one large chunk */ + unsigned int dst_pitch_offset_c; + unsigned int dp_gui_master_cntl_c; + unsigned int sc_top_left_c; + unsigned int sc_bottom_right_c; + unsigned int z_offset_c; + unsigned int z_pitch_c; + unsigned int z_sten_cntl_c; + unsigned int tex_cntl_c; + unsigned int misc_3d_state_cntl_reg; + unsigned int texture_clr_cmp_clr_c; + unsigned int texture_clr_cmp_msk_c; + unsigned int fog_color_c; + + /* Texture state */ + unsigned int tex_size_pitch_c; + unsigned int constant_color_c; + + /* Setup state */ + unsigned int pm4_vc_fpu_setup; + unsigned int setup_cntl; + + /* Mask state */ + unsigned int dp_write_mask; + unsigned int sten_ref_mask_c; + unsigned int plane_3d_mask_c; + + /* Window state */ + unsigned int window_xy_offset; + + /* Core state */ + unsigned int scale_3d_cntl; +} r128_context_regs_t; + +/* Setup registers for each texture unit + */ +typedef struct { + unsigned int tex_cntl; + unsigned int tex_combine_cntl; + unsigned int tex_size_pitch; + unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS]; + unsigned int tex_border_color; +} r128_texture_regs_t; + +typedef struct { + /* The channel for communication of state information to the kernel + * on firing a vertex buffer. + */ + r128_context_regs_t ContextState; + r128_texture_regs_t TexState[R128_MAX_TEXTURE_UNITS]; + unsigned int dirty; + unsigned int vertsize; + unsigned int vc_format; + +#ifdef XF86DRI + /* The current cliprects, or a subset thereof. + */ + XF86DRIClipRectRec boxes[R128_NR_SAREA_CLIPRECTS]; + unsigned int nbox; +#endif + + /* Counters for throttling of rendering clients. + */ + unsigned int last_frame; + unsigned int last_dispatch; + + /* Maintain an LRU of contiguous regions of texture space. If you + * think you own a region of texture memory, and it has an age + * different to the one you set, then you are mistaken and it has + * been stolen by another client. If global texAge hasn't changed, + * there is no need to walk the list. + * + * These regions can be used as a proxy for the fine-grained texture + * information of other clients - by maintaining them in the same + * lru which is used to age their own textures, clients have an + * approximate lru for the whole of global texture space, and can + * make informed decisions as to which areas to kick out. There is + * no need to choose whether to kick out your own texture or someone + * else's - simply eject them all in LRU order. + */ + /* Last elt is sentinal */ + drmTextureRegion texList[ATI_NR_TEX_HEAPS][ATI_NR_TEX_REGIONS+1]; + /* last time texture was uploaded */ + unsigned int texAge[ATI_NR_TEX_HEAPS]; + + int ctxOwner; /* last context to upload state */ + int pfAllowPageFlip; /* set by the 2d driver, read by the client */ + int pfCurrentPage; /* set by kernel, read by others */ +} R128SAREAPriv, *R128SAREAPrivPtr; + +#endif --- xorg-server-1.4.99.906.orig/hw/kdrive/ati/ati_dri.c +++ xorg-server-1.4.99.906/hw/kdrive/ati/ati_dri.c @@ -0,0 +1,1138 @@ +/* + * Copyright © 2003 Eric Anholt + * + * 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 Eric Anholt not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Eric Anholt makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ERIC ANHOLT 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. + */ + +#include + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "ati.h" +#include "ati_reg.h" +#include "ati_dma.h" +#include "ati_dri.h" +#include "ati_dripriv.h" +#include "sarea.h" +#include "ati_sarea.h" +#include "ati_draw.h" +#include "r128_common.h" +#include "radeon_common.h" +#include "kaa.h" + +/* ?? HACK - for now, put this here... */ +/* ?? Alpha - this may need to be a variable to handle UP1x00 vs TITAN */ +#if defined(__alpha__) +# define DRM_PAGE_SIZE 8192 +#elif defined(__ia64__) +# define DRM_PAGE_SIZE getpagesize() +#else +# define DRM_PAGE_SIZE 4096 +#endif + +#ifdef GLXEXT +/* Initialize the visual configs that are supported by the hardware. + * These are combined with the visual configs that the indirect + * rendering core supports, and the intersection is exported to the + * client. + */ +static Bool ATIInitVisualConfigs(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + int numConfigs = 0; + __GLXvisualConfig *pConfigs = NULL; + ATIConfigPrivPtr pATIConfigs = NULL; + ATIConfigPrivPtr *pATIConfigPtrs = NULL; + int i, accum, stencil, db, use_db; + int depth = pScreenPriv->screen->fb[0].depth; + int bpp = pScreenPriv->screen->fb[0].bitsPerPixel; + + if (depth != 16 && (depth != 24 || bpp != 32)) + ErrorF("DRI GLX unsupported at %d/%d depth/bpp\n", depth, bpp); + + if (atis->depthOffset != 0) + use_db = 1; + else + use_db = 0; + + numConfigs = 4; + if (use_db) + numConfigs *= 2; + + pConfigs = xcalloc(sizeof(__GLXvisualConfig), numConfigs); + pATIConfigs = xcalloc(sizeof(ATIConfigPrivRec), numConfigs); + pATIConfigPtrs = xcalloc(sizeof(ATIConfigPrivPtr), numConfigs); + if (pConfigs == NULL || pATIConfigs == NULL || pATIConfigPtrs == NULL) { + xfree(pConfigs); + xfree(pATIConfigs); + xfree(pATIConfigPtrs); + return FALSE; + } + + i = 0; + for (db = 0; db <= use_db; db++) { + for (accum = 0; accum <= 1; accum++) { + for (stencil = 0; stencil <= 1; stencil++) { + pATIConfigPtrs[i] = &pATIConfigs[i]; + + pConfigs[i].vid = (VisualID)(-1); + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + if (depth == 16) { + pConfigs[i].redSize = 5; + pConfigs[i].greenSize = 6; + pConfigs[i].blueSize = 5; + pConfigs[i].alphaSize = 0; + pConfigs[i].redMask = 0x0000F800; + pConfigs[i].greenMask = 0x000007E0; + pConfigs[i].blueMask = 0x0000001F; + pConfigs[i].alphaMask = 0x00000000; + } else { + pConfigs[i].redSize = 8; + pConfigs[i].greenSize = 8; + pConfigs[i].blueSize = 8; + pConfigs[i].alphaSize = 8; + pConfigs[i].redMask = 0x00FF0000; + pConfigs[i].greenMask = 0x0000FF00; + pConfigs[i].blueMask = 0x000000FF; + pConfigs[i].alphaMask = 0xFF000000; + } + if (accum) { /* Simulated in software */ + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + if (depth == 16) + pConfigs[i].accumAlphaSize = 0; + else + pConfigs[i].accumAlphaSize = 16; + } else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + if (db) + pConfigs[i].doubleBuffer = TRUE; + else + pConfigs[i].doubleBuffer = FALSE; + pConfigs[i].stereo = FALSE; + if (depth == 16) { + pConfigs[i].bufferSize = 16; + pConfigs[i].depthSize = 16; + if (stencil) + pConfigs[i].stencilSize = 8; + else + pConfigs[i].stencilSize = 0; + } else { + pConfigs[i].bufferSize = 32; + if (stencil) { + pConfigs[i].depthSize = 24; + pConfigs[i].stencilSize = 8; + } else { + pConfigs[i].depthSize = 24; + pConfigs[i].stencilSize = 0; + } + } + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + if (accum) { + pConfigs[i].visualRating = GLX_SLOW_CONFIG; + } else { + pConfigs[i].visualRating = GLX_NONE; + } + pConfigs[i].transparentPixel = GLX_NONE; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + } + } + + atis->numVisualConfigs = numConfigs; + atis->pVisualConfigs = pConfigs; + atis->pVisualConfigsPriv = pATIConfigs; + GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pATIConfigPtrs); + return TRUE; +} +#endif /* GLXEXT */ + +static void +ATIDRIInitGARTValues(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + int s, l; + + atis->gartOffset = 0; + + /* Initialize the ring buffer data */ + atis->ringStart = atis->gartOffset; + atis->ringMapSize = atis->ringSize * 1024 * 1024 + DRM_PAGE_SIZE; + + atis->ringReadOffset = atis->ringStart + atis->ringMapSize; + atis->ringReadMapSize = DRM_PAGE_SIZE; + + /* Reserve space for vertex/indirect buffers */ + atis->bufStart = atis->ringReadOffset + atis->ringReadMapSize; + atis->bufMapSize = atis->bufSize * 1024 * 1024; + + /* Reserve the rest for GART textures */ + atis->gartTexStart = atis->bufStart + atis->bufMapSize; + s = (atis->gartSize * 1024 * 1024 - atis->gartTexStart); + l = ATILog2((s-1) / ATI_NR_TEX_REGIONS); + if (l < ATI_LOG_TEX_GRANULARITY) l = ATI_LOG_TEX_GRANULARITY; + atis->gartTexMapSize = (s >> l) << l; + atis->log2GARTTexGran = l; +} + +static int +ATIDRIAddAndMap(int fd, drmHandle offset, drmSize size, + drmMapType type, drmMapFlags flags, drmHandlePtr handle, + drmAddressPtr address, char *desc) +{ + char *name; + + name = (type == DRM_AGP) ? "agp" : "pci"; + + if (drmAddMap(fd, offset, size, type, flags, handle) < 0) { + ErrorF("[%s] Could not add %s mapping\n", name, desc); + return FALSE; + } + ErrorF("[%s] %s handle = 0x%08lx\n", name, desc, *handle); + + if (drmMap(fd, *handle, size, address) < 0) { + ErrorF("[%s] Could not map %s\n", name, desc); + return FALSE; + } + ErrorF("[%s] %s mapped at 0x%08lx\n", name, desc, *address); + + return TRUE; +} + +/* Initialize the AGP state. Request memory for use in AGP space, and + initialize the Rage 128 registers to point to that memory. */ +static Bool +ATIDRIAgpInit(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo(pScreenPriv); + unsigned char *mmio = atic->reg_base; + unsigned long mode; + int ret; + CARD32 cntl, chunk; + + if (drmAgpAcquire(atic->drmFd) < 0) { + ErrorF("[agp] AGP not available\n"); + return FALSE; + } + + ATIDRIInitGARTValues(pScreen); + + mode = drmAgpGetMode(atic->drmFd); + if (atic->is_radeon) { + mode &= ~RADEON_AGP_MODE_MASK; + mode |= RADEON_AGP_1X_MODE; + } else { + mode &= ~R128_AGP_MODE_MASK; + mode |= R128_AGP_1X_MODE; + } + + if (drmAgpEnable(atic->drmFd, mode) < 0) { + ErrorF("[agp] AGP not enabled\n"); + drmAgpRelease(atic->drmFd); + return FALSE; + } + ErrorF("[agp] Mode 0x%08x selected\n", drmAgpGetMode(atic->drmFd)); + + if ((ret = drmAgpAlloc(atic->drmFd, atis->gartSize * 1024 * 1024, 0, + NULL, &atis->agpMemHandle)) < 0) { + ErrorF("[agp] Out of memory (%d)\n", ret); + drmAgpRelease(atic->drmFd); + return FALSE; + } + ErrorF("[agp] %d kB allocated with handle 0x%08lx\n", + atis->gartSize * 1024, (long)atis->agpMemHandle); + + if (drmAgpBind(atic->drmFd, atis->agpMemHandle, atis->gartOffset) < 0) { + ErrorF("[agp] Could not bind\n"); + drmAgpFree(atic->drmFd, atis->agpMemHandle); + drmAgpRelease(atic->drmFd); + return FALSE; + } + + if (!ATIDRIAddAndMap(atic->drmFd, atis->ringStart, atis->ringMapSize, + DRM_AGP, DRM_READ_ONLY, &atis->ringHandle, + (drmAddressPtr)&atis->ring, "ring")) + return FALSE; + + if (!ATIDRIAddAndMap(atic->drmFd, atis->ringReadOffset, + atis->ringReadMapSize, DRM_AGP, DRM_READ_ONLY, + &atis->ringReadPtrHandle, (drmAddressPtr)&atis->ringReadPtr, + "ring read ptr")) + return FALSE; + + if (!ATIDRIAddAndMap(atic->drmFd, atis->bufStart, atis->bufMapSize, + DRM_AGP, 0, &atis->bufHandle, (drmAddressPtr)&atis->buf, + "vertex/indirect buffers")) + return FALSE; + + if (!ATIDRIAddAndMap(atic->drmFd, atis->gartTexStart, + atis->gartTexMapSize, DRM_AGP, 0, &atis->gartTexHandle, + (drmAddressPtr)&atis->gartTex, "AGP texture map")) + return FALSE; + + if (atic->is_r100) { + /* Workaround for some hardware bugs */ + cntl = MMIO_IN32(mmio, ATI_REG_AGP_CNTL); + MMIO_OUT32(mmio, ATI_REG_AGP_CNTL, cntl | + RADEON_PENDING_SLOTS_VAL | RADEON_PENDING_SLOTS_SEL); + } else if (!atic->is_radeon) { + cntl = MMIO_IN32(mmio, ATI_REG_AGP_CNTL); + cntl &= ~R128_AGP_APER_SIZE_MASK; + switch (atis->gartSize) { + case 256: cntl |= R128_AGP_APER_SIZE_256MB; break; + case 128: cntl |= R128_AGP_APER_SIZE_128MB; break; + case 64: cntl |= R128_AGP_APER_SIZE_64MB; break; + case 32: cntl |= R128_AGP_APER_SIZE_32MB; break; + case 16: cntl |= R128_AGP_APER_SIZE_16MB; break; + case 8: cntl |= R128_AGP_APER_SIZE_8MB; break; + case 4: cntl |= R128_AGP_APER_SIZE_4MB; break; + default: + ErrorF("[agp] Illegal aperture size %d kB\n", atis->gartSize * + 1024); + return FALSE; + } + MMIO_OUT32(mmio, ATI_REG_AGP_CNTL, cntl); + + /* Disable Rage 128 PCIGART registers */ + chunk = MMIO_IN32(mmio, R128_REG_BM_CHUNK_0_VAL); + chunk &= ~(R128_BM_PTR_FORCE_TO_PCI | + R128_BM_PM4_RD_FORCE_TO_PCI | + R128_BM_GLOBAL_FORCE_TO_PCI); + MMIO_OUT32(mmio, R128_REG_BM_CHUNK_0_VAL, chunk); + + /* Ensure AGP GART is used (for now) */ + MMIO_OUT32(mmio, R128_REG_PCI_GART_PAGE, 1); + } + + MMIO_OUT32(mmio, ATI_REG_AGP_BASE, drmAgpBase(atic->drmFd)); + + return TRUE; +} + +static Bool +ATIDRIPciInit(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo(pScreenPriv); + unsigned char *mmio = atic->reg_base; + CARD32 chunk; + int ret; + + ATIDRIInitGARTValues(pScreen); + + ret = drmScatterGatherAlloc(atic->drmFd, atis->gartSize * 1024 * 1024, + &atis->pciMemHandle); + if (ret < 0) { + ErrorF("[pci] Out of memory (%d)\n", ret); + return FALSE; + } + ErrorF("[pci] %d kB allocated with handle 0x%08lx\n", + atis->gartSize * 1024, (long)atis->pciMemHandle); + + if (!ATIDRIAddAndMap(atic->drmFd, atis->ringStart, atis->ringMapSize, + DRM_SCATTER_GATHER, DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL, + &atis->ringHandle, (drmAddressPtr)&atis->ring, "ring")) + return FALSE; + + if (!ATIDRIAddAndMap(atic->drmFd, atis->ringReadOffset, + atis->ringReadMapSize, DRM_SCATTER_GATHER, + DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL, + &atis->ringReadPtrHandle, (drmAddressPtr)&atis->ringReadPtr, + "ring read ptr")) + return FALSE; + + if (!ATIDRIAddAndMap(atic->drmFd, atis->bufStart, atis->bufMapSize, + DRM_SCATTER_GATHER, 0, &atis->bufHandle, (drmAddressPtr)&atis->buf, + "vertex/indirect buffers")) + return FALSE; + + if (!ATIDRIAddAndMap(atic->drmFd, atis->gartTexStart, + atis->gartTexMapSize, DRM_SCATTER_GATHER, 0, &atis->gartTexHandle, + (drmAddressPtr)&atis->gartTex, "PCI texture map")) + return FALSE; + + if (!atic->is_radeon) { + /* Force PCI GART mode */ + chunk = MMIO_IN32(mmio, R128_REG_BM_CHUNK_0_VAL); + chunk |= (R128_BM_PTR_FORCE_TO_PCI | + R128_BM_PM4_RD_FORCE_TO_PCI | R128_BM_GLOBAL_FORCE_TO_PCI); + MMIO_OUT32(mmio, R128_REG_BM_CHUNK_0_VAL, chunk); + /* Ensure PCI GART is used */ + MMIO_OUT32(mmio, R128_REG_PCI_GART_PAGE, 0); + } + return TRUE; +} + + +/* Initialize the kernel data structures. */ +static int +R128DRIKernelInit(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo(pScreenPriv); + drmR128Init drmInfo; + int bpp = pScreenPriv->screen->fb[0].bitsPerPixel; + + memset(&drmInfo, 0, sizeof(drmR128Init) ); + + drmInfo.func = DRM_R128_INIT_CCE; + drmInfo.sarea_priv_offset = sizeof(XF86DRISAREARec); + drmInfo.is_pci = !atis->using_agp; + drmInfo.cce_mode = R128_PM4_64BM_64VCBM_64INDBM; + drmInfo.cce_secure = TRUE; + drmInfo.ring_size = atis->ringSize * 1024 * 1024; + drmInfo.usec_timeout = atis->DMAusecTimeout; + + drmInfo.front_offset = atis->frontOffset; + drmInfo.front_pitch = atis->frontPitch / (bpp / 8); + drmInfo.back_offset = atis->backOffset; + drmInfo.back_pitch = atis->backPitch / (bpp / 8); + drmInfo.fb_bpp = bpp; + + drmInfo.depth_offset = atis->depthOffset; + drmInfo.depth_pitch = atis->depthPitch / (bpp / 8); + drmInfo.depth_bpp = bpp; + + drmInfo.span_offset = atis->spanOffset; + + drmInfo.fb_offset = atis->fbHandle; + drmInfo.mmio_offset = atis->registerHandle; + drmInfo.ring_offset = atis->ringHandle; + drmInfo.ring_rptr_offset = atis->ringReadPtrHandle; + drmInfo.buffers_offset = atis->bufHandle; + drmInfo.agp_textures_offset = atis->gartTexHandle; + + if (drmCommandWrite(atic->drmFd, DRM_R128_INIT, &drmInfo, + sizeof(drmR128Init)) < 0) + return FALSE; + + return TRUE; +} + +/* Initialize the kernel data structures */ +static int +RadeonDRIKernelInit(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo(pScreenPriv); + drmRadeonInit drmInfo; + + memset(&drmInfo, 0, sizeof(drmRadeonInit)); + + if (atic->is_r200) + drmInfo.func = DRM_RADEON_INIT_R200_CP; + else + drmInfo.func = DRM_RADEON_INIT_CP; + + drmInfo.sarea_priv_offset = sizeof(XF86DRISAREARec); + drmInfo.is_pci = !atis->using_agp; + drmInfo.cp_mode = RADEON_CSQ_PRIBM_INDBM; + drmInfo.gart_size = atis->gartSize * 1024 * 1024; + drmInfo.ring_size = atis->ringSize * 1024 * 1024; + drmInfo.usec_timeout = atis->DMAusecTimeout; + + drmInfo.front_offset = atis->frontOffset; + drmInfo.front_pitch = atis->frontPitch; + drmInfo.back_offset = atis->backOffset; + drmInfo.back_pitch = atis->backPitch; + drmInfo.fb_bpp = pScreenPriv->screen->fb[0].bitsPerPixel; + drmInfo.depth_offset = atis->depthOffset; + drmInfo.depth_pitch = atis->depthPitch; + drmInfo.depth_bpp = pScreenPriv->screen->fb[0].bitsPerPixel; + + drmInfo.fb_offset = atis->fbHandle; + drmInfo.mmio_offset = atis->registerHandle; + drmInfo.ring_offset = atis->ringHandle; + drmInfo.ring_rptr_offset = atis->ringReadPtrHandle; + drmInfo.buffers_offset = atis->bufHandle; + drmInfo.gart_textures_offset = atis->gartTexHandle; + + if (drmCommandWrite(atic->drmFd, DRM_RADEON_CP_INIT, + &drmInfo, sizeof(drmRadeonInit)) < 0) + return FALSE; + + return TRUE; +} + +/* Add a map for the vertex buffers that will be accessed by any + DRI-based clients. */ +static Bool +ATIDRIBufInit(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo(pScreenPriv); + int type, size; + + if (atic->is_radeon) + size = RADEON_BUFFER_SIZE; + else + size = R128_BUFFER_SIZE; + + if (atis->using_agp) + type = DRM_AGP_BUFFER; + else + type = DRM_SG_BUFFER; + + /* Initialize vertex buffers */ + atis->bufNumBufs = drmAddBufs(atic->drmFd, atis->bufMapSize / size, + size, type, atis->bufStart); + + if (atis->bufNumBufs <= 0) { + ErrorF("[drm] Could not create vertex/indirect buffers list\n"); + return FALSE; + } + ErrorF("[drm] Added %d %d byte vertex/indirect buffers\n", + atis->bufNumBufs, size); + + atis->buffers = drmMapBufs(atic->drmFd); + if (atis->buffers == NULL) { + ErrorF("[drm] Failed to map vertex/indirect buffers list\n"); + return FALSE; + } + ErrorF("[drm] Mapped %d vertex/indirect buffers\n", + atis->buffers->count); + + return TRUE; +} + +static int +ATIDRIIrqInit(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo(pScreenPriv); + + if (atis->irqEnabled) + return FALSE; + + atis->irqEnabled = drmCtlInstHandler(atic->drmFd, 0); + + if (!atis->irqEnabled) + return FALSE; + + return TRUE; +} + +static void ATIDRISwapContext(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType oldContextType, void *oldContext, + DRIContextType newContextType, void *newContext) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + + if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) && + (newContextType==DRI_2D_CONTEXT)) { + /* Entering from Wakeup */ + kaaMarkSync(pScreen); + } + if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) && + (newContextType==DRI_2D_CONTEXT)) { + /* Exiting from Block Handler */ + if (atis->dma_started) + ATIFlushIndirect(atis, 1); + } +} + +static Bool ATIDRIFinishScreenInit(ScreenPtr pScreen); + +/* Initialize the screen-specific data structures for the Radeon or + Rage 128. This is the main entry point to the device-specific + initialization code. It calls device-independent DRI functions to + create the DRI data structures and initialize the DRI state. */ +Bool +ATIDRIScreenInit(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo(pScreenPriv); + void *scratch_ptr; + int scratch_int; + DRIInfoPtr pDRIInfo; + int devSareaSize; + drmSetVersion sv; + + if (pScreenPriv->screen->fb[0].depth < 16 || + pScreenPriv->screen->fb[0].bitsPerPixel == 24) { + ErrorF("DRI unsupported at this depth/bpp, disabling.\n"); + return FALSE; + } + + atis->agpMode = 1; + atis->gartSize = 8; + atis->ringSize = 1; + atis->bufSize = 2; + atis->gartTexSize = 1; + atis->DMAusecTimeout = 10000; + + if (atic->drmFd < 0) + return FALSE; + + sv.drm_di_major = -1; + sv.drm_dd_major = -1; + drmSetInterfaceVersion(atic->drmFd, &sv); + if (atic->is_radeon) { + if (sv.drm_dd_major != 1 || sv.drm_dd_minor < 6) { + ErrorF("[dri] radeon kernel module version is %d.%d " + "but version 1.6 or greater is needed.\n", + sv.drm_dd_major, sv.drm_dd_minor); + return FALSE; + } + } else { + if (sv.drm_dd_major != 2 || sv.drm_dd_minor < 2) { + ErrorF("[dri] r128 kernel module version is %d.%d " + "but version 2.2 or greater is needed.\n", + sv.drm_dd_major, sv.drm_dd_minor); + return FALSE; + } + } + + /* Create the DRI data structure, and fill it in before calling the + * DRIScreenInit(). + */ + pDRIInfo = DRICreateInfoRec(); + if (pDRIInfo == NULL) + return FALSE; + + atis->pDRIInfo = pDRIInfo; + pDRIInfo->busIdString = atic->busid; + if (atic->is_radeon) { + pDRIInfo->drmDriverName = "radeon"; + if (atic->is_r100) + pDRIInfo->clientDriverName = "radeon"; + else + pDRIInfo->clientDriverName = "r200"; + } else { + pDRIInfo->drmDriverName = "r128"; + pDRIInfo->clientDriverName = "r128"; + } + pDRIInfo->ddxDriverMajorVersion = 4; + pDRIInfo->ddxDriverMinorVersion = 0; + pDRIInfo->ddxDriverPatchVersion = 0; + pDRIInfo->frameBufferPhysicalAddress = + pScreenPriv->card->attr.address[0] & 0xfc000000; + pDRIInfo->frameBufferSize = pScreenPriv->screen->memory_size; + pDRIInfo->frameBufferStride = pScreenPriv->screen->fb[0].byteStride; + pDRIInfo->ddxDrawableTableEntry = SAREA_MAX_DRAWABLES; + pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES; + + /* For now the mapping works by using a fixed size defined + * in the SAREA header + */ + pDRIInfo->SAREASize = SAREA_MAX; + + if (atic->is_radeon) { + pDRIInfo->devPrivateSize = sizeof(RADEONDRIRec); + devSareaSize = sizeof(RADEONSAREAPriv); + } else { + pDRIInfo->devPrivateSize = sizeof(R128DRIRec); + devSareaSize = sizeof(R128SAREAPriv); + } + + if (sizeof(XF86DRISAREARec) + devSareaSize > SAREA_MAX) { + ErrorF("[dri] Data does not fit in SAREA. Disabling DRI.\n"); + return FALSE; + } + + pDRIInfo->devPrivate = xcalloc(pDRIInfo->devPrivateSize, 1); + if (pDRIInfo->devPrivate == NULL) { + DRIDestroyInfoRec(atis->pDRIInfo); + atis->pDRIInfo = NULL; + return FALSE; + } + + pDRIInfo->contextSize = sizeof(ATIDRIContextRec); + + pDRIInfo->SwapContext = ATIDRISwapContext; + /*pDRIInfo->InitBuffers = R128DRIInitBuffers;*/ /* XXX Appears unnecessary */ + /*pDRIInfo->MoveBuffers = R128DRIMoveBuffers;*/ /* XXX Badness */ + pDRIInfo->bufferRequests = DRI_ALL_WINDOWS; + /*pDRIInfo->TransitionTo2d = R128DRITransitionTo2d; + pDRIInfo->TransitionTo3d = R128DRITransitionTo3d; + pDRIInfo->TransitionSingleToMulti3D = R128DRITransitionSingleToMulti3d; + pDRIInfo->TransitionMultiToSingle3D = R128DRITransitionMultiToSingle3d;*/ + + pDRIInfo->createDummyCtx = TRUE; + pDRIInfo->createDummyCtxPriv = FALSE; + + if (!DRIScreenInit(pScreen, pDRIInfo, &atic->drmFd)) { + ErrorF("[dri] DRIScreenInit failed. Disabling DRI.\n"); + xfree(pDRIInfo->devPrivate); + pDRIInfo->devPrivate = NULL; + DRIDestroyInfoRec(pDRIInfo); + pDRIInfo = NULL; + return FALSE; + } + + /* Add a map for the MMIO registers that will be accessed by any + * DRI-based clients. + */ + atis->registerSize = ATI_REG_SIZE(pScreenPriv->screen->card); + if (drmAddMap(atic->drmFd, ATI_REG_BASE(pScreenPriv->screen->card), + atis->registerSize, DRM_REGISTERS, DRM_READ_ONLY, + &atis->registerHandle) < 0) { + ATIDRICloseScreen(pScreen); + return FALSE; + } + ErrorF("[drm] register handle = 0x%08lx\n", atis->registerHandle); + + /* DRIScreenInit adds the frame buffer map, but we need it as well */ + DRIGetDeviceInfo(pScreen, &atis->fbHandle, &scratch_int, &scratch_int, + &scratch_int, &scratch_int, &scratch_ptr); + + /* Initialize AGP */ + atis->using_agp = atic->is_agp; + if (atic->is_agp && !ATIDRIAgpInit(pScreen)) { + atis->using_agp = FALSE; + ErrorF("[agp] AGP failed to initialize; falling back to PCI mode.\n"); + ErrorF("[agp] Make sure your kernel's AGP support is loaded and functioning.\n"); + } + + /* Initialize PCIGART */ + if (!atis->using_agp && !ATIDRIPciInit(pScreen)) { + ATIDRICloseScreen(pScreen); + return FALSE; + } + +#ifdef GLXEXT + if (!ATIInitVisualConfigs(pScreen)) { + ATIDRICloseScreen(pScreen); + return FALSE; + } + ErrorF("[dri] Visual configs initialized\n"); +#endif + + atis->serverContext = DRIGetContext(pScreen); + + return ATIDRIFinishScreenInit(pScreen); +} + +/* Finish initializing the device-dependent DRI state, and call + DRIFinishScreenInit() to complete the device-independent DRI + initialization. */ +static Bool +R128DRIFinishScreenInit(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + R128SAREAPrivPtr pSAREAPriv; + R128DRIPtr pR128DRI; + int bpp = pScreenPriv->screen->fb[0].bitsPerPixel; + + /* Initialize the kernel data structures */ + if (!R128DRIKernelInit(pScreen)) { + ATIDRICloseScreen(pScreen); + return FALSE; + } + + /* Initialize the vertex buffers list */ + if (!ATIDRIBufInit(pScreen)) { + ATIDRICloseScreen(pScreen); + return FALSE; + } + + /* Initialize IRQ */ + ATIDRIIrqInit(pScreen); + + pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScreen); + memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); + + pR128DRI = (R128DRIPtr)atis->pDRIInfo->devPrivate; + + pR128DRI->deviceID = pScreenPriv->screen->card->attr.deviceID; + pR128DRI->width = pScreenPriv->screen->width; + pR128DRI->height = pScreenPriv->screen->height; + pR128DRI->depth = pScreenPriv->screen->fb[0].depth; + pR128DRI->bpp = pScreenPriv->screen->fb[0].bitsPerPixel; + + pR128DRI->IsPCI = !atis->using_agp; + pR128DRI->AGPMode = atis->agpMode; + + pR128DRI->frontOffset = atis->frontOffset; + pR128DRI->frontPitch = atis->frontPitch / (bpp / 8); + pR128DRI->backOffset = atis->backOffset; + pR128DRI->backPitch = atis->backPitch / (bpp / 8); + pR128DRI->depthOffset = atis->depthOffset; + pR128DRI->depthPitch = atis->depthPitch / (bpp / 8); + pR128DRI->spanOffset = atis->spanOffset; + pR128DRI->textureOffset = atis->textureOffset; + pR128DRI->textureSize = atis->textureSize; + pR128DRI->log2TexGran = atis->log2TexGran; + + pR128DRI->registerHandle = atis->registerHandle; + pR128DRI->registerSize = atis->registerSize; + + pR128DRI->gartTexHandle = atis->gartTexHandle; + pR128DRI->gartTexMapSize = atis->gartTexMapSize; + pR128DRI->log2AGPTexGran = atis->log2GARTTexGran; + pR128DRI->gartTexOffset = atis->gartTexStart; + pR128DRI->sarea_priv_offset = sizeof(XF86DRISAREARec); + + return TRUE; +} + +/* Finish initializing the device-dependent DRI state, and call + * DRIFinishScreenInit() to complete the device-independent DRI + * initialization. + */ +static Bool +RadeonDRIFinishScreenInit(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo(pScreenPriv); + RADEONSAREAPrivPtr pSAREAPriv; + RADEONDRIPtr pRADEONDRI; + drmRadeonMemInitHeap drmHeap; + + /* Initialize the kernel data structures */ + if (!RadeonDRIKernelInit(pScreen)) { + ATIDRICloseScreen(pScreen); + return FALSE; + } + + /* Initialize the vertex buffers list */ + if (!ATIDRIBufInit(pScreen)) { + ATIDRICloseScreen(pScreen); + return FALSE; + } + + /* Initialize IRQ */ + ATIDRIIrqInit(pScreen); + + drmHeap.region = RADEON_MEM_REGION_GART; + drmHeap.start = 0; + drmHeap.size = atis->gartTexMapSize; + + if (drmCommandWrite(atic->drmFd, DRM_RADEON_INIT_HEAP, &drmHeap, + sizeof(drmHeap))) { + ErrorF("[drm] Failed to initialize GART heap manager\n"); + } + + /* Initialize the SAREA private data structure */ + pSAREAPriv = (RADEONSAREAPrivPtr)DRIGetSAREAPrivate(pScreen); + memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); + + pRADEONDRI = (RADEONDRIPtr)atis->pDRIInfo->devPrivate; + + pRADEONDRI->deviceID = pScreenPriv->screen->card->attr.deviceID; + pRADEONDRI->width = pScreenPriv->screen->width; + pRADEONDRI->height = pScreenPriv->screen->height; + pRADEONDRI->depth = pScreenPriv->screen->fb[0].depth; + pRADEONDRI->bpp = pScreenPriv->screen->fb[0].bitsPerPixel; + + pRADEONDRI->IsPCI = !atis->using_agp; + pRADEONDRI->AGPMode = atis->agpMode; + + pRADEONDRI->frontOffset = atis->frontOffset; + pRADEONDRI->frontPitch = atis->frontPitch; + pRADEONDRI->backOffset = atis->backOffset; + pRADEONDRI->backPitch = atis->backPitch; + pRADEONDRI->depthOffset = atis->depthOffset; + pRADEONDRI->depthPitch = atis->depthPitch; + pRADEONDRI->textureOffset = atis->textureOffset; + pRADEONDRI->textureSize = atis->textureSize; + pRADEONDRI->log2TexGran = atis->log2TexGran; + + pRADEONDRI->registerHandle = atis->registerHandle; + pRADEONDRI->registerSize = atis->registerSize; + + pRADEONDRI->statusHandle = atis->ringReadPtrHandle; + pRADEONDRI->statusSize = atis->ringReadMapSize; + + pRADEONDRI->gartTexHandle = atis->gartTexHandle; + pRADEONDRI->gartTexMapSize = atis->gartTexMapSize; + pRADEONDRI->log2GARTTexGran = atis->log2GARTTexGran; + pRADEONDRI->gartTexOffset = atis->gartTexStart; + + pRADEONDRI->sarea_priv_offset = sizeof(XF86DRISAREARec); + + return TRUE; +} + +static Bool +ATIDRIFinishScreenInit(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + ATIScreenInfo(pScreenPriv); + ATICardInfo (pScreenPriv); + + atis->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT; + + /* NOTE: DRIFinishScreenInit must be called before *DRIKernelInit + * because *DRIKernelInit requires that the hardware lock is held by + * the X server, and the first time the hardware lock is grabbed is + * in DRIFinishScreenInit. + */ + if (!DRIFinishScreenInit(pScreen)) { + ATIDRICloseScreen(pScreen); + return FALSE; + } + + if (atic->is_radeon) { + if (!RadeonDRIFinishScreenInit(pScreen)) { + ATIDRICloseScreen(pScreen); + return FALSE; + } + } else { + if (!R128DRIFinishScreenInit(pScreen)) { + ATIDRICloseScreen(pScreen); + return FALSE; + } + } + + return TRUE; +} + +/* The screen is being closed, so clean up any state and free any + resources used by the DRI. */ +void +ATIDRICloseScreen(ScreenPtr pScreen) +{ + KdScreenPriv (pScreen); + ATIScreenInfo (pScreenPriv); + ATICardInfo (pScreenPriv); + drmR128Init drmR128Info; + drmRadeonInit drmRadeonInfo; + + if (atis->indirectBuffer != NULL) { + /* Flush any remaining commands and free indirect buffers. + * Two steps are used because ATIFlushIndirect gets a + * new buffer after discarding. + */ + ATIFlushIndirect(atis, 1); + ATIDRIDispatchIndirect(atis, 1); + xfree(atis->indirectBuffer); + atis->indirectBuffer = NULL; + atis->indirectStart = 0; + } + ATIDRIDMAStop(atis); + + if (atis->irqEnabled) { + drmCtlUninstHandler(atic->drmFd); + atis->irqEnabled = FALSE; + } + + /* De-allocate vertex buffers */ + if (atis->buffers) { + drmUnmapBufs(atis->buffers); + atis->buffers = NULL; + } + + /* De-allocate all kernel resources */ + if (!atic->is_radeon) { + memset(&drmR128Info, 0, sizeof(drmR128Init)); + drmR128Info.func = DRM_R128_CLEANUP_CCE; + drmCommandWrite(atic->drmFd, DRM_R128_INIT, &drmR128Info, + sizeof(drmR128Init)); + } else { + memset(&drmRadeonInfo, 0, sizeof(drmRadeonInfo)); + drmRadeonInfo.func = DRM_RADEON_CLEANUP_CP; + drmCommandWrite(atic->drmFd, DRM_RADEON_CP_INIT, &drmRadeonInfo, + sizeof(drmR128Init)); + } + + /* De-allocate all AGP resources */ + if (atis->gartTex) { + drmUnmap(atis->gartTex, atis->gartTexMapSize); + atis->gartTex = NULL; + } + if (atis->buf) { + drmUnmap(atis->buf, atis->bufMapSize); + atis->buf = NULL; + } + if (atis->ringReadPtr) { + drmUnmap(atis->ringReadPtr, atis->ringReadMapSize); + atis->ringReadPtr = NULL; + } + if (atis->ring) { + drmUnmap(atis->ring, atis->ringMapSize); + atis->ring = NULL; + } + if (atis->agpMemHandle != DRM_AGP_NO_HANDLE) { + drmAgpUnbind(atic->drmFd, atis->agpMemHandle); + drmAgpFree(atic->drmFd, atis->agpMemHandle); + atis->agpMemHandle = DRM_AGP_NO_HANDLE; + drmAgpRelease(atic->drmFd); + } + if (atis->pciMemHandle) { + drmScatterGatherFree(atic->drmFd, atis->pciMemHandle); + atis->pciMemHandle = 0; + } + + /* De-allocate all DRI resources */ + DRICloseScreen(pScreen); + + /* De-allocate all DRI data structures */ + if (atis->pDRIInfo) { + if (atis->pDRIInfo->devPrivate) { + xfree(atis->pDRIInfo->devPrivate); + atis->pDRIInfo->devPrivate = NULL; + } + DRIDestroyInfoRec(atis->pDRIInfo); + atis->pDRIInfo = NULL; + } + +#ifdef GLXEXT + if (atis->pVisualConfigs) { + xfree(atis->pVisualConfigs); + atis->pVisualConfigs = NULL; + } + if (atis->pVisualConfigsPriv) { + xfree(atis->pVisualConfigsPriv); + atis->pVisualConfigsPriv = NULL; + } +#endif /* GLXEXT */ + atic->drmFd = -1; +} + +void +ATIDRIDMAStart(ATIScreenInfo *atis) +{ + ATICardInfo *atic = atis->atic; + int ret; + + if (atic->is_radeon) + ret = drmCommandNone(atic->drmFd, DRM_RADEON_CP_START); + else + ret = drmCommandNone(atic->drmFd, DRM_R128_CCE_START); + + if (ret == 0) + atis->dma_started = TRUE; + else + FatalError("%s: DMA start returned %d\n", __FUNCTION__, ret); +} + +/* Attempts to idle the DMA engine and stops it. Note that the ioctl is the + * same for both R128 and Radeon, so we can just use the name of one of them. + */ +void +ATIDRIDMAStop(ATIScreenInfo *atis) +{ + ATICardInfo *atic = atis->atic; + drmRadeonCPStop stop; + int ret; + + stop.flush = 1; + stop.idle = 1; + ret = drmCommandWrite(atic->drmFd, DRM_RADEON_CP_STOP, &stop, + sizeof(drmRadeonCPStop)); + + if (ret != 0 && errno == EBUSY) { + ErrorF("Failed to idle the DMA engine\n"); + + stop.idle = 0; + ret = drmCommandWrite(atic->drmFd, DRM_RADEON_CP_STOP, &stop, + sizeof(drmRadeonCPStop)); + } + atis->dma_started = FALSE; +} + +void +ATIDRIDMAReset(ATIScreenInfo *atis) +{ + ATICardInfo *atic = atis->atic; + int ret; + + ret = drmCommandNone(atic->drmFd, atic->is_radeon ? + DRM_RADEON_CP_RESET : DRM_R128_CCE_RESET); + + if (ret != 0) + FatalError("Failed to reset CCE/CP\n"); + + atis->dma_started = FALSE; +} + +/* The R128 and Radeon Indirect ioctls differ only in the ioctl number */ +void +ATIDRIDispatchIndirect(ATIScreenInfo *atis, Bool discard) +{ + ATICardInfo *atic = atis->atic; + drmBufPtr buffer = atis->indirectBuffer->drmBuf; + drmR128Indirect indirect; + int cmd; + + indirect.idx = buffer->idx; + indirect.start = atis->indirectStart; + indirect.end = buffer->used; + indirect.discard = discard; + cmd = atic->is_radeon ? DRM_RADEON_INDIRECT : DRM_R128_INDIRECT; + drmCommandWriteRead(atic->drmFd, cmd, &indirect, + sizeof(drmR128Indirect)); +} + +/* Get an indirect buffer for the DMA 2D acceleration commands */ +drmBufPtr +ATIDRIGetBuffer(ATIScreenInfo *atis) +{ + ATICardInfo *atic = atis->atic; + drmDMAReq dma; + drmBufPtr buf = NULL; + int indx = 0, size = 0, ret = 0; + TIMEOUT_LOCALS; + + dma.context = atis->serverContext; + dma.send_count = 0; + dma.send_list = NULL; + dma.send_sizes = NULL; + dma.flags = 0; + dma.request_count = 1; + if (atic->is_radeon) + dma.request_size = RADEON_BUFFER_SIZE; + else + dma.request_size = R128_BUFFER_SIZE; + dma.request_list = &indx; + dma.request_sizes = &size; + dma.granted_count = 0; + + WHILE_NOT_TIMEOUT(.2) { + ret = drmDMA(atic->drmFd, &dma); + if (ret != -EBUSY) + break; + } + if (TIMEDOUT()) + FatalError("Timeout fetching DMA buffer (card hung)\n"); + if (ret != 0) + FatalError("Error fetching DMA buffer: %d\n", ret); + + buf = &atis->buffers->list[indx]; + buf->used = 0; + return buf; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/ati/r128_common.h +++ xorg-server-1.4.99.906/hw/kdrive/ati/r128_common.h @@ -0,0 +1,170 @@ +/* r128_common.h -- common header definitions for R128 2D/3D/DRM suite + * Created: Sun Apr 9 18:16:28 2000 by kevin@precisioninsight.com + * + * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: + * Gareth Hughes + * Kevin E. Martin + * + * Converted to common header format: + * Jens Owen + * + * + */ + +#ifndef _R128_COMMON_H_ +#define _R128_COMMON_H_ + +#include "X11/Xmd.h" + +/* + * WARNING: If you change any of these defines, make sure to change + * the kernel include file as well (r128_drm.h) + */ + +/* Driver specific DRM command indices + * NOTE: these are not OS specific, but they are driver specific + */ +#define DRM_R128_INIT 0x00 +#define DRM_R128_CCE_START 0x01 +#define DRM_R128_CCE_STOP 0x02 +#define DRM_R128_CCE_RESET 0x03 +#define DRM_R128_CCE_IDLE 0x04 +#define DRM_R128_UNDEFINED1 0x05 +#define DRM_R128_RESET 0x06 +#define DRM_R128_SWAP 0x07 +#define DRM_R128_CLEAR 0x08 +#define DRM_R128_VERTEX 0x09 +#define DRM_R128_INDICES 0x0a +#define DRM_R128_BLIT 0x0b +#define DRM_R128_DEPTH 0x0c +#define DRM_R128_STIPPLE 0x0d +#define DRM_R128_UNDEFINED2 0x0e +#define DRM_R128_INDIRECT 0x0f +#define DRM_R128_FULLSCREEN 0x10 +#define DRM_R128_CLEAR2 0x11 +#define DRM_R128_GETPARAM 0x12 +#define DRM_R128_FLIP 0x13 + +#define DRM_R128_FRONT_BUFFER 0x1 +#define DRM_R128_BACK_BUFFER 0x2 +#define DRM_R128_DEPTH_BUFFER 0x4 + +typedef struct { + enum { + DRM_R128_INIT_CCE = 0x01, + DRM_R128_CLEANUP_CCE = 0x02 + } func; + unsigned long sarea_priv_offset; + int is_pci; + int cce_mode; + int cce_secure; /* FIXME: Deprecated, we should remove this */ + int ring_size; + int usec_timeout; + + unsigned int fb_bpp; + unsigned int front_offset, front_pitch; + unsigned int back_offset, back_pitch; + unsigned int depth_bpp; + unsigned int depth_offset, depth_pitch; + unsigned int span_offset; + + unsigned long fb_offset; + unsigned long mmio_offset; + unsigned long ring_offset; + unsigned long ring_rptr_offset; + unsigned long buffers_offset; + unsigned long agp_textures_offset; +} drmR128Init; + +typedef struct { + int flush; + int idle; +} drmR128CCEStop; + +typedef struct { + int idx; + int start; + int end; + int discard; +} drmR128Indirect; + +typedef struct { + int idx; + int pitch; + int offset; + int format; + unsigned short x, y; + unsigned short width, height; +} drmR128Blit; + +typedef struct { + enum { + DRM_R128_WRITE_SPAN = 0x01, + DRM_R128_WRITE_PIXELS = 0x02, + DRM_R128_READ_SPAN = 0x03, + DRM_R128_READ_PIXELS = 0x04 + } func; + int n; + int *x; + int *y; + unsigned int *buffer; + unsigned char *mask; +} drmR128Depth; + +typedef struct { + int prim; + int idx; /* Index of vertex buffer */ + int count; /* Number of vertices in buffer */ + int discard; /* Client finished with buffer? */ +} drmR128Vertex; + +typedef struct { + unsigned int *mask; +} drmR128Stipple; + +typedef struct { + unsigned int flags; + unsigned int clear_color; + unsigned int clear_depth; + unsigned int color_mask; + unsigned int depth_mask; +} drmR128Clear; + +typedef struct { + enum { + DRM_R128_INIT_FULLSCREEN = 0x01, + DRM_R128_CLEANUP_FULLSCREEN = 0x02 + } func; +} drmR128Fullscreen; + +typedef struct drm_r128_getparam { + int param; + int *value; +} drmR128GetParam; + +#define R128_PARAM_IRQ_NR 1 + +#endif --- xorg-server-1.4.99.906.orig/hw/kdrive/ati/radeon_sarea.h +++ xorg-server-1.4.99.906/hw/kdrive/ati/radeon_sarea.h @@ -0,0 +1,221 @@ +/* + * Copyright 2000 ATI Technologies Inc., Markham, Ontario, + * VA Linux Systems Inc., Fremont, California. + * + * 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 on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR + * THEIR SUPPLIERS 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. + */ + +/* + * Authors: + * Kevin E. Martin + * Gareth Hughes + * + */ + +#ifndef _RADEON_SAREA_H_ +#define _RADEON_SAREA_H_ + +/* WARNING: If you change any of these defines, make sure to change the + * defines in the kernel file (radeon_drm.h) + */ +#ifndef __RADEON_SAREA_DEFINES__ +#define __RADEON_SAREA_DEFINES__ + +/* What needs to be changed for the current vertex buffer? */ +#define RADEON_UPLOAD_CONTEXT 0x00000001 +#define RADEON_UPLOAD_VERTFMT 0x00000002 +#define RADEON_UPLOAD_LINE 0x00000004 +#define RADEON_UPLOAD_BUMPMAP 0x00000008 +#define RADEON_UPLOAD_MASKS 0x00000010 +#define RADEON_UPLOAD_VIEWPORT 0x00000020 +#define RADEON_UPLOAD_SETUP 0x00000040 +#define RADEON_UPLOAD_TCL 0x00000080 +#define RADEON_UPLOAD_MISC 0x00000100 +#define RADEON_UPLOAD_TEX0 0x00000200 +#define RADEON_UPLOAD_TEX1 0x00000400 +#define RADEON_UPLOAD_TEX2 0x00000800 +#define RADEON_UPLOAD_TEX0IMAGES 0x00001000 +#define RADEON_UPLOAD_TEX1IMAGES 0x00002000 +#define RADEON_UPLOAD_TEX2IMAGES 0x00004000 +#define RADEON_UPLOAD_CLIPRECTS 0x00008000 /* handled client-side */ +#define RADEON_REQUIRE_QUIESCENCE 0x00010000 +#define RADEON_UPLOAD_ZBIAS 0x00020000 +#define RADEON_UPLOAD_ALL 0x0002ffff +#define RADEON_UPLOAD_CONTEXT_ALL 0x000201ff + +#define RADEON_FRONT 0x1 +#define RADEON_BACK 0x2 +#define RADEON_DEPTH 0x4 +#define RADEON_STENCIL 0x8 + +/* Primitive types */ +#define RADEON_POINTS 0x1 +#define RADEON_LINES 0x2 +#define RADEON_LINE_STRIP 0x3 +#define RADEON_TRIANGLES 0x4 +#define RADEON_TRIANGLE_FAN 0x5 +#define RADEON_TRIANGLE_STRIP 0x6 +#define RADEON_3VTX_POINTS 0x9 +#define RADEON_3VTX_LINES 0xa + +/* Vertex/indirect buffer size */ +#define RADEON_BUFFER_SIZE 65536 + +/* Byte offsets for indirect buffer data */ +#define RADEON_INDEX_PRIM_OFFSET 20 +#define RADEON_HOSTDATA_BLIT_OFFSET 32 + +#define RADEON_SCRATCH_REG_OFFSET 32 + +/* Keep these small for testing */ +#define RADEON_NR_SAREA_CLIPRECTS 12 + +#define RADEON_MAX_TEXTURE_LEVELS 12 +#define RADEON_MAX_TEXTURE_UNITS 3 + +/* Blits have strict offset rules. All blit offset must be aligned on + * a 1K-byte boundary. + */ +#define RADEON_OFFSET_SHIFT 10 +#define RADEON_OFFSET_ALIGN (1 << RADEON_OFFSET_SHIFT) +#define RADEON_OFFSET_MASK (RADEON_OFFSET_ALIGN - 1) + +#endif /* __RADEON_SAREA_DEFINES__ */ + +typedef struct { + unsigned int red; + unsigned int green; + unsigned int blue; + unsigned int alpha; +} radeon_color_regs_t; + +typedef struct { + /* Context state */ + unsigned int pp_misc; + unsigned int pp_fog_color; + unsigned int re_solid_color; + unsigned int rb3d_blendcntl; + unsigned int rb3d_depthoffset; + unsigned int rb3d_depthpitch; + unsigned int rb3d_zstencilcntl; + + unsigned int pp_cntl; + unsigned int rb3d_cntl; + unsigned int rb3d_coloroffset; + unsigned int re_width_height; + unsigned int rb3d_colorpitch; + unsigned int se_cntl; + + /* Vertex format state */ + unsigned int se_coord_fmt; + + /* Line state */ + unsigned int re_line_pattern; + unsigned int re_line_state; + + unsigned int se_line_width; + + /* Bumpmap state */ + unsigned int pp_lum_matrix; + + unsigned int pp_rot_matrix_0; + unsigned int pp_rot_matrix_1; + + /* Mask state */ + unsigned int rb3d_stencilrefmask; + unsigned int rb3d_ropcntl; + unsigned int rb3d_planemask; + + /* Viewport state */ + unsigned int se_vport_xscale; + unsigned int se_vport_xoffset; + unsigned int se_vport_yscale; + unsigned int se_vport_yoffset; + unsigned int se_vport_zscale; + unsigned int se_vport_zoffset; + + /* Setup state */ + unsigned int se_cntl_status; + + /* Misc state */ + unsigned int re_top_left; + unsigned int re_misc; +} radeon_context_regs_t; + +/* Setup registers for each texture unit */ +typedef struct { + unsigned int pp_txfilter; + unsigned int pp_txformat; + unsigned int pp_txoffset; + unsigned int pp_txcblend; + unsigned int pp_txablend; + unsigned int pp_tfactor; + unsigned int pp_border_color; +} radeon_texture_regs_t; + +typedef struct { + /* The channel for communication of state information to the kernel + * on firing a vertex buffer. + */ + radeon_context_regs_t ContextState; + radeon_texture_regs_t TexState[RADEON_MAX_TEXTURE_UNITS]; + unsigned int dirty; + unsigned int vertsize; + unsigned int vc_format; + + /* The current cliprects, or a subset thereof */ + XF86DRIClipRectRec boxes[RADEON_NR_SAREA_CLIPRECTS]; + unsigned int nbox; + + /* Counters for throttling of rendering clients */ + unsigned int last_frame; + unsigned int last_dispatch; + unsigned int last_clear; + + /* Maintain an LRU of contiguous regions of texture space. If you + * think you own a region of texture memory, and it has an age + * different to the one you set, then you are mistaken and it has + * been stolen by another client. If global texAge hasn't changed, + * there is no need to walk the list. + * + * These regions can be used as a proxy for the fine-grained texture + * information of other clients - by maintaining them in the same + * lru which is used to age their own textures, clients have an + * approximate lru for the whole of global texture space, and can + * make informed decisions as to which areas to kick out. There is + * no need to choose whether to kick out your own texture or someone + * else's - simply eject them all in LRU order. + */ + /* Last elt is sentinal */ + drmTextureRegion texList[ATI_NR_TEX_HEAPS][ATI_NR_TEX_REGIONS+1]; + /* last time texture was uploaded */ + unsigned int texAge[ATI_NR_TEX_HEAPS]; + + int ctxOwner; /* last context to upload state */ + int pfAllowPageFlip; /* set by the 2d driver, read by the client */ + int pfCurrentPage; /* set by kernel, read by others */ + int crtc2_base; /* for pageflipping with CloneMode */ +} RADEONSAREAPriv, *RADEONSAREAPrivPtr; + +#endif --- xorg-server-1.4.99.906.orig/hw/kdrive/ati/radeon_common.h +++ xorg-server-1.4.99.906/hw/kdrive/ati/radeon_common.h @@ -0,0 +1,460 @@ +/* radeon_common.h -- common header definitions for Radeon 2D/3D/DRM suite + * + * Copyright 2000 VA Linux Systems, Inc., Fremont, California. + * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: + * Gareth Hughes + * Kevin E. Martin + * Keith Whitwell + * + * Converted to common header format: + * Jens Owen + * + * + */ + +#ifndef _RADEON_COMMON_H_ +#define _RADEON_COMMON_H_ + +#include + +/* WARNING: If you change any of these defines, make sure to change + * the kernel include file as well (radeon_drm.h) + */ + +/* Driver specific DRM command indices + * NOTE: these are not OS specific, but they are driver specific + */ +#define DRM_RADEON_CP_INIT 0x00 +#define DRM_RADEON_CP_START 0x01 +#define DRM_RADEON_CP_STOP 0x02 +#define DRM_RADEON_CP_RESET 0x03 +#define DRM_RADEON_CP_IDLE 0x04 +#define DRM_RADEON_RESET 0x05 +#define DRM_RADEON_FULLSCREEN 0x06 +#define DRM_RADEON_SWAP 0x07 +#define DRM_RADEON_CLEAR 0x08 +#define DRM_RADEON_VERTEX 0x09 +#define DRM_RADEON_INDICES 0x0a +#define DRM_RADEON_STIPPLE 0x0c +#define DRM_RADEON_INDIRECT 0x0d +#define DRM_RADEON_TEXTURE 0x0e +#define DRM_RADEON_VERTEX2 0x0f +#define DRM_RADEON_CMDBUF 0x10 +#define DRM_RADEON_GETPARAM 0x11 +#define DRM_RADEON_FLIP 0x12 +#define DRM_RADEON_ALLOC 0x13 +#define DRM_RADEON_FREE 0x14 +#define DRM_RADEON_INIT_HEAP 0x15 +#define DRM_RADEON_IRQ_EMIT 0x16 +#define DRM_RADEON_IRQ_WAIT 0x17 +#define DRM_RADEON_CP_RESUME 0x18 +#define DRM_RADEON_SETPARAM 0x19 +#define DRM_RADEON_MAX_DRM_COMMAND_INDEX 0x39 + + +#define RADEON_FRONT 0x1 +#define RADEON_BACK 0x2 +#define RADEON_DEPTH 0x4 +#define RADEON_STENCIL 0x8 + +#define RADEON_CLEAR_X1 0 +#define RADEON_CLEAR_Y1 1 +#define RADEON_CLEAR_X2 2 +#define RADEON_CLEAR_Y2 3 +#define RADEON_CLEAR_DEPTH 4 + + +typedef struct { + enum { + DRM_RADEON_INIT_CP = 0x01, + DRM_RADEON_CLEANUP_CP = 0x02, + DRM_RADEON_INIT_R200_CP = 0x03 + } func; + unsigned long sarea_priv_offset; + int is_pci; + int cp_mode; + int gart_size; + int ring_size; + int usec_timeout; + + unsigned int fb_bpp; + unsigned int front_offset, front_pitch; + unsigned int back_offset, back_pitch; + unsigned int depth_bpp; + unsigned int depth_offset, depth_pitch; + + unsigned long fb_offset; + unsigned long mmio_offset; + unsigned long ring_offset; + unsigned long ring_rptr_offset; + unsigned long buffers_offset; + unsigned long gart_textures_offset; +} drmRadeonInit; + +typedef struct { + int flush; + int idle; +} drmRadeonCPStop; + +typedef struct { + int idx; + int start; + int end; + int discard; +} drmRadeonIndirect; + +typedef union drmRadeonClearR { + float f[5]; + unsigned int ui[5]; +} drmRadeonClearRect; + +typedef struct drmRadeonClearT { + unsigned int flags; + unsigned int clear_color; + unsigned int clear_depth; + unsigned int color_mask; + unsigned int depth_mask; /* misnamed field: should be stencil */ + drmRadeonClearRect *depth_boxes; +} drmRadeonClearType; + +typedef struct drmRadeonFullscreenT { + enum { + RADEON_INIT_FULLSCREEN = 0x01, + RADEON_CLEANUP_FULLSCREEN = 0x02 + } func; +} drmRadeonFullscreenType; + +typedef struct { + unsigned int *mask; +} drmRadeonStipple; + +typedef struct { + unsigned int x; + unsigned int y; + unsigned int width; + unsigned int height; + const void *data; +} drmRadeonTexImage; + +typedef struct { + unsigned int offset; + int pitch; + int format; + int width; /* Texture image coordinates */ + int height; + drmRadeonTexImage *image; +} drmRadeonTexture; + + +#define RADEON_MAX_TEXTURE_UNITS 3 + +/* Layout matches drm_radeon_state_t in linux drm_radeon.h. + */ +typedef struct { + struct { + unsigned int pp_misc; /* 0x1c14 */ + unsigned int pp_fog_color; + unsigned int re_solid_color; + unsigned int rb3d_blendcntl; + unsigned int rb3d_depthoffset; + unsigned int rb3d_depthpitch; + unsigned int rb3d_zstencilcntl; + unsigned int pp_cntl; /* 0x1c38 */ + unsigned int rb3d_cntl; + unsigned int rb3d_coloroffset; + unsigned int re_width_height; + unsigned int rb3d_colorpitch; + } context; + struct { + unsigned int se_cntl; + } setup1; + struct { + unsigned int se_coord_fmt; /* 0x1c50 */ + } vertex; + struct { + unsigned int re_line_pattern; /* 0x1cd0 */ + unsigned int re_line_state; + unsigned int se_line_width; /* 0x1db8 */ + } line; + struct { + unsigned int pp_lum_matrix; /* 0x1d00 */ + unsigned int pp_rot_matrix_0; /* 0x1d58 */ + unsigned int pp_rot_matrix_1; + } bumpmap; + struct { + unsigned int rb3d_stencilrefmask; /* 0x1d7c */ + unsigned int rb3d_ropcntl; + unsigned int rb3d_planemask; + } mask; + struct { + unsigned int se_vport_xscale; /* 0x1d98 */ + unsigned int se_vport_xoffset; + unsigned int se_vport_yscale; + unsigned int se_vport_yoffset; + unsigned int se_vport_zscale; + unsigned int se_vport_zoffset; + } viewport; + struct { + unsigned int se_cntl_status; /* 0x2140 */ + } setup2; + struct { + unsigned int re_top_left; /*ignored*/ /* 0x26c0 */ + unsigned int re_misc; + } misc; + struct { + unsigned int pp_txfilter; + unsigned int pp_txformat; + unsigned int pp_txoffset; + unsigned int pp_txcblend; + unsigned int pp_txablend; + unsigned int pp_tfactor; + unsigned int pp_border_color; + } texture[RADEON_MAX_TEXTURE_UNITS]; + struct { + unsigned int se_zbias_factor; + unsigned int se_zbias_constant; + } zbias; + unsigned int dirty; +} drmRadeonState; + +/* 1.1 vertex ioctl. Used in compatibility modes. + */ +typedef struct { + int prim; + int idx; /* Index of vertex buffer */ + int count; /* Number of vertices in buffer */ + int discard; /* Client finished with buffer? */ +} drmRadeonVertex; + +typedef struct { + unsigned int start; + unsigned int finish; + unsigned int prim:8; + unsigned int stateidx:8; + unsigned int numverts:16; /* overloaded as offset/64 for elt prims */ + unsigned int vc_format; +} drmRadeonPrim; + +typedef struct { + int idx; /* Index of vertex buffer */ + int discard; /* Client finished with buffer? */ + int nr_states; + drmRadeonState *state; + int nr_prims; + drmRadeonPrim *prim; +} drmRadeonVertex2; + +#define RADEON_MAX_STATES 16 +#define RADEON_MAX_PRIMS 64 + +/* Command buffer. Replace with true dma stream? + */ +typedef struct { + int bufsz; + char *buf; + int nbox; + drmClipRect *boxes; +} drmRadeonCmdBuffer; + +/* New style per-packet identifiers for use in cmd_buffer ioctl with + * the RADEON_EMIT_PACKET command. Comments relate new packets to old + * state bits and the packet size: + */ +#define RADEON_EMIT_PP_MISC 0 /* context/7 */ +#define RADEON_EMIT_PP_CNTL 1 /* context/3 */ +#define RADEON_EMIT_RB3D_COLORPITCH 2 /* context/1 */ +#define RADEON_EMIT_RE_LINE_PATTERN 3 /* line/2 */ +#define RADEON_EMIT_SE_LINE_WIDTH 4 /* line/1 */ +#define RADEON_EMIT_PP_LUM_MATRIX 5 /* bumpmap/1 */ +#define RADEON_EMIT_PP_ROT_MATRIX_0 6 /* bumpmap/2 */ +#define RADEON_EMIT_RB3D_STENCILREFMASK 7 /* masks/3 */ +#define RADEON_EMIT_SE_VPORT_XSCALE 8 /* viewport/6 */ +#define RADEON_EMIT_SE_CNTL 9 /* setup/2 */ +#define RADEON_EMIT_SE_CNTL_STATUS 10 /* setup/1 */ +#define RADEON_EMIT_RE_MISC 11 /* misc/1 */ +#define RADEON_EMIT_PP_TXFILTER_0 12 /* tex0/6 */ +#define RADEON_EMIT_PP_BORDER_COLOR_0 13 /* tex0/1 */ +#define RADEON_EMIT_PP_TXFILTER_1 14 /* tex1/6 */ +#define RADEON_EMIT_PP_BORDER_COLOR_1 15 /* tex1/1 */ +#define RADEON_EMIT_PP_TXFILTER_2 16 /* tex2/6 */ +#define RADEON_EMIT_PP_BORDER_COLOR_2 17 /* tex2/1 */ +#define RADEON_EMIT_SE_ZBIAS_FACTOR 18 /* zbias/2 */ +#define RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT 19 /* tcl/11 */ +#define RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED 20 /* material/17 */ +#define R200_EMIT_PP_TXCBLEND_0 21 /* tex0/4 */ +#define R200_EMIT_PP_TXCBLEND_1 22 /* tex1/4 */ +#define R200_EMIT_PP_TXCBLEND_2 23 /* tex2/4 */ +#define R200_EMIT_PP_TXCBLEND_3 24 /* tex3/4 */ +#define R200_EMIT_PP_TXCBLEND_4 25 /* tex4/4 */ +#define R200_EMIT_PP_TXCBLEND_5 26 /* tex5/4 */ +#define R200_EMIT_PP_TXCBLEND_6 27 /* /4 */ +#define R200_EMIT_PP_TXCBLEND_7 28 /* /4 */ +#define R200_EMIT_TCL_LIGHT_MODEL_CTL_0 29 /* tcl/6 */ +#define R200_EMIT_TFACTOR_0 30 /* tf/6 */ +#define R200_EMIT_VTX_FMT_0 31 /* vtx/4 */ +#define R200_EMIT_VAP_CTL 32 /* vap/1 */ +#define R200_EMIT_MATRIX_SELECT_0 33 /* msl/5 */ +#define R200_EMIT_TEX_PROC_CTL_2 34 /* tcg/5 */ +#define R200_EMIT_TCL_UCP_VERT_BLEND_CTL 35 /* tcl/1 */ +#define R200_EMIT_PP_TXFILTER_0 36 /* tex0/6 */ +#define R200_EMIT_PP_TXFILTER_1 37 /* tex1/6 */ +#define R200_EMIT_PP_TXFILTER_2 38 /* tex2/6 */ +#define R200_EMIT_PP_TXFILTER_3 39 /* tex3/6 */ +#define R200_EMIT_PP_TXFILTER_4 40 /* tex4/6 */ +#define R200_EMIT_PP_TXFILTER_5 41 /* tex5/6 */ +#define R200_EMIT_PP_TXOFFSET_0 42 /* tex0/1 */ +#define R200_EMIT_PP_TXOFFSET_1 43 /* tex1/1 */ +#define R200_EMIT_PP_TXOFFSET_2 44 /* tex2/1 */ +#define R200_EMIT_PP_TXOFFSET_3 45 /* tex3/1 */ +#define R200_EMIT_PP_TXOFFSET_4 46 /* tex4/1 */ +#define R200_EMIT_PP_TXOFFSET_5 47 /* tex5/1 */ +#define R200_EMIT_VTE_CNTL 48 /* vte/1 */ +#define R200_EMIT_OUTPUT_VTX_COMP_SEL 49 /* vtx/1 */ +#define R200_EMIT_PP_TAM_DEBUG3 50 /* tam/1 */ +#define R200_EMIT_PP_CNTL_X 51 /* cst/1 */ +#define R200_EMIT_RB3D_DEPTHXY_OFFSET 52 /* cst/1 */ +#define R200_EMIT_RE_AUX_SCISSOR_CNTL 53 /* cst/1 */ +#define R200_EMIT_RE_SCISSOR_TL_0 54 /* cst/2 */ +#define R200_EMIT_RE_SCISSOR_TL_1 55 /* cst/2 */ +#define R200_EMIT_RE_SCISSOR_TL_2 56 /* cst/2 */ +#define R200_EMIT_SE_VAP_CNTL_STATUS 57 /* cst/1 */ +#define R200_EMIT_SE_VTX_STATE_CNTL 58 /* cst/1 */ +#define R200_EMIT_RE_POINTSIZE 59 /* cst/1 */ +#define R200_EMIT_TCL_INPUT_VTX_VECTOR_ADDR_0 60 /* cst/4 */ +#define R200_EMIT_PP_CUBIC_FACES_0 61 +#define R200_EMIT_PP_CUBIC_OFFSETS_0 62 +#define R200_EMIT_PP_CUBIC_FACES_1 63 +#define R200_EMIT_PP_CUBIC_OFFSETS_1 64 +#define R200_EMIT_PP_CUBIC_FACES_2 65 +#define R200_EMIT_PP_CUBIC_OFFSETS_2 66 +#define R200_EMIT_PP_CUBIC_FACES_3 67 +#define R200_EMIT_PP_CUBIC_OFFSETS_3 68 +#define R200_EMIT_PP_CUBIC_FACES_4 69 +#define R200_EMIT_PP_CUBIC_OFFSETS_4 70 +#define R200_EMIT_PP_CUBIC_FACES_5 71 +#define R200_EMIT_PP_CUBIC_OFFSETS_5 72 +#define RADEON_EMIT_PP_TEX_SIZE_0 73 +#define RADEON_EMIT_PP_TEX_SIZE_1 74 +#define RADEON_EMIT_PP_TEX_SIZE_2 75 +#define RADEON_MAX_STATE_PACKETS 76 + + +/* Commands understood by cmd_buffer ioctl. More can be added but + * obviously these can't be removed or changed: + */ +#define RADEON_CMD_PACKET 1 /* emit one of the register packets above */ +#define RADEON_CMD_SCALARS 2 /* emit scalar data */ +#define RADEON_CMD_VECTORS 3 /* emit vector data */ +#define RADEON_CMD_DMA_DISCARD 4 /* discard current dma buf */ +#define RADEON_CMD_PACKET3 5 /* emit hw packet */ +#define RADEON_CMD_PACKET3_CLIP 6 /* emit hw packet wrapped in cliprects */ +#define RADEON_CMD_SCALARS2 7 /* R200 stopgap */ +#define RADEON_CMD_WAIT 8 /* synchronization */ + +typedef union { + int i; + struct { + unsigned char cmd_type, pad0, pad1, pad2; + } header; + struct { + unsigned char cmd_type, packet_id, pad0, pad1; + } packet; + struct { + unsigned char cmd_type, offset, stride, count; + } scalars; + struct { + unsigned char cmd_type, offset, stride, count; + } vectors; + struct { + unsigned char cmd_type, buf_idx, pad0, pad1; + } dma; + struct { + unsigned char cmd_type, flags, pad0, pad1; + } wait; +} drmRadeonCmdHeader; + + +#define RADEON_WAIT_2D 0x1 +#define RADEON_WAIT_3D 0x2 + + +typedef struct drm_radeon_getparam { + int param; + int *value; +} drmRadeonGetParam; + +#define RADEON_PARAM_GART_BUFFER_OFFSET 1 +#define RADEON_PARAM_LAST_FRAME 2 +#define RADEON_PARAM_LAST_DISPATCH 3 +#define RADEON_PARAM_LAST_CLEAR 4 +#define RADEON_PARAM_IRQ_NR 5 +#define RADEON_PARAM_GART_BASE 6 + + +#define RADEON_MEM_REGION_GART 1 +#define RADEON_MEM_REGION_FB 2 + +typedef struct drm_radeon_mem_alloc { + int region; + int alignment; + int size; + int *region_offset; /* offset from start of fb or GART */ +} drmRadeonMemAlloc; + +typedef struct drm_radeon_mem_free { + int region; + int region_offset; +} drmRadeonMemFree; + +typedef struct drm_radeon_mem_init_heap { + int region; + int size; + int start; +} drmRadeonMemInitHeap; + +/* 1.6: Userspace can request & wait on irq's: + */ +typedef struct drm_radeon_irq_emit { + int *irq_seq; +} drmRadeonIrqEmit; + +typedef struct drm_radeon_irq_wait { + int irq_seq; +} drmRadeonIrqWait; + + +/* 1.10: Clients tell the DRM where they think the framebuffer is located in + * the card's address space, via a new generic ioctl to set parameters + */ + +typedef struct drm_radeon_set_param { + unsigned int param; + int64_t value; +} drmRadeonSetParam; + +#define RADEON_SETPARAM_FB_LOCATION 1 + + +#endif --- xorg-server-1.4.99.906.orig/hw/kdrive/igs/igs.c +++ xorg-server-1.4.99.906/hw/kdrive/igs/igs.c @@ -0,0 +1,667 @@ +/* + * Copyright © 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "igs.h" + +Bool +igsCardInit (KdCardInfo *card) +{ + int k; + char *pixels; + IgsCardInfo *igsc; + + igsc = (IgsCardInfo *) xalloc (sizeof (IgsCardInfo)); + if (!igsc) + return FALSE; + + memset (igsc, '\0', sizeof (IgsCardInfo)); + + igsc->frameBuffer = (CARD8 *) KdMapDevice (card->attr.address[0] + + IGS_FB, + IGS_MEM); + + igsc->vga = (VOL8 *) KdMapDevice (card->attr.address[0] + + IGS_VGA, + 64 * 1024); + + igsc->cop = (Cop5xxx *) KdMapDevice (card->attr.address[0] + + IGS_COP_OFFSET, + sizeof (Cop5xxx)); + + igsc->copData = (VOL32 *) KdMapDevice (card->attr.address[0] + + IGS_COP_DATA, + IGS_COP_DATA_LEN); + + igsRegInit (&igsc->igsvga, igsc->vga); + + card->driver = igsc; + + return TRUE; +} + +Bool +igsModeSupported (KdScreenInfo *screen, + const KdMonitorTiming *t) +{ + /* make sure the clock isn't too fast */ + if (t->clock > IGS_MAX_CLOCK) + return FALSE; + /* width must be a multiple of 16 */ + if (t->horizontal & 0xf) + return FALSE; + return TRUE; +} + +Bool +igsModeUsable (KdScreenInfo *screen) +{ + KdCardInfo *card = screen->card; + int screen_size; + int pixel_width; + int byte_width; + int fb = 0; + + screen_size = 0; + if (screen->fb[fb].depth >= 24) + { + screen->fb[fb].depth = 24; + if (screen->fb[fb].bitsPerPixel != 24) + screen->fb[fb].bitsPerPixel = 32; + } + else if (screen->fb[fb].depth >= 16) + { + screen->fb[fb].depth = 16; + screen->fb[fb].bitsPerPixel = 16; + } + else if (screen->fb[fb].depth >= 15) + { + screen->fb[fb].depth = 15; + screen->fb[fb].bitsPerPixel = 16; + } + else if (screen->fb[fb].depth >= 12) + { + screen->fb[fb].depth = 12; + screen->fb[fb].bitsPerPixel = 16; + } + else + { + screen->fb[fb].depth = 8; + screen->fb[fb].bitsPerPixel = 8; + } + + byte_width = screen->width * (screen->fb[fb].bitsPerPixel >> 3); + pixel_width = screen->width; + screen->fb[fb].pixelStride = pixel_width; + screen->fb[fb].byteStride = byte_width; + screen_size += byte_width * screen->height; + + return TRUE; +} + +Bool +igsScreenInit (KdScreenInfo *screen) +{ + IgsCardInfo *igsc = screen->card->driver; + int fb = 0; + IgsScreenInfo *igss; + int screen_size, memory; + int pattern_size; + int tile_size; + int stipple_size; + int poffset, boffset; + const KdMonitorTiming *t; + + if (!screen->width || !screen->height) + { + screen->width = 800; + screen->height = 600; + screen->rate = 72; + } + if (!screen->fb[0].depth) + screen->fb[0].depth = 8; + + t = KdFindMode (screen, igsModeSupported); + + screen->rate = t->rate; + screen->width = t->horizontal; + screen->height = t->vertical; + + if (!KdTuneMode (screen, igsModeUsable, igsModeSupported)) + { + return FALSE; + } + + igss = (IgsScreenInfo *) xalloc (sizeof (IgsScreenInfo)); + if (!igss) + return FALSE; + + memset (igss, '\0', sizeof (IgsScreenInfo)); + + screen_size = screen->fb[fb].byteStride * screen->height; + memory = IGS_MEM; + memory -= screen_size; + if (memory >= 1024) + { + igss->cursor_offset = memory - 1024; +#if BITMAP_BIT_ORDER == MSBFirst + igss->cursor_base = (CARD8 *) KdMapDevice (card->attr.address[0] + + igss->cursor_offset, + 1024); +#else + igss->cursor_base = igsc->frameBuffer + igss->cursor_offset; +#endif + memory -= 1024; + } + else + igss->cursor_base = 0; + + tile_size = IgsTileSize(screen->fb[fb].bitsPerPixel) * IGS_NUM_PATTERN; + stipple_size = IgsStippleSize(screen->fb[fb].bitsPerPixel) * IGS_NUM_PATTERN; + pattern_size = tile_size + stipple_size; + if (memory >= pattern_size) + { + boffset = screen_size; + poffset = boffset * 8 / screen->fb[fb].bitsPerPixel; + igss->tile.offset = poffset; + igss->tile.base = igsc->frameBuffer + boffset; + + boffset = screen_size + tile_size; + poffset = boffset * 8 / screen->fb[fb].bitsPerPixel; + igss->stipple.offset = poffset; + igss->stipple.base = igsc->frameBuffer + boffset; + + memory -= pattern_size; + } + else + { + igss->tile.base = 0; + igss->stipple.base = 0; + } + + switch (screen->fb[fb].depth) { + case 8: + screen->fb[fb].visuals = ((1 << StaticGray) | + (1 << GrayScale) | + (1 << StaticColor) | + (1 << PseudoColor) | + (1 << TrueColor) | + (1 << DirectColor)); + screen->fb[fb].blueMask = 0x00; + screen->fb[fb].greenMask = 0x00; + screen->fb[fb].redMask = 0x00; + break; + case 15: + screen->fb[fb].visuals = (1 << TrueColor); + screen->fb[fb].blueMask = 0x001f; + screen->fb[fb].greenMask = 0x03e0; + screen->fb[fb].redMask = 0x7c00; + break; + case 16: + screen->fb[fb].visuals = (1 << TrueColor); + screen->fb[fb].blueMask = 0x001f; + screen->fb[fb].greenMask = 0x07e0; + screen->fb[fb].redMask = 0xf800; + break; + case 24: + screen->fb[fb].visuals = (1 << TrueColor); + screen->fb[fb].blueMask = 0x0000ff; + screen->fb[fb].greenMask = 0x00ff00; + screen->fb[fb].redMask = 0xff0000; + break; + } + + screen->fb[fb].pixelStride = screen->width; + screen->fb[fb].byteStride = screen->width * (screen->fb[fb].bitsPerPixel >> 3); + screen->fb[fb].frameBuffer = igsc->frameBuffer; + if (!igsc->cop) + screen->dumb = TRUE; + screen->driver = igss; + return TRUE; +} + +Bool +igsInitScreen(ScreenPtr pScreen) +{ + return TRUE; +} + +void +igsPreserve (KdCardInfo *card) +{ + IgsCardInfo *igsc = card->driver; + IgsVga *igsvga = &igsc->igsvga; + + igsSave (igsvga); +} + +void +igsSetBlank (IgsVga *igsvga, Bool blank) +{ + igsSetImm(igsvga, igs_screen_off, blank ? 1 : 0); +} + +void +igsSetSync (IgsCardInfo *igsc, int hsync, int vsync) +{ + IgsVga *igsvga = &igsc->igsvga; + + igsSet (igsvga, igs_mexhsyn, hsync); + igsSet (igsvga, igs_mexvsyn, vsync); + VgaFlush (&igsvga->card); +} + + +/* + * Clock synthesis: + * + * scale = p ? (2 * p) : 1 + * f_out = f_ref * ((M + 1) / ((N + 1) * scale)) + * + * Constraints: + * + * 1. 115MHz <= f_ref * ((M + 1) / (N + 1)) <= 260 MHz + * 2. N >= 1 + * + * Vertical refresh rate = clock / ((hsize + hblank) * (vsize + vblank)) + * Horizontal refresh rate = clock / (hsize + hblank) + */ + +/* all in kHz */ + +void +igsGetClock (int target, int *Mp, int *Np, int *Pp, int maxM, int maxN, int maxP, int minVco) +{ + int M, N, P, bestM, bestN; + int f_vco, f_out; + int err, abserr, besterr; + + /* + * Compute correct P value to keep VCO in range + */ + for (P = 0; P <= maxP; P++) + { + f_vco = target * IGS_SCALE(P); + if (f_vco >= minVco) + break; + } + + /* M = f_out / f_ref * ((N + 1) * IGS_SCALE(P)); */ + besterr = target; + for (N = 1; N <= maxN; N++) + { + M = ((target * (N + 1) * IGS_SCALE(P) + (IGS_CLOCK_REF/2)) + IGS_CLOCK_REF/2) / IGS_CLOCK_REF - 1; + if (0 <= M && M <= maxM) + { + f_out = IGS_CLOCK(M,N,P); + err = target - f_out; + if (err < 0) + err = -err; + if (err < besterr) + { + besterr = err; + bestM = M; + bestN = N; + } + } + } + *Mp = bestM; + *Np = bestN; + *Pp = P; +} + +Bool +igsEnable (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + KdScreenInfo *screen = pScreenPriv->screen; + IgsCardInfo *igsc = card->driver; + IgsVga *igsvga = &igsc->igsvga; + const KdMonitorTiming *t; + int hactive, hblank, hfp, hbp; + int vactive, vblank, vfp, vbp; + int hsize; + int fb = 0; + int m, n, r; + int h_total; + int h_display_end; + int h_blank_start; + int h_blank_end; + int h_sync_start; + int h_sync_end; + int h_screen_off; + int v_total; + int v_retrace_start; + int v_retrace_end; + int v_display_end; + int v_blank_start; + int v_blank_end; + int offset; + int num_fetch; + int m_m, m_n, m_r; + + + igsSetBlank (igsvga, TRUE); + + t = KdFindMode (screen, igsModeSupported); + + igsGetClock (t->clock, &m, &n, &r, 2047, 255, 7, IGS_MIN_VCO); + + /* + * Set the chip so that 0x400000 is a big-endian frame buffer + * with the correct byte swapping enabled + */ + igsSet (igsvga, igs_biga22force, 0); + igsSet (igsvga, igs_biga22en, 1); + igsSet (igsvga, igs_biga24en, 1); + /* + * Enable 8-bit DACs + */ + igsSet (igsvga, igs_rampwdn, 0); + igsSet (igsvga, igs_dac6_8, 1); + igsSet (igsvga, igs_dacpwdn, 0); + /* + * Set overscan to black + */ + igsSet (igsvga, igs_overscan_red, 0x00); + igsSet (igsvga, igs_overscan_green, 0x00); + igsSet (igsvga, igs_overscan_blue, 0x00); + /* + * Enable PCI retries + */ + igsSet (igsvga, igs_iow_retry, 1); + igsSet (igsvga, igs_mw_retry, 1); + igsSet (igsvga, igs_mr_retry, 1); + igsSet (igsvga, igs_pci_burst_write, 1); + igsSet (igsvga, igs_pci_burst_read, 1); + /* + * Set FIFO + */ + igsSet (igsvga, igs_memgopg, 1); + igsSet (igsvga, igs_memr2wpg, 0); + igsSet (igsvga, igs_crtff16, 0); + igsSet (igsvga, igs_fifomust, 0xff); + igsSet (igsvga, igs_fifogen, 0xff); + /* + * Enable CRT reg access + */ + igsSetImm (igsvga, igs_ena_vr_access, 1); + igsSetImm (igsvga, igs_crt_protect, 0); + + hfp = t->hfp; + hbp = t->hbp; + hblank = t->hblank; + hactive = t->horizontal; + offset = screen->fb[0].byteStride; + + vfp = t->vfp; + vbp = t->vbp; + vblank = t->vblank; + vactive = t->vertical; + + /* + * Compute character lengths for horizontal timing values + */ + hactive = screen->width / 8; + hblank /= 8; + hfp /= 8; + hbp /= 8; + offset /= 8; + + switch (screen->fb[fb].bitsPerPixel) { + case 8: + igsSet (igsvga, igs_overscan_red, pScreen->blackPixel); + igsSet (igsvga, igs_overscan_green, pScreen->blackPixel); + igsSet (igsvga, igs_overscan_blue, pScreen->blackPixel); + igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_8); + igsSet (igsvga, igs_mode_sel, IGS_MODE_8); + igsSet (igsvga, igs_ramdacbypass, 0); + break; + case 16: + igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_16); + igsSet (igsvga, igs_ramdacbypass, 1); + switch (screen->fb[fb].depth) { + case 12: + igsSet (igsvga, igs_mode_sel, IGS_MODE_4444); + break; + case 15: + igsSet (igsvga, igs_mode_sel, IGS_MODE_5551); + break; + case 16: + igsSet (igsvga, igs_mode_sel, IGS_MODE_565); + break; + } + break; + case 24: + igsSet (igsvga, igs_ramdacbypass, 1); + igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_8); + igsSet (igsvga, igs_mode_sel, IGS_MODE_888); + break; + case 32: + igsSet (igsvga, igs_ramdacbypass, 1); + igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_32); + igsSet (igsvga, igs_mode_sel, IGS_MODE_8888); + break; + } + + /* + * Compute horizontal register values from timings + */ + h_total = hactive + hblank - 5; + h_display_end = hactive - 1; + + h_sync_start = hactive + hfp; + h_sync_end = hactive + hblank - hbp; + /* + * pad the blank values narrow a bit and use the border_select to + * eliminate the remaining border; don't know why, but it doesn't + * work in the documented fashion + */ + h_blank_start = hactive - 1; + h_blank_end = hactive + hblank - 1 - 1; + + num_fetch = (t->horizontal * screen->fb[fb].bitsPerPixel / 64) + 1; + + v_total = vactive + vblank - 2; + v_display_end = vactive - 1; + + v_blank_start = vactive - 1; + v_blank_end = v_blank_start + vblank - 1; + + v_retrace_start = vactive + vfp; + v_retrace_end = vactive + vblank - vbp; + +#if 0 +#define chk(a,b,c) fprintf (stderr, "%20.20s: BIOS %6d X %6d\n", a, igsGet(igsvga, b), c); + + chk("h_total", igs_h_total, h_total); + chk("h_display_end", igs_h_de_end, h_display_end); + chk("h_sync_start", igs_h_rstart, h_sync_start); + chk("h_sync_end", igs_h_rend, h_sync_end&0x1f); + chk("h_blank_start", igs_h_bstart, h_blank_start); + chk("h_blank_end", igs_h_bend, h_blank_end&0x3f); + chk("offset", igs_offset, offset); + chk("num_fetch", igs_num_fetch, num_fetch); + + chk("v_total", igs_v_total, v_total); + chk("v_display_end", igs_v_de_end, v_display_end); + chk("v_blank_start", igs_v_bstart, v_blank_start); + chk("v_blank_end", igs_v_bend, v_blank_end&0xf); + chk("v_retrace_start", igs_v_rstart, v_retrace_start); + chk("v_retrace_end", igs_v_rend, v_retrace_end&0xf); + chk("vclk_m", igs_vclk_m, m); + chk("vclk_n", igs_vclk_n, n); + chk("vclk_p", igs_vclk_p, r); + + fprintf (stderr, "%20.20s: BIOS %6d X %6d\n", "vclk", + IGS_CLOCK(igsGet(igsvga,igs_vclk_m), + igsGet(igsvga,igs_vclk_n), + igsGet(igsvga,igs_vclk_p)), + IGS_CLOCK(m,n,r)); +#endif + igsSet (igsvga, igs_h_total, h_total); + igsSet (igsvga, igs_h_de_end, h_display_end); + igsSet (igsvga, igs_h_rstart, h_sync_start); + igsSet (igsvga, igs_h_rend, h_sync_end); + igsSet (igsvga, igs_h_bstart, h_blank_start); + igsSet (igsvga, igs_h_bend, h_blank_end); + igsSet (igsvga, igs_offset, offset); + igsSet (igsvga, igs_num_fetch, num_fetch); + + igsSet (igsvga, igs_v_total, v_total); + igsSet (igsvga, igs_v_de_end, v_display_end); + igsSet (igsvga, igs_v_bstart, v_blank_start); + igsSet (igsvga, igs_v_bend, v_blank_end&0xf); + igsSet (igsvga, igs_v_rstart, v_retrace_start); + igsSet (igsvga, igs_v_rend, v_retrace_end&0xf); + + igsSet (igsvga, igs_vclk_m, m); + igsSet (igsvga, igs_vclk_n, n); + igsSet (igsvga, igs_vclk_p, r); + igsSet (igsvga, igs_vfsel, IGS_CLOCK(m, n, 0) >= 180000); + VgaFlush (&igsvga->card); + + igsSetImm (igsvga, igs_frqlat, 0); + igsSetImm (igsvga, igs_frqlat, 1); + igsSetImm (igsvga, igs_frqlat, 0); + + igsSetBlank (igsvga, FALSE); +#if 0 +#define dbg(a,b) fprintf(stderr, "%20.20s = 0x%x\n", a, igsGet(igsvga,b)) + +#include "reg.dbg" + + { + VGA16 reg; + char buf[128]; + + for (reg = 0; reg < IGS_NREG; reg++) + fprintf(stderr, "%20.20s = 0x%02x\n", igsRegName(buf, reg), + VgaFetch (&igsvga->card, reg)); + } +#endif + return TRUE; +} + +Bool +igsDPMS (ScreenPtr pScreen, int mode) +{ + KdScreenPriv(pScreen); + IgsCardInfo *igsc = pScreenPriv->card->driver; + IgsVga *igsvga = &igsc->igsvga; + + switch (mode) { + case KD_DPMS_NORMAL: + igsSetSync (igsc, 0, 0); + igsSetBlank (igsvga, FALSE); + break; + case KD_DPMS_STANDBY: + igsSetBlank (igsvga, TRUE); + igsSetSync (igsc, 1, 0); + break; + case KD_DPMS_SUSPEND: + igsSetBlank (igsvga, TRUE); + igsSetSync (igsc, 0, 1); + break; + case KD_DPMS_POWERDOWN: + igsSetBlank (igsvga, TRUE); + igsSetSync (igsc, 1, 1); + break; + } + return TRUE; +} + +void +igsDisable (ScreenPtr pScreen) +{ +} + +void +igsRestore (KdCardInfo *card) +{ + IgsCardInfo *igsc = card->driver; + IgsVga *igsvga = &igsc->igsvga; + + igsReset (igsvga); +} + +void +igsScreenFini (KdScreenInfo *screen) +{ + IgsScreenInfo *igss = (IgsScreenInfo *) screen->driver; + +#if BITMAP_BIT_ORDER == MSBFirst + if (igss->cursor_base) + KdUnmapDevice ((void *) igss->cursor_base, 1024); +#endif + xfree (igss); + screen->driver = 0; +} + +void +igsCardFini (KdCardInfo *card) +{ + IgsCardInfo *igsc = card->driver; + + if (igsc->copData) + KdUnmapDevice ((void *) igsc->copData, IGS_COP_DATA_LEN); + if (igsc->cop) + KdUnmapDevice ((void *) igsc->cop, sizeof (Cop5xxx)); + if (igsc->vga) + KdUnmapDevice ((void *) igsc->vga, 64 * 1024); + if (igsc->frameBuffer) + KdUnmapDevice (igsc->frameBuffer, IGS_MEM); + xfree (igsc); + card->driver = 0; +} + +KdCardFuncs igsFuncs = { + igsCardInit, /* cardinit */ + igsScreenInit, /* scrinit */ + igsInitScreen, + igsPreserve, /* preserve */ + igsEnable, /* enable */ + igsDPMS, /* dpms */ + igsDisable, /* disable */ + igsRestore, /* restore */ + igsScreenFini, /* scrfini */ + igsCardFini, /* cardfini */ + + igsCursorInit, /* initCursor */ + igsCursorEnable, /* enableCursor */ + igsCursorDisable, /* disableCursor */ + igsCursorFini, /* finiCursor */ + 0, /* recolorCursor */ + + igsDrawInit, /* initAccel */ + igsDrawEnable, /* enableAccel */ + igsDrawSync, /* drawSync */ + igsDrawDisable, /* disableAccel */ + igsDrawFini, /* finiAccel */ + + igsGetColors, /* getColors */ + igsPutColors, /* putColors */ +}; --- xorg-server-1.4.99.906.orig/hw/kdrive/igs/igs.h +++ xorg-server-1.4.99.906/hw/kdrive/igs/igs.h @@ -0,0 +1,327 @@ +/* + * Copyright © 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifndef _IGS_H_ +#define _IGS_H_ + +#include "kdrive.h" +#include "igsreg.h" + +extern KdCardFuncs igsFuncs; + +/* + * FB 0x00000000 + * VGA 0x00800000 + * Blt window 0x008a0000 + * Coprocessor 0x008bf000 + */ + +#if BITMAP_BIT_ORDER == MSBFirst +#define IGS_FB 0x00400000 +#else +#define IGS_FB 0x00000000 +#endif +#define IGS_VGA 0x00800000 +#define IGS_COP_DATA 0x008a0000 +#define IGS_COP_DATA_LEN 0x00010000 +#define IGS_COP_OFFSET 0x008bf000 +/* give audio 1/2 meg at end */ +#if 1 +#define IGS_MEM ((4096-512)*1024) +#else +#define IGS_MEM ((4096)*1024) +#endif + +#define IGS_CLOCK_REF 24576 /* KHz */ + +#define IGS_SCALE(p) ((p) ? (2 * (p)) : 1) + +#define IGS_CLOCK(m,n,p) ((IGS_CLOCK_REF * ((m) + 1)) / (((n) + 1) * IGS_SCALE(p))) + +#define IGS_MAX_CLOCK 260000 + +#define IGS_MIN_VCO 115000 + +typedef volatile CARD8 VOL8; +typedef volatile CARD16 VOL16; +typedef volatile CARD32 VOL32; + +typedef struct _Cop5xxx { + VOL8 pad000[0x10]; /* 0x000 */ + + VOL32 control; /* 0x010 */ +#define IGS_CONTROL_HBLTW_RDYZ 0x0100 +#define IGS_CONTROL_MALLWBEPTZ 0x0200 +#define IGS_CONTROL_CMDFF 0x0400 +#define IGS_CONTROL_SOP 0x0800 +#define IGS_CONTROL_OPS 0x1000 +#define IGS_CONTROL_TER 0x2000 +#define IGS_CONTROL_HBACKZ 0x4000 +#define IGS_CONTROL_BUSY 0x8000 + + VOL8 pad014[0x04]; /* 0x014 */ + + VOL32 src1_stride; /* 0x018 */ + + VOL32 format; /* 0x01c */ + +#define IGS_FORMAT_8BPP 0 +#define IGS_FORMAT_16BPP 1 +#define IGS_FORMAT_24BPP 2 +#define IGS_FORMAT_32BPP 3 + + VOL32 bres_error; /* 0x020 */ + VOL32 bres_k1; /* 0x024 */ + VOL32 bres_k2; /* 0x028 */ + VOL8 pad02c[0x1c]; /* 0x02c */ + + VOL32 mix; /* 0x048 */ +#define IGS_MIX_FG 0x00ff +#define IGS_MIX_BG 0xff00 +#define IGS_MAKE_MIX(fg,bg) ((fg) | ((bg) << 8)) + +#define IGS_MIX_ZERO 0x0 +#define IGS_MIX_SRC_AND_DST 0x1 +#define IGS_MIX_SRC_AND_NOT_DST 0x2 +#define IGS_MIX_SRC 0x3 +#define IGS_MIX_NOT_SRC_AND_DST 0x4 +#define IGS_MIX_DST 0x5 +#define IGS_MIX_SRC_XOR_DST 0x6 +#define IGS_MIX_SRC_OR_DST 0x7 +#define IGS_MIX_NOT_SRC_AND_NOT_DST 0x8 +#define IGS_MIX_SRC_XOR_NOT_DST 0x9 +#define IGS_MIX_NOT_DST 0xa +#define IGS_MIX_SRC_OR_NOT_DST 0xb +#define IGS_MIX_NOT_SRC 0xc +#define IGS_MIX_NOT_SRC_OR_DST 0xd +#define IGS_MIX_NOT_SRC_OR_NOT_DST 0xe +#define IGS_MIX_ONE 0xf + + VOL32 colorComp; /* 0x04c */ + VOL32 planemask; /* 0x050 */ + + VOL8 pad054[0x4]; /* 0x054 */ + + VOL32 fg; /* 0x058 */ + VOL32 bg; /* 0x05c */ + VOL32 dim; /* 0x060 */ +#define IGS_MAKE_DIM(w,h) ((w) | ((h) << 16)) + VOL8 pad5[0x0c]; /* 0x064 */ + + VOL32 src1_base_address; /* 0x070 */ + VOL8 pad074[0x04]; /* 0x074 */ + + VOL32 rotate; /* 0x078 */ +#define IGS_MAKE_ROTATE(x,y) ((x) | ((y) << 16)) + VOL32 operation; /* 0x07c */ + +/* OCT[2:0] */ +#define IGS_DRAW_X_MAJOR 0x00000000 +#define IGS_DRAW_Y_MAJOR 0x00000001 +#define IGS_DRAW_T_B 0x00000000 +#define IGS_DRAW_B_T 0x00000002 +#define IGS_DRAW_L_R 0x00000000 +#define IGS_DRAW_R_L 0x00000004 + +/* Draw_Mode[1:0] */ +#define IGS_DRAW_ALL 0x00000000 +#define IGS_DRAW_NOT_FIRST 0x00000010 +#define IGS_DRAW_NOT_LAST 0x00000020 +#define IGS_DRAW_NOT_FIRST_LAST 0x00000030 + +/* TRPS[1:0] */ +#define IGS_TRANS_SRC1 0x00000000 +#define IGS_TRANS_SRC2 0x00000100 +#define IGS_TRANS_DST 0x00000200 +/* TRPS2 Transparent Invert */ +#define IGS_TRANS_INVERT 0x00000400 +/* TRPS3, Transparent Enable */ +#define IGS_TRANS_ENABLE 0x00000800 + +/* PPS[3:0], Pattern Pixel Select */ +#define IGS_PIXEL_TEXT_OPAQUE 0x00001000 +#define IGS_PIXEL_STIP_OPAQUE 0x00002000 +#define IGS_PIXEL_LINE_OPAQUE 0x00003000 +#define IGS_PIXEL_TEXT_TRANS 0x00005000 +#define IGS_PIXEL_STIP_TRANS 0x00006000 +#define IGS_PIXEL_LINE_TRANS 0x00007000 +#define IGS_PIXEL_FG 0x00008000 +#define IGS_PIXEL_TILE 0x00009000 +#define IGS_PIXEL_TILE_OPAQUE 0x0000d000 + +/* HostBltEnable[1:0] */ +#define IGS_HBLT_DISABLE 0x00000000 +#define IGS_HBLT_READ 0x00010000 +#define IGS_HBLT_WRITE_1 0x00020000 +#define IGS_HBLT_WRITE_2 0x00030000 + +/* Src2MapSelect[2:0], Src2 map select mode */ +#define IGS_SRC2_NORMAL 0x00000000 +#define IGS_SRC2_MONO_OPAQUE 0x00100000 +#define IGS_SRC2_FG 0x00200000 +#define IGS_SRC2_MONO_TRANS 0x00500000 + +/* StepFunction[3:0], Step function select */ +#define IGS_STEP_DRAW_AND_STEP 0x04000000 +#define IGS_STEP_LINE_DRAW 0x05000000 +#define IGS_STEP_PXBLT 0x08000000 +#define IGS_STEP_INVERT_PXBLT 0x09000000 +#define IGS_STEP_TERNARY_PXBLT 0x0b000000 + +/* FGS */ +#define IGS_FGS_FG 0x00000000 +#define IGS_FGS_SRC 0x20000000 + +/* BGS */ +#define IGS_BGS_BG 0x00000000 +#define IGS_BGS_SRC 0x80000000 + VOL8 pad080[0x90]; /* 0x080 */ + + VOL32 debug_control; /* 0x110 */ + VOL8 pad114[0x04]; /* 0x114 */ + + VOL32 src2_stride; /* 0x118 */ + VOL8 pad11c[0x14]; /* 0x11c */ + + VOL32 extension; /* 0x130 */ + +#define IGS_BURST_ENABLE 0x01 +#define IGS_STYLE_LINE 0x02 +#define IGS_ADDITIONAL_WAIT 0x04 +#define IGS_BLOCK_COP_REG 0x08 +#define IGS_TURBO_MONO 0x10 +#define IGS_SELECT_SAMPLE 0x40 +#define IGS_MDSBL_RD_B_WR 0x80 +#define IGS_WRMRSTZ 0x100 +#define IGS_TEST_MTST 0x200 + + VOL32 style_line; /* 0x134 */ +#define IGS_MAKE_STILE_LINE(roll_over,inc,pattern,accumulator) \ + ((roll_over) | \ + ((style_line_inc) << 8) | \ + ((style_line_patern) << 16) | \ + ((style_line_accumullator) << 24)) + VOL32 style_line_pattern_index; /* 0x138 */ + + VOL32 mono_burst_total; /* 0x13c */ + VOL8 pad140[0x10]; /* 0x140 */ + + VOL32 pat_x_rotate; /* 0x150 */ + VOL8 pad154[0x1c]; /* 0x154 */ + + VOL32 src1_start; /* 0x170 */ + VOL32 src2_start; /* 0x174 */ + VOL32 dst_start; /* 0x178 */ + VOL8 pad17c[0x9c]; /* 0x17c */ + + VOL32 dst_stride; /* 0x218 */ +} Cop5xxx; + +typedef struct _igsCardInfo { + Cop5xxx *cop; + VOL8 *vga; + VOL32 *copData; + CARD8 *frameBuffer; + IgsVga igsvga; +} IgsCardInfo; + +#define getIgsCardInfo(kd) ((IgsCardInfo *) ((kd)->card->driver)) +#define igsCardInfo(kd) IgsCardInfo *igsc = getIgsCardInfo(kd) + +typedef struct _igsCursor { + int width, height; + int xhot, yhot; + Bool has_cursor; + CursorPtr pCursor; + Pixel source, mask; +} IgsCursor; + +#define IGS_CURSOR_WIDTH 64 +#define IGS_CURSOR_HEIGHT 64 + +typedef struct _igsPattern { + INT32 xrot, yrot; + CARD32 serial_number; + CARD8 *base; + CARD32 offset; +} IgsPattern; + +#define IGS_NUM_PATTERN 8 +#define IGS_PATTERN_WIDTH 8 +#define IGS_PATTERN_HEIGHT 8 + +typedef struct _igsPatternCache { + CARD8 *base; + CARD32 offset; + IgsPattern pattern[IGS_NUM_PATTERN]; + int next; +} IgsPatternCache; + +typedef struct _igsScreenInfo { + CARD8 *cursor_base; + CARD32 cursor_offset; + IgsCursor cursor; + IgsPatternCache tile; + IgsPatternCache stipple; +} IgsScreenInfo; + +#define IgsTileSize(bpp) (IGS_PATTERN_WIDTH*(bpp)/8*IGS_PATTERN_HEIGHT) +#define IgsStippleSize(bpp) (IGS_PATTERN_WIDTH/8*IGS_PATTERN_HEIGHT) + +#define getIgsScreenInfo(kd) ((IgsScreenInfo *) ((kd)->screen->driver)) +#define igsScreenInfo(kd) IgsScreenInfo *igss = getIgsScreenInfo(kd) + +Bool +igsDrawInit (ScreenPtr pScreen); + +void +igsDrawEnable (ScreenPtr pScreen); + +void +igsDrawDisable (ScreenPtr pScreen); + +void +igsDrawSync (ScreenPtr pScreen); + +void +igsDrawFini (ScreenPtr pScreen); + +void +igsGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); + +void +igsPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); + +Bool +igsCursorInit (ScreenPtr pScreen); + +void +igsCursorEnable (ScreenPtr pScreen); + +void +igsCursorDisable (ScreenPtr pScreen); + +void +igsCursorFini (ScreenPtr pScreen); + +#endif /* _IGS_H_ */ --- xorg-server-1.4.99.906.orig/hw/kdrive/igs/igsreg.h +++ xorg-server-1.4.99.906/hw/kdrive/igs/igsreg.h @@ -0,0 +1,155 @@ +/* + * Copyright © 2000 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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. + */ + +#ifndef _IGSREG_H_ +#define _IGSREG_H_ + +#include "vga.h" + +#define IGS_SR 0 +#define IGS_NSR 5 +#define IGS_GR (IGS_SR+IGS_NSR) +#define IGS_NGR 0xC0 +#define IGS_GREX (IGS_GR+IGS_NGR) +#define IGS_GREXBASE 0x3c +#define IGS_NGREX 1 +#define IGS_AR (IGS_GREX+IGS_NGREX) +#define IGS_NAR 0x15 +#define IGS_CR (IGS_AR+IGS_NAR) +#define IGS_NCR 0x48 +#define IGS_DAC (IGS_CR+IGS_NCR) +#define IGS_NDAC 4 +#define IGS_DACEX (IGS_DAC+IGS_NDAC) +#define IGS_NDACEX 4 +#define IGS_MISC_OUT (IGS_DACEX + IGS_NDACEX) +#define IGS_INPUT_STATUS_1 (IGS_MISC_OUT+1) +#define IGS_NREG (IGS_INPUT_STATUS_1+1) + +extern VgaReg igs_h_total[]; +extern VgaReg igs_h_de_end[]; +extern VgaReg igs_h_bstart[]; +extern VgaReg igs_h_bend[]; +extern VgaReg igs_de_skew[]; +extern VgaReg igs_ena_vr_access[]; +extern VgaReg igs_h_rstart[]; +extern VgaReg igs_h_rend[]; +extern VgaReg igs_h_rdelay[]; +extern VgaReg igs_v_total[]; +extern VgaReg igs_v_rstart[]; +extern VgaReg igs_v_rend[]; +extern VgaReg igs_clear_v_int[]; +extern VgaReg igs_disable_v_int[]; +extern VgaReg igs_bandwidth[]; +extern VgaReg igs_crt_protect[]; +extern VgaReg igs_v_de_end[]; +extern VgaReg igs_offset[]; +extern VgaReg igs_v_bstart[]; +extern VgaReg igs_v_bend[]; +extern VgaReg igs_linecomp[]; +extern VgaReg igs_ivideo[]; +extern VgaReg igs_num_fetch[]; +extern VgaReg igs_wcrt0[]; +extern VgaReg igs_wcrt1[]; +extern VgaReg igs_rcrts1[]; +extern VgaReg igs_selwk[]; +extern VgaReg igs_dot_clock_8[]; +extern VgaReg igs_screen_off[]; +extern VgaReg igs_enable_write_plane[]; +extern VgaReg igs_mexhsyn[]; +extern VgaReg igs_mexvsyn[]; +extern VgaReg igs_pci_burst_write[]; +extern VgaReg igs_pci_burst_read[]; +extern VgaReg igs_iow_retry[]; +extern VgaReg igs_mw_retry[]; +extern VgaReg igs_mr_retry[]; +extern VgaReg igs_biga22en[]; +extern VgaReg igs_biga24en[]; +extern VgaReg igs_biga22force[]; +extern VgaReg igs_bigswap[]; +#define IGS_BIGSWAP_8 0x3f +#define IGS_BIGSWAP_16 0x2a +#define IGS_BIGSWAP_32 0x00 +extern VgaReg igs_sprite_x[]; +extern VgaReg igs_sprite_preset_x[]; +extern VgaReg igs_sprite_y[]; +extern VgaReg igs_sprite_preset_y[]; +extern VgaReg igs_sprite_visible[]; +extern VgaReg igs_sprite_64x64[]; +extern VgaReg igs_mgrext[]; +extern VgaReg igs_hcshf[]; +extern VgaReg igs_mbpfix[]; +extern VgaReg igs_overscan_red[]; +extern VgaReg igs_overscan_green[]; +extern VgaReg igs_overscan_blue[]; +extern VgaReg igs_memgopg[]; +extern VgaReg igs_memr2wpg[]; +extern VgaReg igs_crtff16[]; +extern VgaReg igs_fifomust[]; +extern VgaReg igs_fifogen[]; +extern VgaReg igs_mode_sel[]; +#define IGS_MODE_TEXT 0 +#define IGS_MODE_8 1 +#define IGS_MODE_565 2 +#define IGS_MODE_5551 6 +#define IGS_MODE_8888 3 +#define IGS_MODE_888 4 +#define IGS_MODE_332 9 +#define IGS_MODE_4444 10 +extern VgaReg igs_sprite_addr[]; +extern VgaReg igs_fastmpie[]; +extern VgaReg igs_vclk_m[]; +extern VgaReg igs_vclk_n[]; +extern VgaReg igs_vfsel[]; +extern VgaReg igs_vclk_p[]; +extern VgaReg igs_frqlat[]; +extern VgaReg igs_dac_mask[]; +extern VgaReg igs_dac_read_index[]; +extern VgaReg igs_dac_write_index[]; +extern VgaReg igs_dac_data[]; +extern VgaReg igs_rampwdn[]; +extern VgaReg igs_dac6_8[]; +extern VgaReg igs_ramdacbypass[]; +extern VgaReg igs_dacpwdn[]; +extern VgaReg igs_cursor_read_index[]; +extern VgaReg igs_cursor_write_index[]; +extern VgaReg igs_cursor_data[]; + +#define igsGet(sv,r) VgaGet(&(sv)->card, (r)) +#define igsGetImm(sv,r) VgaGetImm(&(sv)->card, (r)) +#define igsSet(sv,r,v) VgaSet(&(sv)->card, (r), (v)) +#define igsSetImm(sv,r,v) VgaSetImm(&(sv)->card, (r), (v)) + +typedef struct _igsVga { + VgaCard card; + VgaValue values[IGS_NREG]; +} IgsVga; + +void +igsRegInit (IgsVga *igsvga, VGAVOL8 *mmio); + +void +igsSave (IgsVga *igsvga); + +void +igsReset (IgsVga *igsvga); + +#endif /* _IGSREG_H_ */ --- xorg-server-1.4.99.906.orig/hw/kdrive/igs/igsdraw.h +++ xorg-server-1.4.99.906/hw/kdrive/igs/igsdraw.h @@ -0,0 +1,258 @@ +/* + * Copyright © 2000 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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. + */ + +#ifndef _IGSDRAW_H_ +#define _IGSDRAW_H_ + +extern CARD8 igsPatRop[]; + +#define SetupIgs(s) KdScreenPriv(s); \ + igsCardInfo(pScreenPriv); \ + Cop5xxx *cop = igsc->cop; \ + int cop_stride = pScreenPriv->screen->fb[0].pixelStride + +#define _igsWaitLoop(cop,mask,value) { \ + int __loop = 1000000; \ + while (((cop)->control & (mask)) != (value)) { \ + if (--__loop <= 0) { \ + FatalError("Warning: igsWaitLoop 0x%x 0x%x failed\n", mask, value); \ + } \ + } \ +} + +#define _igsWaitDone(cop) _igsWaitLoop(cop, \ + (IGS_CONTROL_BUSY| \ + IGS_CONTROL_MALLWBEPTZ), \ + 0) + +#if 1 +#define _igsWaitFull(cop) _igsWaitLoop(cop, \ + IGS_CONTROL_CMDFF, \ + 0) +#else +#define _igsWaitFull(cop) _igsWaitDone(cop) +#endif + +#define _igsWaitIdleEmpty(cop) _igsWaitDone(cop) +#define _igsWaitHostBltAck(cop) _igsWaitLoop(cop, \ + (IGS_CONTROL_HBACKZ| \ + IGS_CONTROL_CMDFF), \ + 0) + +#define _igsReset(cop) ((cop)->control = 0) + +#define IgsInvertBits32(v) { \ + v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ + v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ + v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ +} + +#define IgsInvertBits16(v) { \ + v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \ + v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \ + v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \ +} + +#define IgsInvertBits8(v) { \ + v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \ + v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \ + v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \ +} + +#define IgsByteSwap32(x) ((x) = (((x) >> 24) | \ + (((x) >> 8) & 0xff00) | \ + (((x) << 8) & 0xff0000) | \ + ((x) << 24))) + +#define IgsByteSwap16(x) ((x) = ((x) << 8) | ((x) >> 8)) + +#define igsPatternDimOk(d) ((d) <= IGS_PATTERN_WIDTH && (((d) & ((d) - 1)) == 0)) + +#if BITMAP_BIT_ORDER == LSBFirst +#define IgsAdjustBits32(b) IgsInvertBits32(b) +#define IgsAdjustBits16(x) IgsInvertBits16(x) +#else +#define IgsAdjustBits32(x) IgsByteSwap32(x) +#define IgsAdjustBits16(x) IgsByteSwap16(x) +#endif + +#define _igsSetSolidRect(cop,alu,pm,pix,cmd) {\ + _igsWaitFull(cop); \ + (cop)->mix = IGS_MAKE_MIX(alu,alu); \ + (cop)->fg = (pix); \ + (cmd) = (IGS_DRAW_T_B | \ + IGS_DRAW_L_R | \ + IGS_DRAW_ALL | \ + IGS_PIXEL_FG | \ + IGS_HBLT_DISABLE | \ + IGS_SRC2_NORMAL | \ + IGS_STEP_PXBLT | \ + IGS_FGS_FG | \ + IGS_BGS_BG); \ +} + +#define _igsSetTiledRect(cop,alu,pm,base,cmd) {\ + _igsWaitFull(cop); \ + (cop)->mix = IGS_MAKE_MIX(alu,alu); \ + (cop)->src1_stride = IGS_PATTERN_WIDTH - 1; \ + (cop)->src1_start = (base); \ + (cmd) = (IGS_DRAW_T_B | \ + IGS_DRAW_L_R | \ + IGS_DRAW_ALL | \ + IGS_PIXEL_TILE | \ + IGS_HBLT_DISABLE | \ + IGS_SRC2_NORMAL | \ + IGS_STEP_PXBLT | \ + IGS_FGS_SRC | \ + IGS_BGS_BG); \ +} + +#define _igsSetStippledRect(cop,alu,pm,pix,base,cmd) {\ + _igsWaitFull(cop); \ + (cop)->mix = IGS_MAKE_MIX(alu,alu); \ + (cop)->src1_start = (base); \ + (cop)->fg = (pix); \ + (cmd) = (IGS_DRAW_T_B | \ + IGS_DRAW_L_R | \ + IGS_DRAW_ALL | \ + IGS_PIXEL_STIP_TRANS | \ + IGS_HBLT_DISABLE | \ + IGS_SRC2_NORMAL | \ + IGS_STEP_PXBLT | \ + IGS_FGS_FG | \ + IGS_BGS_BG); \ +} + +#define _igsSetOpaqueStippledRect(cop,alu,pm,_fg,_bg,base,cmd) {\ + _igsWaitFull(cop); \ + (cop)->mix = IGS_MAKE_MIX(alu,alu); \ + (cop)->src1_start = (base); \ + (cop)->fg = (_fg); \ + (cop)->bg = (_bg); \ + (cmd) = (IGS_DRAW_T_B | \ + IGS_DRAW_L_R | \ + IGS_DRAW_ALL | \ + IGS_PIXEL_STIP_OPAQUE | \ + IGS_HBLT_DISABLE | \ + IGS_SRC2_NORMAL | \ + IGS_STEP_PXBLT | \ + IGS_FGS_FG | \ + IGS_BGS_BG); \ +} + +#define _igsRect(cop,x,y,w,h,cmd) { \ + _igsWaitFull(cop); \ + (cop)->dst_start = (x) + (y) * (cop_stride); \ + (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \ + (cop)->operation = (cmd); \ +} + +#define _igsPatRect(cop,x,y,w,h,cmd) { \ + _igsWaitFull(cop); \ + (cop)->dst_start = (x) + (y) * (cop_stride); \ + (cop)->rotate = IGS_MAKE_ROTATE(x&7,y&7); \ + (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \ + (cop)->operation = (cmd); \ +} + +#define _igsSetBlt(cop,alu,pm,backwards,upsidedown,cmd) { \ + _igsWaitFull(cop); \ + (cop)->mix = IGS_MAKE_MIX(alu,alu); \ + (cop)->src1_stride = cop_stride - 1; \ + (cmd) = (IGS_DRAW_ALL | \ + IGS_PIXEL_FG | \ + IGS_HBLT_DISABLE | \ + IGS_SRC2_NORMAL | \ + IGS_STEP_PXBLT | \ + IGS_FGS_SRC | \ + IGS_BGS_BG); \ + if (backwards) (cmd) |= IGS_DRAW_R_L; \ + if (upsidedown) (cmd) |= IGS_DRAW_B_T; \ +} + +#if 0 +#define _igsPreparePlaneBlt(cop) { \ + _igsReset(cop); \ + (cop)->dst_stride = cop_stride - 1; \ + (cop)->src1_stride = cop_stride - 1; \ + (cop)->src2_stride = cop_stride - 1; \ + (cop)->format = IGS_FORMAT_16BPP; \ + (cop)->src1_start = 0; \ + (cop)->src2_start = 0; \ +} +#else +#define _igsPreparePlaneBlt(cop) +#endif + +#define _igsSetTransparentPlaneBlt(cop,alu,pm,fg_pix,cmd) { \ + _igsWaitIdleEmpty(cop); \ + _igsPreparePlaneBlt(cop); \ + (cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[alu]); \ + (cop)->fg = (fg_pix); \ + (cmd) = (IGS_DRAW_T_B | \ + IGS_DRAW_L_R | \ + IGS_DRAW_ALL | \ + IGS_PIXEL_FG | \ + IGS_HBLT_WRITE_2 | \ + IGS_SRC2_MONO_TRANS | \ + IGS_STEP_TERNARY_PXBLT | \ + IGS_FGS_FG | \ + IGS_BGS_BG); \ +} + +#define _igsSetOpaquePlaneBlt(cop,alu,pm,fg_pix,bg_pix,cmd) { \ + _igsWaitIdleEmpty(cop); \ + _igsPreparePlaneBlt(cop); \ + (cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[alu]); \ + (cop)->fg = (fg_pix); \ + (cop)->bg = (bg_pix); \ + (cmd) = (IGS_DRAW_T_B | \ + IGS_DRAW_L_R | \ + IGS_DRAW_ALL | \ + IGS_PIXEL_FG | \ + IGS_HBLT_WRITE_2 | \ + IGS_SRC2_MONO_OPAQUE | \ + IGS_STEP_TERNARY_PXBLT | \ + IGS_FGS_FG | \ + IGS_BGS_BG); \ +} + +#define _igsPlaneBlt(cop,x,y,w,h,cmd) { \ +/* _igsWaitFull(cop); */ \ + (cop)->dst_start = (x) + (y) * (cop_stride); \ + (cop)->dim = IGS_MAKE_DIM((w)-1,(h)-1); \ + (cop)->operation = (cmd); \ +/* _igsWaitHostBltAck(cop); */ \ +} + +#define _igsBlt(cop,sx,sy,dx,dy,w,h,cmd) { \ + _igsWaitFull(cop); \ + (cop)->dst_start = (dx) + (dy) * cop_stride; \ + (cop)->src1_start = (sx) + (sy) * cop_stride; \ + (cop)->src1_stride = cop_stride - 1; \ + (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \ + (cop)->operation = (cmd); \ +} + +#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3)) + +#endif --- xorg-server-1.4.99.906.orig/hw/kdrive/igs/igscurs.c +++ xorg-server-1.4.99.906/hw/kdrive/igs/igscurs.c @@ -0,0 +1,345 @@ +/* + * Copyright © 2000 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "igs.h" +#include "cursorstr.h" + +#define SetupCursor(s) KdScreenPriv(s); \ + igsCardInfo(pScreenPriv); \ + igsScreenInfo(pScreenPriv); \ + IgsCursor *pCurPriv = &igss->cursor; \ + IgsVga *igsvga = &igsc->igsvga + +static void +_igsMoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CARD8 xoff, yoff; + + x -= pCurPriv->xhot; + xoff = 0; + if (x < 0) + { + xoff = -x; + x = 0; + } + y -= pCurPriv->yhot; + yoff = 0; + if (y < 0) + { + yoff = -y; + y = 0; + } + + igsSet (igsvga, igs_sprite_x, x); + igsSet (igsvga, igs_sprite_preset_x, xoff); + igsSet (igsvga, igs_sprite_y, y); + igsSet (igsvga, igs_sprite_preset_y, yoff); +} + +static void +igsMoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor (pScreen); + + if (!pCurPriv->has_cursor) + return; + + if (!pScreenPriv->enabled) + return; + + _igsMoveCursor (pScreen, x, y); + VgaFlush (&igsvga->card); +} + + +static void +igsSetCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + + igsSetImm (igsvga, igs_cursor_write_index, 0); + igsSetImm (igsvga, igs_cursor_data, pCursor->backRed >> 8); + igsSetImm (igsvga, igs_cursor_data, pCursor->backGreen >> 8); + igsSetImm (igsvga, igs_cursor_data, pCursor->backBlue >> 8); + igsSetImm (igsvga, igs_cursor_write_index, 1); + igsSetImm (igsvga, igs_cursor_data, pCursor->foreRed >> 8); + igsSetImm (igsvga, igs_cursor_data, pCursor->foreGreen >> 8); + igsSetImm (igsvga, igs_cursor_data, pCursor->foreBlue >> 8); +} + +#if BITMAP_BIT_ORDER == MSBFirst +#define IgsAdjustCursor(v) { \ + v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ + v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ + v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ + v = ((v & 0x00ff00ff) << 8) | ((v >> 8) & 0x00ff00ff); \ + v = ((v & 0x0000ffff) <<16) | ((v >>16) & 0x0000ffff); \ +} +#else +#define IgsAdjustCursor(v) +#endif + +#define ExplodeBits2(v) (((v) & 1) | (((v) & 2) << 1)) +#define ExplodeBits4(v) ((ExplodeBits2((v) >> 2) << 4) | \ + (ExplodeBits2((v) & 0x3))) +#define ExplodeBits8(v) ((ExplodeBits4((v) >> 4) << 8) | \ + (ExplodeBits4((v) & 0xf))) +#define ExplodeBits16(v) ((ExplodeBits8((v) >> 8) << 16) | \ + (ExplodeBits8((v) & 0xff))) +static void +igsLoadCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + CursorBitsPtr bits = pCursor->bits; + int w, h; + CARD32 *ram, *msk, *mskLine, *src, *srcLine; + int i, j; + int cursor_address; + int lwsrc; + unsigned char ramdac_control_; + CARD32 offset; + CARD32 b0, b1; + + pCurPriv->pCursor = pCursor; + pCurPriv->xhot = pCursor->bits->xhot; + pCurPriv->yhot = pCursor->bits->yhot; + + /* + * Stick new image into cursor memory + */ + ram = (CARD32 *) igss->cursor_base; + mskLine = (CARD32 *) bits->mask; + srcLine = (CARD32 *) bits->source; + + h = bits->height; + if (h > IGS_CURSOR_HEIGHT) + h = IGS_CURSOR_HEIGHT; + + lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */ + + for (i = 0; i < IGS_CURSOR_HEIGHT; i++) { + msk = mskLine; + src = srcLine; + mskLine += lwsrc; + srcLine += lwsrc; + for (j = 0; j < IGS_CURSOR_WIDTH / 32; j++) { + + CARD32 m, s; + + if (i < h && j < lwsrc) + { + m = *msk++; + s = *src++; + IgsAdjustCursor(m); + IgsAdjustCursor(s); + } + else + { + m = 0; + s = 0; + } + s &= m; + m = ~m; + b0 = ExplodeBits16(s&0xffff) | (ExplodeBits16(m&0xffff)<<1); + b1 = ExplodeBits16(s>>16) | (ExplodeBits16(m>>16)<<1); + *ram++ = b0; + *ram++ = b1; + } + } + + /* Set new color */ + igsSetCursorColors (pScreen); + + /* Set address for cursor bits */ + offset = igss->cursor_offset; + offset >>= 10; + igsSet (igsvga, igs_sprite_addr, offset); + + /* Assume TV interpolation off */ + igsSet (igsvga, igs_hcshf, 3); + /* Enable the cursor */ + igsSet (igsvga, igs_sprite_visible, 1); + igsSet (igsvga, igs_sprite_64x64, 1); + /* Move to new position */ + _igsMoveCursor (pScreen, x, y); + + VgaFlush (&igsvga->card); +} + +static void +igsUnloadCursor (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + /* Disable cursor */ + igsSet (igsvga, igs_sprite_visible, 0); + VgaFlush (&igsvga->card); +} + +static Bool +igsRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + SetupCursor(pScreen); + + if (!pScreenPriv->enabled) + return TRUE; + + /* miRecolorCursor does this */ + if (pCurPriv->pCursor == pCursor) + { + if (pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + igsLoadCursor (pScreen, x, y); + } + } + return TRUE; +} + +static Bool +igsUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + return TRUE; +} + +static void +igsSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +{ + SetupCursor(pScreen); + + pCurPriv->pCursor = pCursor; + + if (!pScreenPriv->enabled) + return; + + if (pCursor) + igsLoadCursor (pScreen, x, y); + else + igsUnloadCursor (pScreen); +} + +miPointerSpriteFuncRec igsPointerSpriteFuncs = { + igsRealizeCursor, + igsUnrealizeCursor, + igsSetCursor, + igsMoveCursor, +}; + +static void +igsQueryBestSize (int class, + unsigned short *pwidth, unsigned short *pheight, + ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + switch (class) + { + case CursorShape: + if (*pwidth > pCurPriv->width) + *pwidth = pCurPriv->width; + if (*pheight > pCurPriv->height) + *pheight = pCurPriv->height; + if (*pwidth > pScreen->width) + *pwidth = pScreen->width; + if (*pheight > pScreen->height) + *pheight = pScreen->height; + break; + default: + fbQueryBestSize (class, pwidth, pheight, pScreen); + break; + } +} + +Bool +igsCursorInit (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!igss->cursor_base) + { + pCurPriv->has_cursor = FALSE; + return FALSE; + } + + pCurPriv->width = IGS_CURSOR_WIDTH; + pCurPriv->height= IGS_CURSOR_HEIGHT; + pScreen->QueryBestSize = igsQueryBestSize; + miPointerInitialize (pScreen, + &igsPointerSpriteFuncs, + &kdPointerScreenFuncs, + FALSE); + pCurPriv->has_cursor = TRUE; + pCurPriv->pCursor = NULL; + return TRUE; +} + +void +igsCursorEnable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + igsLoadCursor (pScreen, x, y); + } + else + igsUnloadCursor (pScreen); + } +} + +void +igsCursorDisable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!pScreenPriv->enabled) + return; + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + igsUnloadCursor (pScreen); + } + } +} + +void +igsCursorFini (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + pCurPriv->pCursor = NULL; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/igs/igsstub.c +++ xorg-server-1.4.99.906/hw/kdrive/igs/igsstub.c @@ -0,0 +1,71 @@ +/* + * Copyright © 2000 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "igs.h" + +void +InitCard (char *name) +{ + KdCardAttr attr; + CARD32 count; + + count = 0; +#ifdef EMBED + attr.address[0] = 0x10000000; /* Adomo Wing video base address */ + attr.io = 0; + attr.naddr = 1; +#else + while (LinuxFindPci (0x10ea, 0x5000, count, &attr)) +#endif + { + KdCardInfoAdd (&igsFuncs, &attr, 0); + count++; + } +} + +void +InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) +{ + KdInitOutput (pScreenInfo, argc, argv); +} + +void +InitInput (int argc, char **argv) +{ + KdOsAddInputDrivers (); + KdInitInput (); +} + +void +ddxUseMsg (void) +{ + KdUseMsg (); +} + +int +ddxProcessArgument (int argc, char **argv, int i) +{ + return KdProcessArgument (argc, argv, i); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/igs/igscmap.c +++ xorg-server-1.4.99.906/hw/kdrive/igs/igscmap.c @@ -0,0 +1,62 @@ +/* + * Copyright © 2000 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "igs.h" + +#define IGS_DAC_SHIFT 8 +void +igsGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) +{ + KdScreenPriv(pScreen); + igsCardInfo(pScreenPriv); + IgsVga *igsvga = &igsc->igsvga; + + while (ndef--) + { + igsSetImm (igsvga, igs_dac_read_index, pdefs->pixel); + pdefs->red = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT; + pdefs->green = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT; + pdefs->blue = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT; + pdefs++; + } +} + +void +igsPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) +{ + KdScreenPriv(pScreen); + igsCardInfo(pScreenPriv); + IgsVga *igsvga = &igsc->igsvga; + + while (ndef--) + { + igsSetImm (igsvga, igs_dac_write_index, pdefs->pixel); + igsSetImm (igsvga, igs_dac_data, pdefs->red >> IGS_DAC_SHIFT); + igsSetImm (igsvga, igs_dac_data, pdefs->green >> IGS_DAC_SHIFT); + igsSetImm (igsvga, igs_dac_data, pdefs->blue >> IGS_DAC_SHIFT); + pdefs++; + } +} + --- xorg-server-1.4.99.906.orig/hw/kdrive/igs/igsdraw.c +++ xorg-server-1.4.99.906/hw/kdrive/igs/igsdraw.c @@ -0,0 +1,1463 @@ +/* + * Copyright © 2000 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "igs.h" +#include "igsdraw.h" + +#include "Xmd.h" +#include "gcstruct.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "regionstr.h" +#include "mistruct.h" +#include "fontstruct.h" +#include "dixfontstr.h" +#include "fb.h" +#include "migc.h" +#include "miline.h" + +CARD8 igsPatRop[16] = { + /* GXclear */ 0x00, /* 0 */ + /* GXand */ 0xa0, /* src AND dst */ + /* GXandReverse */ 0x50, /* src AND NOT dst */ + /* GXcopy */ 0xf0, /* src */ + /* GXandInverted*/ 0x0a, /* NOT src AND dst */ + /* GXnoop */ 0xaa, /* dst */ + /* GXxor */ 0x5a, /* src XOR dst */ + /* GXor */ 0xfa, /* src OR dst */ + /* GXnor */ 0x05, /* NOT src AND NOT dst */ + /* GXequiv */ 0xa5, /* NOT src XOR dst */ + /* GXinvert */ 0x55, /* NOT dst */ + /* GXorReverse */ 0xf5, /* src OR NOT dst */ + /* GXcopyInverted*/ 0x0f, /* NOT src */ + /* GXorInverted */ 0xaf, /* NOT src OR dst */ + /* GXnand */ 0x5f, /* NOT src OR NOT dst */ + /* GXset */ 0xff, /* 1 */ +}; + +/* + * Handle pixel transfers + */ + +#define BURST +#ifdef BURST +#define PixTransDeclare VOL32 *pix_trans_base = igsc->copData,\ + *pix_trans = pix_trans_base +#define PixTransStart(n) if (pix_trans + (n) > pix_trans_base + 16384) pix_trans = pix_trans_base +#define PixTransStore(t) *pix_trans++ = (t) +#else +#define PixTransDeclare VOL32 *pix_trans = igsc->copData +#define PixTransStart(n) +#define PixTransStore(t) *pix_trans = (t) +#endif + +static IgsPattern * +igsSetPattern (ScreenPtr pScreen, + PixmapPtr pPixmap, + CARD8 fillStyle, + INT32 xrot, + INT32 yrot) +{ + KdScreenPriv(pScreen); + igsCardInfo(pScreenPriv); + igsScreenInfo(pScreenPriv); + int i; + IgsPatternCache *c; + IgsPattern *p; + + if (fillStyle == FillTiled) + c = &igss->tile; + else + c = &igss->stipple; + for (i = 0; i < IGS_NUM_PATTERN; i++) + { + p = &c->pattern[i]; + if (p->serial_number == pPixmap->drawable.serialNumber && + p->xrot == xrot && + p->yrot == yrot) + { + return p; + } + } + p = &c->pattern[c->next]; + if (++c->next == IGS_NUM_PATTERN) + c->next = 0; + p->serial_number = pPixmap->drawable.serialNumber; + p->xrot = xrot; + p->yrot = yrot; + + if (fillStyle != FillTiled) + { + FbStip *pix; + FbStride pixStride; + int pixBpp; + int pixXoff, pixYoff; + CARD8 tmp[8]; + CARD32 *pat; + int stipX, stipY; + int y; + FbStip bits; + + fbGetStipDrawable (&pPixmap->drawable, pix, pixStride, pixBpp, pixXoff, pixYoff); + + modulus (-yrot - pixYoff, pPixmap->drawable.height, stipY); + modulus (-xrot - pixXoff, FB_UNIT, stipX); + + pat = (CARD32 *) p->base; + + for (y = 0; y < 8; y++) + { + bits = pix[stipY * pixStride]; + FbRotLeft (bits, stipX); + tmp[y] = (CARD8) bits; + stipY++; + if (stipY == pPixmap->drawable.height) + stipY = 0; + } + for (i = 0; i < 2; i++) + { + bits = (tmp[i*4+0] | + (tmp[i*4+1] << 8) | + (tmp[i*4+2] << 16) | + (tmp[i*4+3] << 24)); + IgsAdjustBits32 (bits); + *pat++ = bits; + } + } + else + { + FbBits *pix; + FbStride pixStride; + int pixBpp; + FbBits *pat; + FbStride patStride; + int patBpp; + int patXoff, patYoff; + + fbGetDrawable (&pPixmap->drawable, pix, pixStride, pixBpp, patXoff, patYoff); + + pat = (FbBits *) p->base; + patBpp = pixBpp; + patStride = (patBpp * IGS_PATTERN_WIDTH) / (8 * sizeof (FbBits)); + + fbTile (pat, patStride, 0, + patBpp * IGS_PATTERN_WIDTH, IGS_PATTERN_HEIGHT, + + pix, pixStride, + pPixmap->drawable.width * pixBpp, + pPixmap->drawable.height, + GXcopy, FB_ALLONES, pixBpp, + (xrot - patXoff) * pixBpp, yrot - patYoff); + } + return p; +} + +void +igsFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, + unsigned long pixel, int alu, unsigned long planemask) +{ + SetupIgs(pDrawable->pScreen); + CARD32 cmd; + + _igsSetSolidRect(cop,alu,planemask,pixel,cmd); + while (nBox--) + { + _igsRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd); + pBox++; + } + KdMarkSync (pDrawable->pScreen); +} + +void +igsFillBoxTiled (DrawablePtr pDrawable, int nBox, BoxPtr pBox, + PixmapPtr pPixmap, int xrot, int yrot, int alu) +{ + SetupIgs(pDrawable->pScreen); + CARD32 cmd; + IgsPattern *p = igsSetPattern (pDrawable->pScreen, + pPixmap, + FillTiled, + xrot, yrot); + + _igsSetTiledRect(cop,alu,planemask,p->offset,cmd); + while (nBox--) + { + _igsPatRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd); + pBox++; + } + KdMarkSync (pDrawable->pScreen); +} + +void +igsFillBoxStippled (DrawablePtr pDrawable, GCPtr pGC, + int nBox, BoxPtr pBox) +{ + SetupIgs(pDrawable->pScreen); + CARD32 cmd; + int xrot = pGC->patOrg.x + pDrawable->x; + int yrot = pGC->patOrg.y + pDrawable->y; + IgsPattern *p = igsSetPattern (pDrawable->pScreen, + pGC->stipple, + pGC->fillStyle, + xrot, yrot); + if (pGC->fillStyle == FillStippled) + { + _igsSetStippledRect (cop,pGC->alu,planemask,pGC->fgPixel,p->offset,cmd); + } + else + { + _igsSetOpaqueStippledRect (cop,pGC->alu,planemask, + pGC->fgPixel,pGC->bgPixel,p->offset,cmd); + } + while (nBox--) + { + _igsPatRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd); + pBox++; + } + KdMarkSync (pDrawable->pScreen); +} + + +void +igsStipple (ScreenPtr pScreen, + CARD32 cmd, + FbStip *psrcBase, + FbStride widthSrc, + int srcx, + int srcy, + int dstx, + int dsty, + int width, + int height) +{ + SetupIgs(pScreen); + FbStip *psrcLine, *psrc; + FbStride widthRest; + FbStip bits, tmp, lastTmp; + int leftShift, rightShift; + int nl, nlMiddle; + int r; + PixTransDeclare; + + /* Compute blt address and parameters */ + psrc = psrcBase + srcy * widthSrc + (srcx >> 5); + nlMiddle = (width + 31) >> 5; + leftShift = srcx & 0x1f; + rightShift = 32 - leftShift; + widthRest = widthSrc - nlMiddle; + + _igsPlaneBlt(cop,dstx,dsty,width,height,cmd); + + if (leftShift == 0) + { + while (height--) + { + nl = nlMiddle; + PixTransStart(nl); + while (nl--) + { + tmp = *psrc++; + IgsAdjustBits32 (tmp); + PixTransStore (tmp); + } + psrc += widthRest; + } + } + else + { + widthRest--; + while (height--) + { + bits = *psrc++; + nl = nlMiddle; + PixTransStart(nl); + while (nl--) + { + tmp = FbStipLeft(bits, leftShift); + bits = *psrc++; + tmp |= FbStipRight(bits, rightShift); + IgsAdjustBits32(tmp); + PixTransStore (tmp); + } + psrc += widthRest; + } + } +} + +void +igsCopyNtoN (DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pbox, + int nbox, + int dx, + int dy, + Bool reverse, + Bool upsidedown, + Pixel bitplane, + void *closure) +{ + SetupIgs(pDstDrawable->pScreen); + int srcX, srcY, dstX, dstY; + int w, h; + CARD32 flags; + CARD32 cmd; + CARD8 alu; + + if (pGC) + { + alu = pGC->alu; + if (sourceInvarient (pGC->alu)) + { + igsFillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu, pGC->planemask); + return; + } + } + else + alu = GXcopy; + + _igsSetBlt(cop,alu,pGC->planemask,reverse,upsidedown,cmd); + while (nbox--) + { + w = pbox->x2 - pbox->x1; + h = pbox->y2 - pbox->y1; + if (reverse) + dstX = pbox->x2 - 1; + else + dstX = pbox->x1; + srcX = dstX + dx; + + if (upsidedown) + dstY = pbox->y2 - 1; + else + dstY = pbox->y1; + + srcY = dstY + dy; + + _igsBlt (cop, srcX, srcY, dstX, dstY, w, h, cmd); + pbox++; + } + KdMarkSync (pDstDrawable->pScreen); +} + +RegionPtr +igsCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, + int srcx, int srcy, int width, int height, int dstx, int dsty) +{ + KdScreenPriv(pDstDrawable->pScreen); + FbBits depthMask; + + depthMask = FbFullMask (pDstDrawable->depth); + if ((pGC->planemask & depthMask) == depthMask && + pSrcDrawable->type == DRAWABLE_WINDOW && + pDstDrawable->type == DRAWABLE_WINDOW) + { + return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, + dstx, dsty, igsCopyNtoN, 0, 0); + } + return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, dstx, dsty); +} + +typedef struct _igs1toNargs { + unsigned long copyPlaneFG, copyPlaneBG; + Bool opaque; +} igs1toNargs; + +void +igsCopy1toN (DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pbox, + int nbox, + int dx, + int dy, + Bool reverse, + Bool upsidedown, + Pixel bitplane, + void *closure) +{ + SetupIgs(pDstDrawable->pScreen); + + igs1toNargs *args = closure; + int dstx, dsty; + FbStip *psrcBase; + FbStride widthSrc; + int srcBpp; + int srcXoff, srcYoff; + CARD32 cmd; + + if (args->opaque && sourceInvarient (pGC->alu)) + { + igsFillBoxSolid (pDstDrawable, nbox, pbox, + pGC->bgPixel, pGC->alu, pGC->planemask); + return; + } + + fbGetStipDrawable (pSrcDrawable, psrcBase, widthSrc, srcBpp, srcXoff, srcYoff); + + if (args->opaque) + { + _igsSetOpaquePlaneBlt (cop, pGC->alu, pGC->planemask, args->copyPlaneFG, + args->copyPlaneBG, cmd); + } + else + { + _igsSetTransparentPlaneBlt (cop, pGC->alu, pGC->planemask, + args->copyPlaneFG, cmd); + } + + while (nbox--) + { + dstx = pbox->x1; + dsty = pbox->y1; + + igsStipple (pDstDrawable->pScreen, cmd, + psrcBase, widthSrc, + dstx + dx - srcXoff, dsty + dy - srcYoff, + dstx, dsty, + pbox->x2 - dstx, pbox->y2 - dsty); + pbox++; + } + KdMarkSync (pDstDrawable->pScreen); +} + +RegionPtr +igsCopyPlane (DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + int srcx, + int srcy, + int width, + int height, + int dstx, + int dsty, + unsigned long bitPlane) +{ + RegionPtr ret; + igs1toNargs args; + FbBits depthMask; + + depthMask = FbFullMask (pDstDrawable->depth); + if ((pGC->planemask & depthMask) == depthMask && + pDstDrawable->type == DRAWABLE_WINDOW && + pSrcDrawable->depth == 1) + { + args.copyPlaneFG = pGC->fgPixel; + args.copyPlaneBG = pGC->bgPixel; + args.opaque = TRUE; + return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, + dstx, dsty, igsCopy1toN, bitPlane, &args); + } + return KdCheckCopyPlane(pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, + dstx, dsty, bitPlane); +} + +#if 0 +/* would you believe this is slower than fb? */ +void +igsPushPixels (GCPtr pGC, + PixmapPtr pBitmap, + DrawablePtr pDrawable, + int w, + int h, + int x, + int y) +{ + igs1toNargs args; + FbBits depthMask; + + depthMask = FbFullMask (pDstDrawable->depth); + if ((pGC->planemask & depthMask) == depthMask && + pDrawable->type == DRAWABLE_WINDOW && + pGC->fillStyle == FillSolid) + { + args.opaque = FALSE; + args.copyPlaneFG = pGC->fgPixel; + (void) fbDoCopy ((DrawablePtr) pBitmap, pDrawable, pGC, + 0, 0, w, h, x, y, igsCopy1toN, 1, &args); + } + else + { + KdCheckPushPixels (pGC, pBitmap, pDrawable, w, h, x, y); + } +} +#else +#define igsPushPixels KdCheckPushPixels +#endif + +BOOL +igsFillOk (GCPtr pGC) +{ + FbBits depthMask; + + depthMask = FbFullMask(pGC->depth); + if ((pGC->planemask & depthMask) != depthMask) + return FALSE; + switch (pGC->fillStyle) { + case FillSolid: + return TRUE; + case FillTiled: + return (igsPatternDimOk (pGC->tile.pixmap->drawable.width) && + igsPatternDimOk (pGC->tile.pixmap->drawable.height)); + case FillStippled: + case FillOpaqueStippled: + return (igsPatternDimOk (pGC->stipple->drawable.width) && + igsPatternDimOk (pGC->stipple->drawable.height)); + } + return FALSE; +} + +void +igsFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n, + DDXPointPtr ppt, int *pwidth, int fSorted) +{ + SetupIgs(pDrawable->pScreen); + DDXPointPtr pptFree; + FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); + int *pwidthFree;/* copies of the pointers to free */ + CARD32 cmd; + int nTmp; + INT16 x, y; + int width; + IgsPattern *p; + + if (!igsFillOk (pGC)) + { + KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted); + return; + } + nTmp = n * miFindMaxBand(fbGetCompositeClip(pGC)); + pwidthFree = (int *)xalloc(nTmp * sizeof(int)); + pptFree = (DDXPointRec *)xalloc(nTmp * sizeof(DDXPointRec)); + if(!pptFree || !pwidthFree) + { + if (pptFree) xfree(pptFree); + if (pwidthFree) xfree(pwidthFree); + return; + } + n = miClipSpans(fbGetCompositeClip(pGC), + ppt, pwidth, n, + pptFree, pwidthFree, fSorted); + pwidth = pwidthFree; + ppt = pptFree; + switch (pGC->fillStyle) { + case FillSolid: + _igsSetSolidRect(cop,pGC->alu,pGC->planemask,pGC->fgPixel,cmd); + break; + case FillTiled: + p = igsSetPattern (pDrawable->pScreen, + pGC->tile.pixmap, + FillTiled, + pGC->patOrg.x + pDrawable->x, + pGC->patOrg.y + pDrawable->y); + _igsSetTiledRect (cop,pGC->alu,pGC->planemask,p->offset,cmd); + break; + default: + p = igsSetPattern (pDrawable->pScreen, + pGC->stipple, + pGC->fillStyle, + pGC->patOrg.x + pDrawable->x, + pGC->patOrg.y + pDrawable->y); + if (pGC->fillStyle == FillStippled) + { + _igsSetStippledRect (cop,pGC->alu,pGC->planemask, + pGC->fgPixel,p->offset,cmd); + } + else + { + _igsSetOpaqueStippledRect (cop,pGC->alu,pGC->planemask, + pGC->fgPixel,pGC->bgPixel,p->offset,cmd); + } + break; + } + while (n--) + { + x = ppt->x; + y = ppt->y; + ppt++; + width = *pwidth++; + if (width) + { + _igsPatRect(cop,x,y,width,1,cmd); + } + } + xfree(pptFree); + xfree(pwidthFree); + KdMarkSync (pDrawable->pScreen); +} + +#define NUM_STACK_RECTS 1024 + +void +igsPolyFillRect (DrawablePtr pDrawable, GCPtr pGC, + int nrectFill, xRectangle *prectInit) +{ + SetupIgs(pDrawable->pScreen); + xRectangle *prect; + RegionPtr prgnClip; + register BoxPtr pbox; + register BoxPtr pboxClipped; + BoxPtr pboxClippedBase; + BoxPtr pextent; + BoxRec stackRects[NUM_STACK_RECTS]; + FbGCPrivPtr fbPriv = fbGetGCPrivate (pGC); + int numRects; + int n; + int xorg, yorg; + int x, y; + + if (!igsFillOk (pGC)) + { + KdCheckPolyFillRect (pDrawable, pGC, nrectFill, prectInit); + return; + } + prgnClip = fbGetCompositeClip (pGC); + xorg = pDrawable->x; + yorg = pDrawable->y; + + if (xorg || yorg) + { + prect = prectInit; + n = nrectFill; + while(n--) + { + prect->x += xorg; + prect->y += yorg; + prect++; + } + } + + prect = prectInit; + + numRects = REGION_NUM_RECTS(prgnClip) * nrectFill; + if (numRects > NUM_STACK_RECTS) + { + pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec)); + if (!pboxClippedBase) + return; + } + else + pboxClippedBase = stackRects; + + pboxClipped = pboxClippedBase; + + if (REGION_NUM_RECTS(prgnClip) == 1) + { + int x1, y1, x2, y2, bx2, by2; + + pextent = REGION_RECTS(prgnClip); + x1 = pextent->x1; + y1 = pextent->y1; + x2 = pextent->x2; + y2 = pextent->y2; + while (nrectFill--) + { + if ((pboxClipped->x1 = prect->x) < x1) + pboxClipped->x1 = x1; + + if ((pboxClipped->y1 = prect->y) < y1) + pboxClipped->y1 = y1; + + bx2 = (int) prect->x + (int) prect->width; + if (bx2 > x2) + bx2 = x2; + pboxClipped->x2 = bx2; + + by2 = (int) prect->y + (int) prect->height; + if (by2 > y2) + by2 = y2; + pboxClipped->y2 = by2; + + prect++; + if ((pboxClipped->x1 < pboxClipped->x2) && + (pboxClipped->y1 < pboxClipped->y2)) + { + pboxClipped++; + } + } + } + else + { + int x1, y1, x2, y2, bx2, by2; + + pextent = REGION_EXTENTS(pGC->pScreen, prgnClip); + x1 = pextent->x1; + y1 = pextent->y1; + x2 = pextent->x2; + y2 = pextent->y2; + while (nrectFill--) + { + BoxRec box; + + if ((box.x1 = prect->x) < x1) + box.x1 = x1; + + if ((box.y1 = prect->y) < y1) + box.y1 = y1; + + bx2 = (int) prect->x + (int) prect->width; + if (bx2 > x2) + bx2 = x2; + box.x2 = bx2; + + by2 = (int) prect->y + (int) prect->height; + if (by2 > y2) + by2 = y2; + box.y2 = by2; + + prect++; + + if ((box.x1 >= box.x2) || (box.y1 >= box.y2)) + continue; + + n = REGION_NUM_RECTS (prgnClip); + pbox = REGION_RECTS(prgnClip); + + /* clip the rectangle to each box in the clip region + this is logically equivalent to calling Intersect() + */ + while(n--) + { + pboxClipped->x1 = max(box.x1, pbox->x1); + pboxClipped->y1 = max(box.y1, pbox->y1); + pboxClipped->x2 = min(box.x2, pbox->x2); + pboxClipped->y2 = min(box.y2, pbox->y2); + pbox++; + + /* see if clipping left anything */ + if(pboxClipped->x1 < pboxClipped->x2 && + pboxClipped->y1 < pboxClipped->y2) + { + pboxClipped++; + } + } + } + } + if (pboxClipped != pboxClippedBase) + { + switch (pGC->fillStyle) { + case FillSolid: + igsFillBoxSolid(pDrawable, + pboxClipped-pboxClippedBase, pboxClippedBase, + pGC->fgPixel, pGC->alu, pGC->planemask); + break; + case FillTiled: + igsFillBoxTiled(pDrawable, + pboxClipped-pboxClippedBase, pboxClippedBase, + pGC->tile.pixmap, + pGC->patOrg.x + pDrawable->x, + pGC->patOrg.y + pDrawable->y, + pGC->alu); + break; + case FillStippled: + case FillOpaqueStippled: + igsFillBoxStippled (pDrawable, pGC, + pboxClipped-pboxClippedBase, pboxClippedBase); + break; + } + } + if (pboxClippedBase != stackRects) + xfree(pboxClippedBase); +} + +int +igsTextInRegion (GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppci) +{ + int w; + FontPtr pfont = pGC->font; + BoxRec bbox; + + if (FONTCONSTMETRICS(pfont)) + w = FONTMAXBOUNDS(pfont,characterWidth) * nglyph; + else + { + w = 0; + while (nglyph--) + w += (*ppci++)->metrics.characterWidth; + } + if (w < 0) + { + bbox.x1 = x + w; + bbox.x2 = x; + } + else + { + bbox.x1 = x; + bbox.x2 = x + w; + } + w = FONTMINBOUNDS(pfont,leftSideBearing); + if (w < 0) + bbox.x1 += w; + w = FONTMAXBOUNDS(pfont, rightSideBearing) - FONTMINBOUNDS(pfont, characterWidth); + if (w > 0) + bbox.x2 += w; + bbox.y1 = y - FONTMAXBOUNDS(pfont,ascent); + bbox.y2 = y + FONTMAXBOUNDS(pfont,descent); + + return RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox); +} + +void +igsGlyphBltClipped (DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppciInit, + Bool image) +{ + SetupIgs(pDrawable->pScreen); + CARD32 cmd; + int h; + int w; + int xBack, yBack; + int hBack, wBack; + int lw; + FontPtr pfont = pGC->font; + CharInfoPtr pci; + unsigned long *bits; + BoxPtr extents; + BoxRec bbox; + CARD32 b; + CharInfoPtr *ppci; + FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); + RegionPtr pClip = fbGetCompositeClip(pGC); + BoxPtr pBox; + int nbox; + int x1, y1, x2, y2; + unsigned char alu; + Bool set; + PixTransDeclare; + + if (image) + { + xBack = x; + yBack = y - FONTASCENT(pGC->font); + wBack = 0; + hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); + if (hBack) + { + h = nglyph; + ppci = ppciInit; + while (h--) + wBack += (*ppci++)->metrics.characterWidth; + } + if (wBack < 0) + { + xBack = xBack + wBack; + wBack = -wBack; + } + if (hBack < 0) + { + yBack = yBack + hBack; + hBack = -hBack; + } + alu = GXcopy; + if (wBack) + { + _igsSetSolidRect (cop, GXcopy, pGC->planemask, pGC->bgPixel, cmd); + for (nbox = REGION_NUM_RECTS (pClip), + pBox = REGION_RECTS (pClip); + nbox--; + pBox++) + { + x1 = xBack; + x2 = xBack + wBack; + y1 = yBack; + y2 = yBack + hBack; + if (x1 < pBox->x1) x1 = pBox->x1; + if (x2 > pBox->x2) x2 = pBox->x2; + if (y1 < pBox->y1) y1 = pBox->y1; + if (y2 > pBox->y2) y2 = pBox->y2; + if (x1 < x2 && y1 < y2) + { + _igsRect (cop, x1, y1, x2 - x1, y2 - y1, cmd); + } + } + KdMarkSync (pDrawable->pScreen); + } + } + else + { + wBack = 0; + alu = pGC->alu; + } + + ppci = ppciInit; + set = FALSE; + while (nglyph--) + { + pci = *ppci++; + h = pci->metrics.ascent + pci->metrics.descent; + w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; + x1 = x + pci->metrics.leftSideBearing; + y1 = y - pci->metrics.ascent; + bbox.x1 = x1; + bbox.y1 = y1; + bbox.x2 = x1 + w; + bbox.y2 = y1 + h; + switch (RECT_IN_REGION(pGC->pScreen, pClip, &bbox)) + { + case rgnIN: + lw = h * ((w + 31) >> 5); + if (lw) + { + if (!set) + { + _igsSetTransparentPlaneBlt (cop, alu, pGC->planemask, pGC->fgPixel, cmd); + set = TRUE; + } + _igsPlaneBlt(cop, + x + pci->metrics.leftSideBearing, + y - pci->metrics.ascent, + w, h, cmd); + bits = (unsigned long *) pci->bits; + PixTransStart (lw); + while (lw--) + { + b = *bits++; + IgsAdjustBits32 (b); + PixTransStore(b); + } + KdMarkSync (pDrawable->pScreen); + } + break; + case rgnPART: + set = FALSE; + KdCheckSync (pDrawable->pScreen); + fbPutXYImage (pDrawable, + pClip, + fbPriv->fg, + fbPriv->bg, + fbPriv->pm, + alu, + FALSE, + x1, y1, + w, h, + (FbStip *) pci->bits, + (w + 31) >> 5, + 0); + break; + case rgnOUT: + break; + } + x += pci->metrics.characterWidth; + } +} + +void +igsGlyphBlt (DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppciInit, + Bool image) +{ + SetupIgs(pDrawable->pScreen); + CARD32 cmd; + int h; + int w; + int xBack, yBack; + int hBack, wBack; + int lw; + FontPtr pfont = pGC->font; + CharInfoPtr pci; + unsigned long *bits; + BoxPtr extents; + BoxRec bbox; + CARD32 b; + CharInfoPtr *ppci; + unsigned char alu; + PixTransDeclare; + + /* + * Paint background for image text + */ + if (image) + { + xBack = x; + yBack = y - FONTASCENT(pGC->font); + wBack = 0; + hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); + if (hBack) + { + h = nglyph; + ppci = ppciInit; + while (h--) + wBack += (*ppci++)->metrics.characterWidth; + } + if (wBack < 0) + { + xBack = xBack + wBack; + wBack = -wBack; + } + if (hBack < 0) + { + yBack = yBack + hBack; + hBack = -hBack; + } + alu = GXcopy; + if (wBack) + { + _igsSetSolidRect (cop, GXcopy, pGC->planemask, pGC->bgPixel, cmd); + _igsRect (cop, xBack, yBack, wBack, hBack, cmd); + } + } + else + { + wBack = 0; + alu = pGC->alu; + } + + _igsSetTransparentPlaneBlt (cop, alu, pGC->planemask, pGC->fgPixel, cmd); + ppci = ppciInit; + while (nglyph--) + { + pci = *ppci++; + h = pci->metrics.ascent + pci->metrics.descent; + w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; + lw = h * ((w + 31) >> 5); + if (lw) + { + _igsPlaneBlt(cop, + x + pci->metrics.leftSideBearing, + y - pci->metrics.ascent, + w, h, cmd); + bits = (unsigned long *) pci->bits; + PixTransStart(lw); + while (lw--) + { + b = *bits++; + IgsAdjustBits32 (b); + PixTransStore(b); + } + } + x += pci->metrics.characterWidth; + } + KdMarkSync (pDrawable->pScreen); +} + +void +igsTEGlyphBlt (DrawablePtr pDrawable, + GCPtr pGC, + int xInit, + int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + Bool image) +{ + SetupIgs(pDrawable->pScreen); + CARD32 cmd; + int x, y; + int h, lw, lwTmp; + int w; + FontPtr pfont = pGC->font; + unsigned long *char1, *char2, *char3, *char4; + int widthGlyphs, widthGlyph; + BoxRec bbox; + CARD32 tmp; + PixTransDeclare; + + widthGlyph = FONTMAXBOUNDS(pfont,characterWidth); + if (!widthGlyph) + return; + + h = FONTASCENT(pfont) + FONTDESCENT(pfont); + if (!h) + return; + + x = xInit + FONTMAXBOUNDS(pfont,leftSideBearing); + y = yInit - FONTASCENT(pfont); + + if (image) + { + _igsSetOpaquePlaneBlt (cop, GXcopy, pGC->planemask, pGC->fgPixel, pGC->bgPixel, cmd); + } + else + { + _igsSetTransparentPlaneBlt (cop, pGC->alu, pGC->planemask, pGC->fgPixel, cmd); + } + +#if BITMAP_BIT_ORDER == LSBFirst +#define SHIFT << +#else +#define SHIFT >> +#endif + +#define LoopIt(count, w, loadup, fetch) \ + while (nglyph >= count) \ + { \ + nglyph -= count; \ + _igsPlaneBlt (cop, x, y, w, h, cmd); \ + x += w; \ + loadup \ + lwTmp = h; \ + PixTransStart(h); \ + while (lwTmp--) { \ + tmp = fetch; \ + IgsAdjustBits32(tmp); \ + PixTransStore(tmp); \ + } \ + } + + if (widthGlyph <= 8) + { + widthGlyphs = widthGlyph << 2; + LoopIt(4, widthGlyphs, + char1 = (unsigned long *) (*ppci++)->bits; + char2 = (unsigned long *) (*ppci++)->bits; + char3 = (unsigned long *) (*ppci++)->bits; + char4 = (unsigned long *) (*ppci++)->bits;, + (*char1++ | ((*char2++ | ((*char3++ | (*char4++ + SHIFT widthGlyph)) + SHIFT widthGlyph)) + SHIFT widthGlyph))) + } + else if (widthGlyph <= 10) + { + widthGlyphs = (widthGlyph << 1) + widthGlyph; + LoopIt(3, widthGlyphs, + char1 = (unsigned long *) (*ppci++)->bits; + char2 = (unsigned long *) (*ppci++)->bits; + char3 = (unsigned long *) (*ppci++)->bits;, + (*char1++ | ((*char2++ | (*char3++ SHIFT widthGlyph)) SHIFT widthGlyph))) + } + else if (widthGlyph <= 16) + { + widthGlyphs = widthGlyph << 1; + LoopIt(2, widthGlyphs, + char1 = (unsigned long *) (*ppci++)->bits; + char2 = (unsigned long *) (*ppci++)->bits;, + (*char1++ | (*char2++ SHIFT widthGlyph))) + } + lw = h * ((widthGlyph + 31) >> 5); + while (nglyph--) + { + _igsPlaneBlt (cop, x, y, widthGlyph, h, cmd); + x += widthGlyph; + char1 = (unsigned long *) (*ppci++)->bits; + lwTmp = lw; + PixTransStart(lw); + while (lwTmp--) + { + tmp = *char1++; + IgsAdjustBits32(tmp); + PixTransStore(tmp); + } + } + KdMarkSync (pDrawable->pScreen); +} + +/* + * Blt glyphs using image transfer window + */ + +void +igsPolyGlyphBlt (DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase) +{ + if (pGC->fillStyle != FillSolid || + fbGetGCPrivate(pGC)->pm != FB_ALLONES) + { + KdCheckPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); + return; + } + x += pDrawable->x; + y += pDrawable->y; + + switch (igsTextInRegion (pGC, x, y, nglyph, ppci)) { + case rgnIN: + if (TERMINALFONT(pGC->font)) + igsTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE); + else + igsGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE); + break; + case rgnPART: + igsGlyphBltClipped (pDrawable, pGC, x, y, nglyph, ppci, FALSE); + break; + case rgnOUT: + break; + } +} + +void +igsImageGlyphBlt (DrawablePtr pDrawable, + GCPtr pGC, + int x, int y, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase) +{ + if (fbGetGCPrivate(pGC)->pm != FB_ALLONES) + { + KdCheckImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); + return; + } + x += pDrawable->x; + y += pDrawable->y; + + switch (igsTextInRegion (pGC, x, y, nglyph, ppci)) { + case rgnIN: + if (TERMINALFONT(pGC->font)) + igsTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE); + else + igsGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE); + break; + case rgnPART: + igsGlyphBltClipped (pDrawable, pGC, x, y, nglyph, ppci, TRUE); + break; + case rgnOUT: + break; + } +} + +static void +igsInvalidatePattern (IgsPatternCache *c, + PixmapPtr pPixmap) +{ + int i; + + if (c->base) + { + for (i = 0; i < IGS_NUM_PATTERN; i++) + { + if (c->pattern[i].serial_number == pPixmap->drawable.serialNumber) + c->pattern[i].serial_number = ~0; + } + } +} + +static void +igsInitPattern (IgsPatternCache *c, int bsize, int psize) +{ + int i; + int boffset; + int poffset; + + for (i = 0; i < IGS_NUM_PATTERN; i++) + { + boffset = i * bsize; + poffset = i * psize; + c->pattern[i].xrot = -1; + c->pattern[i].yrot = -1; + c->pattern[i].serial_number = ~0; + c->pattern[i].offset = c->offset + poffset; + c->pattern[i].base = c->base + boffset; + } + c->next = 0; +} + +static const GCOps igsOps = { + igsFillSpans, + KdCheckSetSpans, + KdCheckPutImage, + igsCopyArea, + igsCopyPlane, + KdCheckPolyPoint, + KdCheckPolylines, + KdCheckPolySegment, + miPolyRectangle, + KdCheckPolyArc, + miFillPolygon, + igsPolyFillRect, + KdCheckPolyFillArc, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + igsImageGlyphBlt, + igsPolyGlyphBlt, + igsPushPixels, +}; + +void +igsValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) +{ + FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); + + fbValidateGC (pGC, changes, pDrawable); + + if (pDrawable->type == DRAWABLE_WINDOW) + pGC->ops = (GCOps *) &igsOps; + else + pGC->ops = (GCOps *) &fbGCOps; +} + +GCFuncs igsGCFuncs = { + igsValidateGC, + miChangeGC, + miCopyGC, + miDestroyGC, + miChangeClip, + miDestroyClip, + miCopyClip +}; + +int +igsCreateGC (GCPtr pGC) +{ + if (!fbCreateGC (pGC)) + return FALSE; + + if (pGC->depth != 1) + pGC->funcs = &igsGCFuncs; + + return TRUE; +} + +void +igsCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + KdScreenPriv(pScreen); + RegionRec rgnDst; + int dx, dy; + WindowPtr pwinRoot; + + pwinRoot = WindowTable[pWin->drawable.pScreen->myNum]; + + dx = ptOldOrg.x - pWin->drawable.x; + dy = ptOldOrg.y - pWin->drawable.y; + REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy); + + REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0); + + REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc); + + fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, + 0, + &rgnDst, dx, dy, igsCopyNtoN, 0, 0); + + REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); +} + + +Bool +igsDrawInit (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + igsCardInfo(pScreenPriv); + igsScreenInfo(pScreenPriv); + int i; + int pattern_size; + int boffset, poffset; + + KdScreenInitAsync (pScreen); + + /* + * Replace various fb screen functions + */ + pScreen->CreateGC = igsCreateGC; + pScreen->CopyWindow = igsCopyWindow; + + /* + * Initialize patterns + */ + if (igss->tile.base) + { + pattern_size = IgsTileSize(pScreenPriv->screen->fb[0].bitsPerPixel); + igsInitPattern (&igss->tile, + pattern_size, + pattern_size * 8 / pScreenPriv->screen->fb[0].bitsPerPixel); + pattern_size = IgsStippleSize(pScreenPriv->screen->fb[0].bitsPerPixel); + igsInitPattern (&igss->stipple, + pattern_size, + pattern_size * 8 / pScreenPriv->screen->fb[0].bitsPerPixel); + } + return TRUE; +} + +void +igsDrawEnable (ScreenPtr pScreen) +{ + SetupIgs(pScreen); + CARD32 cmd; + CARD32 base; + CARD16 stride; + CARD32 format; + + stride = pScreenPriv->screen->fb[0].pixelStride; + _igsWaitIdleEmpty(cop); + _igsReset(cop); + switch (pScreenPriv->screen->fb[0].bitsPerPixel) { + case 8: + format = IGS_FORMAT_8BPP; + break; + case 16: + format = IGS_FORMAT_16BPP; + break; + case 24: + format = IGS_FORMAT_24BPP; + break; + case 32: + format = IGS_FORMAT_32BPP; + break; + } + cop->format = format; + cop->dst_stride = stride - 1; + cop->src1_stride = stride - 1; + cop->src2_stride = stride - 1; + cop->src1_start = 0; + cop->src2_start = 0; + cop->extension |= IGS_BLOCK_COP_REG | IGS_BURST_ENABLE; + + _igsSetSolidRect(cop, GXcopy, ~0, pScreen->blackPixel, cmd); + _igsRect (cop, 0, 0, + pScreenPriv->screen->width, pScreenPriv->screen->height, + cmd); + _igsWaitIdleEmpty (cop); +} + +void +igsDrawDisable (ScreenPtr pScreen) +{ +} + +void +igsDrawFini (ScreenPtr pScreen) +{ +} + +void +igsDrawSync (ScreenPtr pScreen) +{ + SetupIgs(pScreen); + + _igsWaitIdleEmpty(cop); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/igs/igsreg.c +++ xorg-server-1.4.99.906/hw/kdrive/igs/igsreg.c @@ -0,0 +1,969 @@ +/* + * Copyright © 2000 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "igsreg.h" +#include + +#define CR00 IGS_CR+0x00 +#define CR01 IGS_CR+0x01 +#define CR02 IGS_CR+0x02 +#define CR03 IGS_CR+0x03 +#define CR04 IGS_CR+0x04 +#define CR05 IGS_CR+0x05 +#define CR06 IGS_CR+0x06 +#define CR07 IGS_CR+0x07 +#define CR08 IGS_CR+0x08 +#define CR09 IGS_CR+0x09 +#define CR0A IGS_CR+0x0A +#define CR0B IGS_CR+0x0B +#define CR0C IGS_CR+0x0C +#define CR0D IGS_CR+0x0D +#define CR0E IGS_CR+0x0E +#define CR0F IGS_CR+0x0F +#define CR10 IGS_CR+0x10 +#define CR11 IGS_CR+0x11 +#define CR12 IGS_CR+0x12 +#define CR13 IGS_CR+0x13 +#define CR14 IGS_CR+0x14 +#define CR15 IGS_CR+0x15 +#define CR16 IGS_CR+0x16 +#define CR17 IGS_CR+0x17 +#define CR18 IGS_CR+0x18 +#define CR19 IGS_CR+0x19 +#define CR1A IGS_CR+0x1A +#define CR1B IGS_CR+0x1B +#define CR1C IGS_CR+0x1C +#define CR1D IGS_CR+0x1D +#define CR1E IGS_CR+0x1E +#define CR1F IGS_CR+0x1F +#define CR20 IGS_CR+0x20 +#define CR21 IGS_CR+0x21 +#define CR22 IGS_CR+0x22 +#define CR23 IGS_CR+0x23 +#define CR24 IGS_CR+0x24 +#define CR25 IGS_CR+0x25 +#define CR26 IGS_CR+0x26 +#define CR27 IGS_CR+0x27 +#define CR28 IGS_CR+0x28 +#define CR29 IGS_CR+0x29 +#define CR2A IGS_CR+0x2A +#define CR2B IGS_CR+0x2B +#define CR2C IGS_CR+0x2C +#define CR2D IGS_CR+0x2D +#define CR2E IGS_CR+0x2E +#define CR2F IGS_CR+0x2F +#define CR30 IGS_CR+0x30 +#define CR31 IGS_CR+0x31 +#define CR32 IGS_CR+0x32 +#define CR33 IGS_CR+0x33 +#define CR34 IGS_CR+0x34 +#define CR35 IGS_CR+0x35 +#define CR36 IGS_CR+0x36 +#define CR37 IGS_CR+0x37 +#define CR38 IGS_CR+0x38 +#define CR39 IGS_CR+0x39 +#define CR3A IGS_CR+0x3A +#define CR3B IGS_CR+0x3B +#define CR3C IGS_CR+0x3C +#define CR3D IGS_CR+0x3D +#define CR3E IGS_CR+0x3E +#define CR3F IGS_CR+0x3F +#define CR40 IGS_CR+0x40 +#define CR41 IGS_CR+0x41 +#define CR42 IGS_CR+0x42 +#define CR43 IGS_CR+0x43 +#define CR44 IGS_CR+0x44 +#define CR45 IGS_CR+0x45 +#define CR46 IGS_CR+0x46 +#define CR47 IGS_CR+0x47 +#define CR48 IGS_CR+0x48 + +#define CR_FIRST CR00 +#define CR_LAST CR48 + +#define SR00 IGS_SR+0x00 +#define SR01 IGS_SR+0x01 +#define SR02 IGS_SR+0x02 +#define SR03 IGS_SR+0x03 +#define SR04 IGS_SR+0x04 + +#define SR_FIRST SR00 +#define SR_LAST SR04 + +#define AR00 IGS_AR+0x00 +#define AR01 IGS_AR+0x01 +#define AR02 IGS_AR+0x02 +#define AR03 IGS_AR+0x03 +#define AR04 IGS_AR+0x04 +#define AR05 IGS_AR+0x05 +#define AR06 IGS_AR+0x06 +#define AR07 IGS_AR+0x07 +#define AR08 IGS_AR+0x08 +#define AR09 IGS_AR+0x09 +#define AR0A IGS_AR+0x0A +#define AR0B IGS_AR+0x0B +#define AR0C IGS_AR+0x0C +#define AR0D IGS_AR+0x0D +#define AR0E IGS_AR+0x0E +#define AR0F IGS_AR+0x0F +#define AR10 IGS_AR+0x10 +#define AR11 IGS_AR+0x11 +#define AR12 IGS_AR+0x12 +#define AR13 IGS_AR+0x13 +#define AR14 IGS_AR+0x14 + +#define AR_FIRST AR00 +#define AR_LAST AR14 + +#define GR00 IGS_GR+0x00 +#define GR01 IGS_GR+0x01 +#define GR02 IGS_GR+0x02 +#define GR03 IGS_GR+0x03 +#define GR04 IGS_GR+0x04 +#define GR05 IGS_GR+0x05 +#define GR06 IGS_GR+0x06 +#define GR07 IGS_GR+0x07 +#define GR08 IGS_GR+0x08 +#define GR09 IGS_GR+0x09 +#define GR0A IGS_GR+0x0A +#define GR0B IGS_GR+0x0B +#define GR0C IGS_GR+0x0C +#define GR0D IGS_GR+0x0D +#define GR0E IGS_GR+0x0E +#define GR0F IGS_GR+0x0F +#define GR10 IGS_GR+0x10 +#define GR11 IGS_GR+0x11 +#define GR12 IGS_GR+0x12 +#define GR13 IGS_GR+0x13 +#define GR14 IGS_GR+0x14 +#define GR15 IGS_GR+0x15 +#define GR16 IGS_GR+0x16 +#define GR17 IGS_GR+0x17 +#define GR18 IGS_GR+0x18 +#define GR19 IGS_GR+0x19 +#define GR1A IGS_GR+0x1A +#define GR1B IGS_GR+0x1B +#define GR1C IGS_GR+0x1C +#define GR1D IGS_GR+0x1D +#define GR1E IGS_GR+0x1E +#define GR1F IGS_GR+0x1F +#define GR20 IGS_GR+0x20 +#define GR21 IGS_GR+0x21 +#define GR22 IGS_GR+0x22 +#define GR23 IGS_GR+0x23 +#define GR24 IGS_GR+0x24 +#define GR25 IGS_GR+0x25 +#define GR26 IGS_GR+0x26 +#define GR27 IGS_GR+0x27 +#define GR28 IGS_GR+0x28 +#define GR29 IGS_GR+0x29 +#define GR2A IGS_GR+0x2A +#define GR2B IGS_GR+0x2B +#define GR2C IGS_GR+0x2C +#define GR2D IGS_GR+0x2D +#define GR2E IGS_GR+0x2E +#define GR2F IGS_GR+0x2F +#define GR30 IGS_GR+0x30 +#define GR31 IGS_GR+0x31 +#define GR32 IGS_GR+0x32 +#define GR33 IGS_GR+0x33 +#define GR34 IGS_GR+0x34 +#define GR35 IGS_GR+0x35 +#define GR36 IGS_GR+0x36 +#define GR37 IGS_GR+0x37 +#define GR38 IGS_GR+0x38 +#define GR39 IGS_GR+0x39 +#define GR3A IGS_GR+0x3A +#define GR3B IGS_GR+0x3B +#define GR3C IGS_GR+0x3C +#define GR3D IGS_GR+0x3D +#define GR3E IGS_GR+0x3E +#define GR3F IGS_GR+0x3F +#define GR40 IGS_GR+0x40 +#define GR41 IGS_GR+0x41 +#define GR42 IGS_GR+0x42 +#define GR43 IGS_GR+0x43 +#define GR44 IGS_GR+0x44 +#define GR45 IGS_GR+0x45 +#define GR46 IGS_GR+0x46 +#define GR47 IGS_GR+0x47 +#define GR48 IGS_GR+0x48 +#define GR49 IGS_GR+0x49 +#define GR4A IGS_GR+0x4A +#define GR4B IGS_GR+0x4B +#define GR4C IGS_GR+0x4C +#define GR4D IGS_GR+0x4D +#define GR4E IGS_GR+0x4E +#define GR4F IGS_GR+0x4F +#define GR50 IGS_GR+0x50 +#define GR51 IGS_GR+0x51 +#define GR52 IGS_GR+0x52 +#define GR53 IGS_GR+0x53 +#define GR54 IGS_GR+0x54 +#define GR55 IGS_GR+0x55 +#define GR56 IGS_GR+0x56 +#define GR57 IGS_GR+0x57 +#define GR58 IGS_GR+0x58 +#define GR59 IGS_GR+0x59 +#define GR5A IGS_GR+0x5A +#define GR5B IGS_GR+0x5B +#define GR5C IGS_GR+0x5C +#define GR5D IGS_GR+0x5D +#define GR5E IGS_GR+0x5E +#define GR5F IGS_GR+0x5F +#define GR60 IGS_GR+0x60 +#define GR61 IGS_GR+0x61 +#define GR62 IGS_GR+0x62 +#define GR63 IGS_GR+0x63 +#define GR64 IGS_GR+0x64 +#define GR65 IGS_GR+0x65 +#define GR66 IGS_GR+0x66 +#define GR67 IGS_GR+0x67 +#define GR68 IGS_GR+0x68 +#define GR69 IGS_GR+0x69 +#define GR6A IGS_GR+0x6A +#define GR6B IGS_GR+0x6B +#define GR6C IGS_GR+0x6C +#define GR6D IGS_GR+0x6D +#define GR6E IGS_GR+0x6E +#define GR6F IGS_GR+0x6F +#define GR70 IGS_GR+0x70 +#define GR71 IGS_GR+0x71 +#define GR72 IGS_GR+0x72 +#define GR73 IGS_GR+0x73 +#define GR74 IGS_GR+0x74 +#define GR75 IGS_GR+0x75 +#define GR76 IGS_GR+0x76 +#define GR77 IGS_GR+0x77 +#define GR78 IGS_GR+0x78 +#define GR79 IGS_GR+0x79 +#define GR7A IGS_GR+0x7A +#define GR7B IGS_GR+0x7B +#define GR7C IGS_GR+0x7C +#define GR7D IGS_GR+0x7D +#define GR7E IGS_GR+0x7E +#define GR7F IGS_GR+0x7F +#define GR80 IGS_GR+0x80 +#define GR81 IGS_GR+0x81 +#define GR82 IGS_GR+0x82 +#define GR83 IGS_GR+0x83 +#define GR84 IGS_GR+0x84 +#define GR85 IGS_GR+0x85 +#define GR86 IGS_GR+0x86 +#define GR87 IGS_GR+0x87 +#define GR88 IGS_GR+0x88 +#define GR89 IGS_GR+0x89 +#define GR8A IGS_GR+0x8A +#define GR8B IGS_GR+0x8B +#define GR8C IGS_GR+0x8C +#define GR8D IGS_GR+0x8D +#define GR8E IGS_GR+0x8E +#define GR8F IGS_GR+0x8F +#define GR90 IGS_GR+0x90 +#define GR91 IGS_GR+0x91 +#define GR92 IGS_GR+0x92 +#define GR93 IGS_GR+0x93 +#define GR94 IGS_GR+0x94 +#define GR95 IGS_GR+0x95 +#define GR96 IGS_GR+0x96 +#define GR97 IGS_GR+0x97 +#define GR98 IGS_GR+0x98 +#define GR99 IGS_GR+0x99 +#define GR9A IGS_GR+0x9A +#define GR9B IGS_GR+0x9B +#define GR9C IGS_GR+0x9C +#define GR9D IGS_GR+0x9D +#define GR9E IGS_GR+0x9E +#define GR9F IGS_GR+0x9F +#define GRA0 IGS_GR+0xA0 +#define GRA1 IGS_GR+0xA1 +#define GRA2 IGS_GR+0xA2 +#define GRA3 IGS_GR+0xA3 +#define GRA4 IGS_GR+0xA4 +#define GRA5 IGS_GR+0xA5 +#define GRA6 IGS_GR+0xA6 +#define GRA7 IGS_GR+0xA7 +#define GRA8 IGS_GR+0xA8 +#define GRA9 IGS_GR+0xA9 +#define GRAA IGS_GR+0xAA +#define GRAB IGS_GR+0xAB +#define GRAC IGS_GR+0xAC +#define GRAD IGS_GR+0xAD +#define GRAE IGS_GR+0xAE +#define GRAF IGS_GR+0xAF +#define GRB0 IGS_GR+0xB0 +#define GRB1 IGS_GR+0xB1 +#define GRB2 IGS_GR+0xB2 +#define GRB3 IGS_GR+0xB3 +#define GRB4 IGS_GR+0xB4 +#define GRB5 IGS_GR+0xB5 +#define GRB6 IGS_GR+0xB6 +#define GRB7 IGS_GR+0xB7 +#define GRB8 IGS_GR+0xB8 +#define GRB9 IGS_GR+0xB9 +#define GRBA IGS_GR+0xBA +#define GRBB IGS_GR+0xBB +#define GRBC IGS_GR+0xBC +#define GRBD IGS_GR+0xBD +#define GRBE IGS_GR+0xBE +#define GRBF IGS_GR+0xBF + +#define GR_FIRST GR00 +#define GR_LAST GRBF + +#define GREX3C IGS_GREX+(0x3c-IGS_GREXBASE) + +VgaReg igs_h_total[] = { + CR00, 0, 8, + VGA_REG_END +}; + +VgaReg igs_h_de_end[] = { + CR01, 0, 8, + VGA_REG_END +}; + +VgaReg igs_h_bstart[] = { + CR02, 0, 8, + VGA_REG_END +}; + +VgaReg igs_h_bend[] = { + CR03, 0, 5, + CR05, 7, 1, + VGA_REG_END +}; + +VgaReg igs_de_skew[] = { + CR03, 5, 2, + VGA_REG_END +}; + +VgaReg igs_ena_vr_access[] = { + CR03, 7, 1, + VGA_REG_END +}; + +VgaReg igs_h_rstart[] = { + CR04, 0, 8, + VGA_REG_END +}; + +VgaReg igs_h_rend[] = { + CR05, 0, 5, + VGA_REG_END +}; + +VgaReg igs_h_rdelay[] = { + CR05, 5, 2, + VGA_REG_END +}; + +VgaReg igs_v_total[] = { + CR06, 0, 8, + CR07, 0, 1, + CR07, 5, 1, + GR11, 0, 1, + VGA_REG_END +}; + +VgaReg igs_v_rstart[] = { + CR10, 0, 8, + CR07, 2, 1, + CR07, 7, 1, + GR11, 2, 1, + VGA_REG_END +}; + +VgaReg igs_v_rend[] = { + CR11, 0, 4, + VGA_REG_END +}; + +VgaReg igs_clear_v_int[] = { + CR11, 4, 1, + VGA_REG_END +}; + +VgaReg igs_disable_v_int[] = { + CR11, 5, 1, + VGA_REG_END +}; + +VgaReg igs_bandwidth[] = { + CR11, 6, 1, + VGA_REG_END +}; + +VgaReg igs_crt_protect[] = { + CR11, 7, 1, + VGA_REG_END +}; + +VgaReg igs_v_de_end[] = { + CR12, 0, 8, + CR07, 1, 1, + CR07, 6, 1, + GR11, 1, 1, + VGA_REG_END +}; + +VgaReg igs_offset[] = { + CR13, 0, 8, + GR15, 4, 2, + VGA_REG_END +}; + +VgaReg igs_v_bstart[] = { + CR15, 0, 8, + CR07, 3, 1, + CR09, 5, 1, + GR11, 3, 1, + VGA_REG_END +}; + +VgaReg igs_v_bend[] = { + CR16, 0, 7, + VGA_REG_END +}; + +VgaReg igs_linecomp[] = { + CR18, 0, 8, + CR07, 4, 1, + CR09, 6, 1, + GR11, 4, 1, + VGA_REG_END +}; + +VgaReg igs_ivideo[] = { + GR11, 5, 1, + VGA_REG_END +}; + +VgaReg igs_num_fetch[] = { + GR14, 0, 8, + GR15, 0, 2, + VGA_REG_END +}; + +VgaReg igs_wcrt0[] = { + CR1F, 0, 1, + VGA_REG_END +}; + +VgaReg igs_wcrt1[] = { + CR1F, 1, 1, + VGA_REG_END +}; + +VgaReg igs_rcrts1[] = { + CR1F, 4, 1, + VGA_REG_END +}; + +VgaReg igs_selwk[] = { + CR1F, 6, 1, + VGA_REG_END +}; + +VgaReg igs_dot_clock_8[] = { + SR01, 0, 1, + VGA_REG_END +}; + +VgaReg igs_screen_off[] = { + SR01, 5, 1, + VGA_REG_END +}; + +VgaReg igs_enable_write_plane[] = { + SR02, 0, 4, + VGA_REG_END +}; + +VgaReg igs_mexhsyn[] = { + GR16, 0, 2, + VGA_REG_END +}; + +VgaReg igs_mexvsyn[] = { + GR16, 2, 2, + VGA_REG_END +}; + +VgaReg igs_pci_burst_write[] = { + GR30, 5, 1, + VGA_REG_END +}; + +VgaReg igs_pci_burst_read[] = { + GR30, 7, 1, + VGA_REG_END +}; + +VgaReg igs_iow_retry[] = { + GREX3C, 0, 1, + VGA_REG_END +}; + +VgaReg igs_mw_retry[] = { + GREX3C, 1, 1, + VGA_REG_END +}; + +VgaReg igs_mr_retry[] = { + GREX3C, 2, 1, + VGA_REG_END +}; + + + +VgaReg igs_biga22en[] = { + GR3D, 4, 1, + VGA_REG_END +}; + +VgaReg igs_biga24en[] = { + GR3D, 5, 1, + VGA_REG_END +}; + +VgaReg igs_biga22force[] = { + GR3D, 6, 1, + VGA_REG_END +}; + +VgaReg igs_bigswap[] = { + GR3F, 0, 6, + VGA_REG_END +}; + +/* #define IGS_BIGSWAP_8 0x3f */ +/* #define IGS_BIGSWAP_16 0x2a */ +/* #define IGS_BIGSWAP_32 0x00 */ + +VgaReg igs_sprite_x[] = { + GR50, 0, 8, + GR51, 0, 3, + VGA_REG_END +}; + +VgaReg igs_sprite_preset_x[] = { + GR52, 0, 6, + VGA_REG_END +}; + +VgaReg igs_sprite_y[] = { + GR53, 0, 8, + GR54, 0, 3, + VGA_REG_END +}; + +VgaReg igs_sprite_preset_y[] = { + GR55, 0, 6, + VGA_REG_END +}; + +VgaReg igs_sprite_visible[] = { + GR56, 0, 1, + VGA_REG_END +}; + +VgaReg igs_sprite_64x64[] = { + GR56, 1, 1, + VGA_REG_END +}; + +VgaReg igs_mgrext[] = { + GR57, 0, 1, + VGA_REG_END +}; + +VgaReg igs_hcshf[] = { + GR57, 4, 2, + VGA_REG_END +}; + +VgaReg igs_mbpfix[] = { + GR57, 6, 2, + VGA_REG_END +}; + +VgaReg igs_overscan_red[] = { + GR58, 0, 8, + VGA_REG_END +}; + +VgaReg igs_overscan_green[] = { + GR59, 0, 8, + VGA_REG_END +}; + +VgaReg igs_overscan_blue[] = { + GR5A, 0, 8, + VGA_REG_END +}; + +VgaReg igs_memgopg[] = { + GR73, 2, 1, + VGA_REG_END +}; + +VgaReg igs_memr2wpg[] = { + GR73, 1, 1, + VGA_REG_END +}; + +VgaReg igs_crtff16[] = { + GR73, 3, 1, + VGA_REG_END +}; + +VgaReg igs_fifomust[] = { + GR74, 0, 5, + VGA_REG_END +}; + +VgaReg igs_fifogen[] = { + GR75, 0, 5, + VGA_REG_END +}; + +VgaReg igs_mode_sel[] = { + GR77, 0, 4, + VGA_REG_END +}; + +/* #define IGS_MODE_TEXT 0 */ +/* #define IGS_MODE_8 1 */ +/* #define IGS_MODE_565 2 */ +/* #define IGS_MODE_5551 6 */ +/* #define IGS_MODE_8888 3 */ +/* #define IGS_MODE_888 4 */ +/* #define IGS_MODE_332 9 */ +/* #define IGS_MODE_4444 10 */ + +VgaReg igs_sprite_addr[] = { + GR7E, 0, 8, + GR7F, 0, 4, + VGA_REG_END +}; + +VgaReg igs_fastmpie[] = { + GR9E, 0, 1, + VGA_REG_END +}; + +VgaReg igs_vclk_m[] = { + GRB0, 0, 8, + GRBA, 0, 3, + VGA_REG_END +}; + +VgaReg igs_vclk_n[] = { + GRB1, 0, 5, + GRBA, 3, 3, + VGA_REG_END +}; + +VgaReg igs_vfsel[] = { + GRB1, 5, 1, + VGA_REG_END +}; + +VgaReg igs_vclk_p[] = { + GRB1, 6, 2, + GRBA, 6, 1, + VGA_REG_END +}; + +VgaReg igs_frqlat[] = { + GRB9, 7, 1, + VGA_REG_END +}; + + +VgaReg igs_dac_mask[] = { + IGS_DAC + 0, 0, 8, + VGA_REG_END +}; + +VgaReg igs_dac_read_index[] = { + IGS_DAC + 1, 0, 8, + VGA_REG_END +}; + +VgaReg igs_dac_write_index[] = { + IGS_DAC + 2, 0, 8, + VGA_REG_END +}; + +VgaReg igs_dac_data[] = { + IGS_DAC + 3, 0, 8, + VGA_REG_END +}; + +VgaReg igs_rampwdn[] = { + IGS_DACEX + 0, 0, 1, + VGA_REG_END +}; + +VgaReg igs_dac6_8[] = { + IGS_DACEX + 0, 1, 1, + VGA_REG_END +}; + +VgaReg igs_ramdacbypass[] = { + IGS_DACEX + 0, 4, 1, + VGA_REG_END +}; + +VgaReg igs_dacpwdn[] = { + IGS_DACEX + 0, 6, 1, + VGA_REG_END +}; + +VgaReg igs_cursor_read_index[] = { + IGS_DACEX + 1, 0, 8, + VGA_REG_END +}; + +VgaReg igs_cursor_write_index[] = { + IGS_DACEX + 2, 0, 8, + VGA_REG_END +}; + +VgaReg igs_cursor_data[] = { + IGS_DACEX + 3, 0, 8, + VGA_REG_END +}; + +VGA8 +_igsInb (VgaCard *card, VGA16 port) +{ + VGAVOL8 *reg; + + if (card->closure) + return VgaReadMemb ((VGA32) card->closure + port); + else + return VgaInb (port); +} + +void +_igsOutb (VgaCard *card, VGA8 value, VGA16 port) +{ + if (card->closure) + VgaWriteMemb (value, (VGA32) card->closure + port); + else + VgaOutb (value, port); +} + +void +_igsRegMap (VgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write) +{ + if (reg < IGS_SR + IGS_NSR) + { + map->access = VgaAccessIndIo; + map->port = 0x3c4; + map->addr = 0; + map->value = 1; + map->index = reg - IGS_SR; + } + else if (reg < IGS_GR + IGS_NGR) + { + map->access = VgaAccessIndIo; + map->port = 0x3ce; + map->addr = 0; + map->value = 1; + map->index = reg - IGS_GR; + } + else if (reg < IGS_GREX + IGS_NGREX) + { + VGA8 gr33; + + map->access = VgaAccessDone; + _igsOutb (card, 0x33, 0x3ce); + gr33 = _igsInb (card, 0x3cf); + _igsOutb (card, gr33 | 0x40, 0x3cf); + _igsOutb (card, IGS_GREXBASE + reg - IGS_GREX, 0x3ce); + if (write) + _igsOutb (card, map->value, 0x3cf); + else + map->value = _igsInb (card, 0x3cf); + _igsOutb (card, 0x33, 0x3ce); + _igsOutb (card, gr33, 0x3cf); + return; + } + else if (reg < IGS_AR + IGS_NAR) + { + reg -= IGS_AR; + map->access = VgaAccessDone; + /* reset AFF to index */ + (void) _igsInb (card, 0x3da); + if (reg >= 16) + reg |= 0x20; + _igsOutb (card, reg, 0x3c0); + if (write) + _igsOutb (card, map->value, 0x3c0); + else + map->value = _igsInb (card, 0x3c1); + if (!(reg & 0x20)) + { + /* enable video display again */ + (void) _igsInb (card, 0x3da); + _igsOutb (card, 0x20, 0x3c0); + } + return; + } + else if (reg < IGS_CR + IGS_NCR) + { + map->access = VgaAccessIndIo; + map->port = 0x3d4; + map->addr = 0; + map->value = 1; + map->index = reg - IGS_CR; + } + else if (reg < IGS_DAC + IGS_NDAC) + { + map->access = VgaAccessIo; + map->port = 0x3c6 + reg - IGS_DAC; + } + else if (reg < IGS_DACEX + IGS_NDACEX) + { + VGA8 gr56; + reg = 0x3c6 + reg - IGS_DACEX; + map->access = VgaAccessDone; + _igsOutb (card, 0x56, 0x3ce); + gr56 = _igsInb (card, 0x3cf); + _igsOutb (card, gr56 | 4, 0x3cf); + if (write) + _igsOutb (card, map->value, reg); + else + map->value = _igsInb (card, reg); + _igsOutb (card, gr56, 0x3cf); + return; + } + else switch (reg) { + case IGS_MISC_OUT: + map->access = VgaAccessIo; + if (write) + map->port = 0x3c2; + else + map->port = 0x3cc; + break; + case IGS_INPUT_STATUS_1: + map->access = VgaAccessIo; + map->port = 0x3da; + break; + } + if (card->closure) + { + map->port = map->port + (VGA32) card->closure; + if (map->access == VgaAccessIo) + map->access = VgaAccessMem; + if (map->access == VgaAccessIndIo) + map->access = VgaAccessIndMem; + } +} + +VgaSave igsSaves[] = { + CR00, CR18, + SR01, SR02, + GR11, GRBA, + IGS_MISC_OUT, IGS_MISC_OUT, + VGA_SAVE_END +}; + +void +igsRegInit (IgsVga *igsvga, VGAVOL8 *mmio) +{ + igsvga->card.map = _igsRegMap; + igsvga->card.closure = (void *) mmio; + igsvga->card.max = IGS_NREG; + igsvga->card.values = igsvga->values; + igsvga->card.saves = igsSaves; +} + +void +igsSave (IgsVga *igsvga) +{ + igsSetImm (igsvga, igs_wcrt0, 1); + igsSetImm (igsvga, igs_wcrt1, 1); + igsSetImm (igsvga, igs_rcrts1, 1); + igsSetImm (igsvga, igs_selwk, 1); + VgaPreserve (&igsvga->card); +} + +void +igsReset (IgsVga *igsvga) +{ + VgaRestore (&igsvga->card); + igsSetImm (igsvga, igs_frqlat, 0); + igsSetImm (igsvga, igs_frqlat, 1); + igsSetImm (igsvga, igs_frqlat, 0); + VgaFinish (&igsvga->card); +} + +char * +igsRegName(char *buf, VGA16 reg) +{ + if (reg < IGS_SR + IGS_NSR) + { + sprintf (buf, " SR%02X", reg - IGS_SR); + } + else if (reg < IGS_GR + IGS_NGR) + { + sprintf (buf, " GR%02X", reg - IGS_GR); + } + else if (reg < IGS_GREX + IGS_NGREX) + { + sprintf (buf, " GRX%02X", reg - IGS_GREX + IGS_GREXBASE); + } + else if (reg < IGS_AR + IGS_NAR) + { + sprintf (buf, " AR%02X", reg - IGS_AR); + } + else if (reg < IGS_CR + IGS_NCR) + { + sprintf (buf, " CR%02X", reg - IGS_CR); + } + else if (reg < IGS_DAC + IGS_NDAC) + { + sprintf (buf, " DAC%02X", reg - IGS_DAC); + } + else if (reg < IGS_DACEX + IGS_NDACEX) + { + sprintf (buf, "DACX%02X", reg - IGS_DACEX); + } + else switch (reg) { + case IGS_MISC_OUT: + sprintf (buf, "MISC_O"); + break; + case IGS_INPUT_STATUS_1: + sprintf (buf, "IN_S_1"); + break; + } + return buf; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/Xkdrive.man +++ xorg-server-1.4.99.906/hw/kdrive/Xkdrive.man @@ -0,0 +1,77 @@ +.\" $RCSId: xc/programs/Xserver/hw/kdrive/Xkdrive.man,v 1.3 2001/01/24 00:06:10 dawes Exp $ +.\" +.TH Xkdrive 1 __vendorversion__ +.SH NAME +Xkdrive \- tiny X server +.SH SYNOPSIS +.B Xvesa +.RI [ :display ] +.RI [ option ...] + +.B Xfbdev +.RI [ :display ] +.RI [ option ...] + +.B Xigs +.RI [ :display ] +.RI [ option ...] + +.B Xtrident +.RI [ :display ] +.RI [ option ...] + +.B Xsis530 +.RI [ :display ] +.RI [ option ...] + +.B Xtrio +.RI [ :display ] +.RI [ option ...] + +.B Xitsy +.RI [ :display ] +.RI [ option ...] +.SH DESCRIPTION +.B Xkdrive +is a family of X servers designed to be particularly small. This +manual page describes the common functionality of the +.B Xkdrive +servers; for information on a specific X server, please refer to the +relevant manual page. +.SH OPTIONS +In addition to the standard options accepted by all X servers (see +Xserver(1)), all the +.B Xkdrive +servers accept the following options: +.TP 8 +.B -card \fIpcmcia\fP +use pcmcia card as additional screen. +.TP 8 +.B -dumb +disable hardware acceleration. +.TP 8 +.B -origin \fIX\fP,\fIY\fP +Locates the next screen in the Xinerama virtual screen. +.TP 8 +.B -screen \fIwidth\fBx\fIheight\fR[\fBx\fIdepth\fR[\fBx\fIfreq\fR]]\fR[\fB@\fIrotation\fR]\fB +use a screen of the specified \fIwidth\fP, \fIheight\fP, screen \fIdepth\fP, \fIfrequency\fP, and \fIrotation\fP (0, 90, 180 and 270 are legal values). +.TP 8 +.B -softCursor +disable the hardware cursor. +.TP 8 +.B -videoTest +start the server, pause momentarily, and exit. +.TP 8 +.B -zaphod +disable switching screens by moving the pointer across a screen boundary. +.TP 8 +.B -2button +enable emulation of a middle mouse button by chording. +.TP 8 +.B -3button +disable emulation of a middle mouse button by chording. +.SH SEE ALSO +X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1), Xvesa(1), Xfbdev(1). +.SH AUTHORS +The Xkdrive common core was written by Keith Packard, +and is based on the Sample Implementation of X. --- xorg-server-1.4.99.906.orig/hw/kdrive/ephyr/ephyrproxyext.c +++ xorg-server-1.4.99.906/hw/kdrive/ephyr/ephyrproxyext.c @@ -0,0 +1,119 @@ +/* + * Xephyr - A kdrive X server thats runs in a host X window. + * Authored by Matthew Allum + * + * Copyright © 2007 OpenedHand Ltd + * + * 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 OpenedHand Ltd not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. OpenedHand Ltd makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL OpenedHand Ltd 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. + * + * Authors: + * Dodji Seketeli + */ + +/* + * \file + * This file defines a proxy extension that forwards requests. + * When a request to extension FOO is sent to Xephyr, that request is forwared + * to the host X, without even trying to know what the request means. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "ephyrproxyext.h" +#define _HAVE_XALLOC_DECLS +#include "ephyrlog.h" +#include "ephyrhostproxy.h" +#include "hostx.h" + +static Bool ephyrProxyGetHostExtensionInfo (const char *a_ext_name, + int *a_major_opcode, + int *a_first_event, + int *a_first_error) ; + +static int ephyrProxyProcDispatch (ClientPtr client) ; + +static Bool +ephyrProxyGetHostExtensionInfo (const char *a_ext_name, + int *a_major_opcode, + int *a_first_event, + int *a_first_error) +{ + return hostx_get_extension_info (a_ext_name, a_major_opcode, + a_first_event, a_first_error) ; +} + +static int +ephyrProxyProcDispatch (ClientPtr a_client) +{ + int res=BadImplementation ; + struct XReply reply ; + + if (!ephyrHostProxyDoForward (a_client->requestBuffer, &reply, FALSE)) { + EPHYR_LOG_ERROR ("forwarding failed\n") ; + goto out ; + } + reply.sequence_number = a_client->sequence; + res = Success ; + + WriteToClient(a_client, 32, (char *)&reply); + +out: + return res ; +} + +static void +ephyrProxyProcReset (ExtensionEntry *a_entry) +{ +} + +Bool +ephyrProxyExtensionInit (const char *a_extension_name) +{ + Bool is_ok = FALSE ; + int major_opcode=0, first_event=0, first_error=0; + ExtensionEntry *ext=NULL ; + + if (!ephyrProxyGetHostExtensionInfo (a_extension_name, + &major_opcode, + &first_event, + &first_error)) { + EPHYR_LOG ("failed to query extension %s from host\n", a_extension_name) ; + goto out; + } + ext = AddExtension ((char*)a_extension_name, 0, 0, + ephyrProxyProcDispatch, + ephyrProxyProcDispatch, + ephyrProxyProcReset, + StandardMinorOpcode) ; + if (!ext) { + EPHYR_LOG_ERROR ("failed to add the extension\n") ; + goto out ; + } + is_ok = TRUE ; + +out: + EPHYR_LOG ("leave\n") ; + return is_ok ; +} + --- xorg-server-1.4.99.906.orig/hw/kdrive/ephyr/GL/internal/dri_interface.h +++ xorg-server-1.4.99.906/hw/kdrive/ephyr/GL/internal/dri_interface.h @@ -0,0 +1,517 @@ +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * (C) Copyright IBM Corporation 2004 + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS 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. + */ + +/** + * \file dri_interface.h + * + * This file contains all the types and functions that define the interface + * between a DRI driver and driver loader. Currently, the most common driver + * loader is the XFree86 libGL.so. However, other loaders do exist, and in + * the future the server-side libglx.a will also be a loader. + * + * \author Kevin E. Martin + * \author Ian Romanick + */ + +#ifndef DRI_INTERFACE_H +#define DRI_INTERFACE_H + +#include +#include + +/** + * \name DRI interface structures + * + * The following structures define the interface between the GLX client + * side library and the DRI (direct rendering infrastructure). + */ +/*@{*/ +typedef struct __DRIdisplayRec __DRIdisplay; +typedef struct __DRIscreenRec __DRIscreen; +typedef struct __DRIcontextRec __DRIcontext; +typedef struct __DRIdrawableRec __DRIdrawable; +typedef struct __DRIdriverRec __DRIdriver; +typedef struct __DRIframebufferRec __DRIframebuffer; +typedef struct __DRIversionRec __DRIversion; +typedef struct __DRIinterfaceMethodsRec __DRIinterfaceMethods; +typedef unsigned long __DRIid; +typedef void __DRInativeDisplay; +/*@}*/ + + +/** + * \name Functions provided by the driver loader. + */ +/*@{*/ +/** + * Type of a pointer to \c glXGetScreenDriver, as returned by + * \c glXGetProcAddress. This function is used to get the name of the DRI + * driver for the specified screen of the specified display. The driver + * name is typically used with \c glXGetDriverConfig. + * + * \sa glXGetScreenDriver, glXGetProcAddress, glXGetDriverConfig + */ +typedef const char * (* PFNGLXGETSCREENDRIVERPROC) (__DRInativeDisplay *dpy, int scrNum); + +/** + * Type of a pointer to \c glXGetDriverConfig, as returned by + * \c glXGetProcAddress. This function is used to get the XML document + * describing the configuration options available for the specified driver. + * + * \sa glXGetDriverConfig, glXGetProcAddress, glXGetScreenDriver + */ +typedef const char * (* PFNGLXGETDRIVERCONFIGPROC) (const char *driverName); + +/** + * Type of a pointer to \c glxEnableExtension, as returned by + * \c __DRIinterfaceMethods::getProcAddress. This function is used to enable + * a GLX extension on the specified screen. + */ +typedef void (* PFNGLXSCRENABLEEXTENSIONPROC) ( void *psc, const char * name ); +/*@}*/ + + +/** + * \name Functions and data provided by the driver. + */ +/*@{*/ + +typedef void *(CREATENEWSCREENFUNC)(__DRInativeDisplay *dpy, int scrn, + __DRIscreen *psc, const __GLcontextModes * modes, + const __DRIversion * ddx_version, const __DRIversion * dri_version, + const __DRIversion * drm_version, const __DRIframebuffer * frame_buffer, + void * pSAREA, int fd, int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes); +typedef CREATENEWSCREENFUNC* PFNCREATENEWSCREENFUNC; +extern CREATENEWSCREENFUNC __driCreateNewScreen_20050727; + + +/** + * XML document describing the configuration options supported by the + * driver. + */ +extern const char __driConfigOptions[]; + +/*@}*/ + + +/** + * Stored version of some component (i.e., server-side DRI module, kernel-side + * DRM, etc.). + * + * \todo + * There are several data structures that explicitly store a major version, + * minor version, and patch level. These structures should be modified to + * have a \c __DRIversionRec instead. + */ +struct __DRIversionRec { + int major; /**< Major version number. */ + int minor; /**< Minor version number. */ + int patch; /**< Patch-level. */ +}; + + +typedef void (*__DRIfuncPtr)(void); + +struct __DRIinterfaceMethodsRec { + /** + * Get pointer to named function. + */ + __DRIfuncPtr (*getProcAddress)( const char * proc_name ); + + /** + * Create a list of \c __GLcontextModes structures. + */ + __GLcontextModes * (*createContextModes)(unsigned count, + size_t minimum_bytes_per_struct); + + /** + * Destroy a list of \c __GLcontextModes structures. + * + * \todo + * Determine if the drivers actually need to call this. + */ + void (*destroyContextModes)( __GLcontextModes * modes ); + + /** + * Get the \c __DRIscreen for a given display and screen number. + */ + __DRIscreen *(*getScreen)(__DRInativeDisplay *dpy, int screenNum); + + + /** + * \name Client/server protocol functions. + * + * These functions implement the DRI client/server protocol for + * context and drawable operations. Platforms that do not implement + * the wire protocol (e.g., EGL) will implement glorified no-op functions. + */ + /*@{*/ + /** + * Determine if the specified window ID still exists. + * + * \note + * Implementations may assume that the driver will only pass an ID into + * this function that actually corresponds to a window. On + * implementations where windows can only be destroyed by the DRI driver + * (e.g., EGL), this function is allowed to always return \c GL_TRUE. + */ + GLboolean (*windowExists)(__DRInativeDisplay *dpy, __DRIid draw); + + /** + * Create the server-side portion of the GL context. + */ + GLboolean (* createContext)( __DRInativeDisplay *dpy, int screenNum, + int configID, void * contextID, drm_context_t * hw_context ); + + /** + * Destroy the server-side portion of the GL context. + */ + GLboolean (* destroyContext)( __DRInativeDisplay *dpy, int screenNum, + __DRIid context ); + + /** + * Create the server-side portion of the drawable. + */ + GLboolean (*createDrawable)( __DRInativeDisplay * ndpy, int screen, + __DRIid drawable, drm_drawable_t * hHWDrawable ); + + /** + * Destroy the server-side portion of the drawable. + */ + GLboolean (*destroyDrawable)( __DRInativeDisplay * ndpy, int screen, + __DRIid drawable ); + + /** + * This function is used to get information about the position, size, and + * clip rects of a drawable. + */ + GLboolean (* getDrawableInfo) ( __DRInativeDisplay *dpy, int scrn, + __DRIid draw, unsigned int * index, unsigned int * stamp, + int * x, int * y, int * width, int * height, + int * numClipRects, drm_clip_rect_t ** pClipRects, + int * backX, int * backY, + int * numBackClipRects, drm_clip_rect_t ** pBackClipRects ); + /*@}*/ + + + /** + * \name Timing related functions. + */ + /*@{*/ + /** + * Get the 64-bit unadjusted system time (UST). + */ + int (*getUST)(int64_t * ust); + + /** + * Get the media stream counter (MSC) rate. + * + * Matching the definition in GLX_OML_sync_control, this function returns + * the rate of the "media stream counter". In practical terms, this is + * the frame refresh rate of the display. + */ + GLboolean (*getMSCRate)(__DRInativeDisplay * dpy, __DRIid drawable, + int32_t * numerator, int32_t * denominator); + /*@}*/ + + /** + * Reports areas of the given drawable which have been modified by the + * driver. + * + * \param drawable which the drawing was done to. + * \param rects rectangles affected, with the drawable origin as the + * origin. + * \param x X offset of the drawable within the screen (used in the + * front_buffer case) + * \param y Y offset of the drawable within the screen. + * \param front_buffer boolean flag for whether the drawing to the + * drawable was actually done directly to the front buffer (instead + * of backing storage, for example) + */ + void (*reportDamage)(__DRInativeDisplay * dpy, int screen, + __DRIid drawable, + int x, int y, + drm_clip_rect_t *rects, int num_rects, + int front_buffer); +}; + + +/** + * Framebuffer information record. Used by libGL to communicate information + * about the framebuffer to the driver's \c __driCreateNewScreen function. + * + * In XFree86, most of this information is derrived from data returned by + * calling \c XF86DRIGetDeviceInfo. + * + * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen + * __driUtilCreateNewScreen CallCreateNewScreen + * + * \bug This structure could be better named. + */ +struct __DRIframebufferRec { + unsigned char *base; /**< Framebuffer base address in the CPU's + * address space. This value is calculated by + * calling \c drmMap on the framebuffer handle + * returned by \c XF86DRIGetDeviceInfo (or a + * similar function). + */ + int size; /**< Framebuffer size, in bytes. */ + int stride; /**< Number of bytes from one line to the next. */ + int width; /**< Pixel width of the framebuffer. */ + int height; /**< Pixel height of the framebuffer. */ + int dev_priv_size; /**< Size of the driver's dev-priv structure. */ + void *dev_priv; /**< Pointer to the driver's dev-priv structure. */ +}; + + +/** + * Screen dependent methods. This structure is initialized during the + * \c __DRIdisplayRec::createScreen call. + */ +struct __DRIscreenRec { + /** + * Method to destroy the private DRI screen data. + */ + void (*destroyScreen)(__DRInativeDisplay *dpy, int scrn, void *screenPrivate); + + /** + * Method to create the private DRI drawable data and initialize the + * drawable dependent methods. + */ + void *(*createNewDrawable)(__DRInativeDisplay *dpy, const __GLcontextModes *modes, + __DRIid draw, __DRIdrawable *pdraw, + int renderType, const int *attrs); + + /** + * Method to return a pointer to the DRI drawable data. + */ + __DRIdrawable *(*getDrawable)(__DRInativeDisplay *dpy, __DRIid draw, + void *drawablePrivate); + + /** + * Opaque pointer to private per screen direct rendering data. \c NULL + * if direct rendering is not supported on this screen. Never + * dereferenced in libGL. + */ + void *private; + + /** + * Get the number of vertical refreshes since some point in time before + * this function was first called (i.e., system start up). + * + * \since Internal API version 20030317. + */ + int (*getMSC)( void *screenPrivate, int64_t *msc ); + + /** + * Opaque pointer that points back to the containing + * \c __GLXscreenConfigs. This data structure is shared with DRI drivers + * but \c __GLXscreenConfigs is not. However, they are needed by some GLX + * functions called by DRI drivers. + * + * \since Internal API version 20030813. + */ + void *screenConfigs; + + /** + * Functions associated with MESA_allocate_memory. + * + * \since Internal API version 20030815. + */ + /*@{*/ + void *(*allocateMemory)(__DRInativeDisplay *dpy, int scrn, GLsizei size, + GLfloat readfreq, GLfloat writefreq, + GLfloat priority); + + void (*freeMemory)(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer); + + GLuint (*memoryOffset)(__DRInativeDisplay *dpy, int scrn, const GLvoid *pointer); + /*@}*/ + + /** + * Method to create the private DRI context data and initialize the + * context dependent methods. + * + * \since Internal API version 20031201. + */ + void * (*createNewContext)(__DRInativeDisplay *dpy, const __GLcontextModes *modes, + int render_type, + void *sharedPrivate, __DRIcontext *pctx); + + /** + * Method to override base texture image with a driver specific 'offset'. + * The depth passed in allows e.g. to ignore the alpha channel of texture + * images where the non-alpha components don't occupy a whole texel. + * + * For GLX_EXT_texture_from_pixmap with AIGLX. + * + * \since Internal API version 20070121. + */ + void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname, + unsigned long long offset, GLint depth, GLuint pitch); +}; + +/** + * Context dependent methods. This structure is initialized during the + * \c __DRIscreenRec::createContext call. + */ +struct __DRIcontextRec { + /** + * Method to destroy the private DRI context data. + */ + void (*destroyContext)(__DRInativeDisplay *dpy, int scrn, void *contextPrivate); + + /** + * Opaque pointer to private per context direct rendering data. + * \c NULL if direct rendering is not supported on the display or + * screen used to create this context. Never dereferenced in libGL. + */ + void *private; + + /** + * Pointer to the mode used to create this context. + * + * \since Internal API version 20040317. + */ + const __GLcontextModes * mode; + + /** + * Method to bind a DRI drawable to a DRI graphics context. + * + * \since Internal API version 20050727. + */ + GLboolean (*bindContext)(__DRInativeDisplay *dpy, int scrn, __DRIid draw, + __DRIid read, __DRIcontext *ctx); + + /** + * Method to unbind a DRI drawable from a DRI graphics context. + * + * \since Internal API version 20050727. + */ + GLboolean (*unbindContext)(__DRInativeDisplay *dpy, int scrn, __DRIid draw, + __DRIid read, __DRIcontext *ctx); +}; + +/** + * Drawable dependent methods. This structure is initialized during the + * \c __DRIscreenRec::createDrawable call. \c createDrawable is not called + * by libGL at this time. It's currently used via the dri_util.c utility code + * instead. + */ +struct __DRIdrawableRec { + /** + * Method to destroy the private DRI drawable data. + */ + void (*destroyDrawable)(__DRInativeDisplay *dpy, void *drawablePrivate); + + /** + * Method to swap the front and back buffers. + */ + void (*swapBuffers)(__DRInativeDisplay *dpy, void *drawablePrivate); + + /** + * Opaque pointer to private per drawable direct rendering data. + * \c NULL if direct rendering is not supported on the display or + * screen used to create this drawable. Never dereferenced in libGL. + */ + void *private; + + /** + * Get the number of completed swap buffers for this drawable. + * + * \since Internal API version 20030317. + */ + int (*getSBC)(__DRInativeDisplay *dpy, void *drawablePrivate, int64_t *sbc ); + + /** + * Wait for the SBC to be greater than or equal target_sbc. + * + * \since Internal API version 20030317. + */ + int (*waitForSBC)( __DRInativeDisplay * dpy, void *drawablePriv, + int64_t target_sbc, + int64_t * msc, int64_t * sbc ); + + /** + * Wait for the MSC to equal target_msc, or, if that has already passed, + * the next time (MSC % divisor) is equal to remainder. If divisor is + * zero, the function will return as soon as MSC is greater than or equal + * to target_msc. + * + * \since Internal API version 20030317. + */ + int (*waitForMSC)( __DRInativeDisplay * dpy, void *drawablePriv, + int64_t target_msc, int64_t divisor, int64_t remainder, + int64_t * msc, int64_t * sbc ); + + /** + * Like \c swapBuffers, but does NOT have an implicit \c glFlush. Once + * rendering is complete, waits until MSC is equal to target_msc, or + * if that has already passed, waits until (MSC % divisor) is equal + * to remainder. If divisor is zero, the swap will happen as soon as + * MSC is greater than or equal to target_msc. + * + * \since Internal API version 20030317. + */ + int64_t (*swapBuffersMSC)(__DRInativeDisplay *dpy, void *drawablePrivate, + int64_t target_msc, + int64_t divisor, int64_t remainder); + + /** + * Enable or disable frame usage tracking. + * + * \since Internal API version 20030317. + */ + int (*frameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate, GLboolean enable); + + /** + * Retrieve frame usage information. + * + * \since Internal API version 20030317. + */ + int (*queryFrameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate, + int64_t * sbc, int64_t * missedFrames, + float * lastMissedUsage, float * usage ); + + /** + * Used by drivers that implement the GLX_SGI_swap_control or + * GLX_MESA_swap_control extension. + * + * \since Internal API version 20030317. + */ + unsigned swap_interval; + + /** + * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension. + * + * \since Internal API version 20060314. + */ + void (*copySubBuffer)(__DRInativeDisplay *dpy, void *drawablePrivate, + int x, int y, int w, int h); +}; + +#endif --- xorg-server-1.4.99.906.orig/hw/kdrive/ephyr/ephyrhostproxy.c +++ xorg-server-1.4.99.906/hw/kdrive/ephyr/ephyrhostproxy.c @@ -0,0 +1,94 @@ +/* + * Xephyr - A kdrive X server thats runs in a host X window. + * Authored by Matthew Allum + * + * Copyright © 2007 OpenedHand Ltd + * + * 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 OpenedHand Ltd not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. OpenedHand Ltd makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL OpenedHand Ltd 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. + * + * Authors: + * Dodji Seketeli + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#define _HAVE_XALLOC_DECLS +#include "ephyrlog.h" +#include "ephyrhostproxy.h" +#include "hostx.h" + +/* byte swap a short */ +#define swaps(x, n) { \ + n = ((char *) (x))[0];\ + ((char *) (x))[0] = ((char *) (x))[1];\ + ((char *) (x))[1] = n; } + +#define GetXReq(req) \ + WORD64ALIGN ;\ + if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\ + _XFlush(dpy);\ + req = (xReq *)(dpy->last_req = dpy->bufptr);\ + dpy->bufptr += SIZEOF(xReq);\ + dpy->request++ + + +Bool +ephyrHostProxyDoForward (pointer a_request_buffer, + struct XReply *a_reply, + Bool a_do_swap) +{ + Bool is_ok = FALSE ; + int n=0 ; + Display *dpy=hostx_get_display () ; + xReq *in_req = (xReq*) a_request_buffer ; + xReq *forward_req=NULL ; + struct XReply reply ; + + EPHYR_RETURN_VAL_IF_FAIL (in_req && dpy, FALSE) ; + + EPHYR_LOG ("enter\n") ; + + if (a_do_swap) { + swaps (&in_req->length, n) ; + } + EPHYR_LOG ("Req {type:%d, data:%d, length:%d}\n", + in_req->reqType, in_req->data, in_req->length) ; + GetXReq (forward_req) ; + memmove (forward_req, in_req, 4) ; + + if (!_XReply (dpy, (xReply*) &reply, 0, FALSE)) { + EPHYR_LOG_ERROR ("failed to get reply\n") ; + goto out; + } + EPHYR_LOG ("XReply{type:%d, foo:%d, seqnum:%d, length:%d}\n", + reply.type, reply.foo, reply.sequence_number, reply.length) ; + + if (a_reply) { + memmove (a_reply, &reply, sizeof (reply)) ; + } + is_ok = TRUE ; + +out: + EPHYR_LOG ("leave\n") ; + return is_ok ; +} + --- xorg-server-1.4.99.906.orig/hw/kdrive/ephyr/ephyrproxyext.h +++ xorg-server-1.4.99.906/hw/kdrive/ephyr/ephyrproxyext.h @@ -0,0 +1,34 @@ +/* + * Xephyr - A kdrive X server thats runs in a host X window. + * Authored by Matthew Allum + * + * Copyright © 2007 OpenedHand Ltd + * + * 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 OpenedHand Ltd not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. OpenedHand Ltd makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL OpenedHand Ltd 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. + * + * Authors: + * Dodji Seketeli + */ +#ifndef __EPHYRPROXYEXT_H__ +#define __EPHYRPROXYEXT_H__ + +Bool ephyrProxyExtensionInit (const char *a_extension_name) ; + +#endif /*__EPHYRPROXYEXT_H__*/ + --- xorg-server-1.4.99.906.orig/hw/kdrive/ephyr/ephyrhostproxy.h +++ xorg-server-1.4.99.906/hw/kdrive/ephyr/ephyrhostproxy.h @@ -0,0 +1,51 @@ +/* + * Xephyr - A kdrive X server thats runs in a host X window. + * Authored by Matthew Allum + * + * Copyright © 2007 OpenedHand Ltd + * + * 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 OpenedHand Ltd not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. OpenedHand Ltd makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL OpenedHand Ltd 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. + * + * Authors: + * Dodji Seketeli + */ + +#ifndef __EPHYRHOSTPROXY_H__ +#define __EPHYRHOSTPROXY_H__ + +struct XReply { + int8_t type ;/*X_Reply*/ + int8_t foo; + int16_t sequence_number ; + int32_t length ; + /*following is some data up to 32 bytes lenght*/ + int32_t pad0 ; + int32_t pad1 ; + int32_t pad2 ; + int32_t pad3 ; + int32_t pad4 ; + int32_t pad5 ; +}; + +Bool +ephyrHostProxyDoForward (pointer a_request_buffer, + struct XReply *a_reply, + Bool a_do_swap) ; + +#endif /*__EPHYRHOSTPROXY_H__*/ --- xorg-server-1.4.99.906.orig/hw/kdrive/epson/Xepson.man +++ xorg-server-1.4.99.906/hw/kdrive/epson/Xepson.man @@ -0,0 +1,26 @@ +.\" $XFree86: xc/programs/Xserver/hw/kdrive/epson/Xepson.man,v 1.5 2001/02/13 21:15:15 dawes Exp $ +.\" +.TH Xepson 1 __vendorversion__ +.SH NAME +Xepson \- Epson 13806 accelerated framebuffer device tiny X server +.SH SYNOPSIS +.B Xepson +.RI [ :display ] +.RI [ option ...] +.SH DESCRIPTION +.B Xepson +is a driver for the Epson LCD 13806 framebuffer. +.B Xepson +is heavily based upon the Kdrive Xfbdev driver, and behaves very similarly, except for accelerated operations targetted at the Epson chip. +.SH OPTIONS +.B Xepson +accepts the common options of the Xkdrive family of servers. Please +see Xkdrive(1). +.SH KEYBOARD +To be written. +.SH SEE ALSO +X(__miscmansuffix__), Xserver(1), Xkdrive(1), xdm(1), xinit(1). +.SH AUTHORS +The +.B Xepson +server was written by Costas Stylianou based on the Xfbdev sources with some contributions from Phil Blundell & Peter Naulls. --- xorg-server-1.4.99.906.orig/hw/kdrive/nvidia/nvidiacurs.c +++ xorg-server-1.4.99.906/hw/kdrive/nvidia/nvidiacurs.c @@ -0,0 +1,389 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "trident.h" +#include "cursorstr.h" + +#define SetupCursor(s) KdScreenPriv(s); \ + tridentCardInfo(pScreenPriv); \ + tridentScreenInfo(pScreenPriv); \ + TridentCursor *pCurPriv = &tridents->cursor + +static void +_tridentMoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CARD8 xlow, xhigh, ylow, yhigh; + CARD8 xoff, yoff; + + x -= pCurPriv->xhot; + xoff = 0; + if (x < 0) + { + xoff = -x; + x = 0; + } + y -= pCurPriv->yhot; + yoff = 0; + if (y < 0) + { + yoff = -y; + y = 0; + } + xlow = (CARD8) x; + xhigh = (CARD8) (x >> 8); + ylow = (CARD8) y; + yhigh = (CARD8) (y >> 8); + + + /* This is the recommended order to move the cursor */ + + tridentWriteIndex (tridentc, 0x3d4, 0x41, xhigh); + tridentWriteIndex (tridentc, 0x3d4, 0x40, xlow); + tridentWriteIndex (tridentc, 0x3d4, 0x42, ylow); + tridentWriteIndex (tridentc, 0x3d4, 0x46, xoff); + tridentWriteIndex (tridentc, 0x3d4, 0x47, yoff); + tridentWriteIndex (tridentc, 0x3d4, 0x43, yhigh); +} + +static void +tridentMoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor (pScreen); + + if (!pCurPriv->has_cursor) + return; + + if (!pScreenPriv->enabled) + return; + + _tridentMoveCursor (pScreen, x, y); +} + +static void +tridentAllocCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + + KdAllocateCursorPixels (pScreen, 0, pCursor, + &pCurPriv->source, &pCurPriv->mask); + switch (pScreenPriv->screen->fb[0].bitsPerPixel) { + case 4: + pCurPriv->source |= pCurPriv->source << 4; + pCurPriv->mask |= pCurPriv->mask << 4; + case 8: + pCurPriv->source |= pCurPriv->source << 8; + pCurPriv->mask |= pCurPriv->mask << 8; + case 16: + pCurPriv->source |= pCurPriv->source << 16; + pCurPriv->mask |= pCurPriv->mask << 16; + } +} + +static void +tridentSetCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + CARD32 fg, bg; + + fg = pCurPriv->source; + bg = pCurPriv->mask; + tridentWriteIndex (tridentc, 0x3d4, 0x48, fg); + tridentWriteIndex (tridentc, 0x3d4, 0x49, fg >> 8); + tridentWriteIndex (tridentc, 0x3d4, 0x4a, fg >> 16); + + tridentWriteIndex (tridentc, 0x3d4, 0x4c, bg); + tridentWriteIndex (tridentc, 0x3d4, 0x4d, bg >> 8); + tridentWriteIndex (tridentc, 0x3d4, 0x4e, bg >> 16); +} + +void +tridentRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + xColorItem sourceColor, maskColor; + + if (!pCurPriv->has_cursor || !pCursor) + return; + + if (!pScreenPriv->enabled) + return; + + if (pdef) + { + while (ndef) + { + if (pdef->pixel == pCurPriv->source || + pdef->pixel == pCurPriv->mask) + break; + ndef--; + } + if (!ndef) + return; + } + tridentAllocCursorColors (pScreen); + tridentSetCursorColors (pScreen); +} + +#define InvertBits32(v) { \ + v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ + v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ + v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ +} + +static void +tridentLoadCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + CursorBitsPtr bits = pCursor->bits; + int w, h; + CARD32 *ram, *msk, *mskLine, *src, *srcLine; + int i, j; + int cursor_address; + int lwsrc; + unsigned char ramdac_control_; + CARD32 offset; + + /* + * Allocate new colors + */ + tridentAllocCursorColors (pScreen); + + pCurPriv->pCursor = pCursor; + pCurPriv->xhot = pCursor->bits->xhot; + pCurPriv->yhot = pCursor->bits->yhot; + + /* + * Stick new image into cursor memory + */ + ram = (CARD32 *) tridents->cursor_base; + mskLine = (CARD32 *) bits->mask; + srcLine = (CARD32 *) bits->source; + + h = bits->height; + if (h > TRIDENT_CURSOR_HEIGHT) + h = TRIDENT_CURSOR_HEIGHT; + + lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */ + + for (i = 0; i < TRIDENT_CURSOR_HEIGHT; i++) { + msk = mskLine; + src = srcLine; + mskLine += lwsrc; + srcLine += lwsrc; + for (j = 0; j < TRIDENT_CURSOR_WIDTH / 32; j++) { + + CARD32 m, s; + +#if 1 + if (i < h && j < lwsrc) + { + m = *msk++; + s = *src++; + InvertBits32(m); + InvertBits32(s); + } + else + { + m = 0; + s = 0; + } +#endif + *ram++ = m; + *ram++ = s; + } + } + + /* Set address for cursor bits */ + offset = tridents->cursor_base - (CARD8 *) tridents->screen; + offset >>= 10; + tridentWriteIndex (tridentc, 0x3d4, 0x44, (CARD8) (offset & 0xff)); + tridentWriteIndex (tridentc, 0x3d4, 0x45, (CARD8) (offset >> 8)); + + /* Set new color */ + tridentSetCursorColors (pScreen); + + /* Enable the cursor */ + tridentWriteIndex (tridentc, 0x3d4, 0x50, 0xc1); + + /* Move to new position */ + tridentMoveCursor (pScreen, x, y); +} + +static void +tridentUnloadCursor (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + /* Disable cursor */ + tridentWriteIndex (tridentc, 0x3d4, 0x50, 0); +} + +static Bool +tridentRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + SetupCursor(pScreen); + + if (!pScreenPriv->enabled) + return TRUE; + + /* miRecolorCursor does this */ + if (pCurPriv->pCursor == pCursor) + { + if (pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + tridentLoadCursor (pScreen, x, y); + } + } + return TRUE; +} + +static Bool +tridentUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + return TRUE; +} + +static void +tridentSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +{ + SetupCursor(pScreen); + + pCurPriv->pCursor = pCursor; + + if (!pScreenPriv->enabled) + return; + + if (pCursor) + tridentLoadCursor (pScreen, x, y); + else + tridentUnloadCursor (pScreen); +} + +miPointerSpriteFuncRec tridentPointerSpriteFuncs = { + tridentRealizeCursor, + tridentUnrealizeCursor, + tridentSetCursor, + tridentMoveCursor, +}; + +static void +tridentQueryBestSize (int class, + unsigned short *pwidth, unsigned short *pheight, + ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + switch (class) + { + case CursorShape: + if (*pwidth > pCurPriv->width) + *pwidth = pCurPriv->width; + if (*pheight > pCurPriv->height) + *pheight = pCurPriv->height; + if (*pwidth > pScreen->width) + *pwidth = pScreen->width; + if (*pheight > pScreen->height) + *pheight = pScreen->height; + break; + default: + fbQueryBestSize (class, pwidth, pheight, pScreen); + break; + } +} + +Bool +tridentCursorInit (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!tridents->cursor_base) + { + pCurPriv->has_cursor = FALSE; + return FALSE; + } + + pCurPriv->width = TRIDENT_CURSOR_WIDTH; + pCurPriv->height= TRIDENT_CURSOR_HEIGHT; + pScreen->QueryBestSize = tridentQueryBestSize; + miPointerInitialize (pScreen, + &tridentPointerSpriteFuncs, + &kdPointerScreenFuncs, + FALSE); + pCurPriv->has_cursor = TRUE; + pCurPriv->pCursor = NULL; + return TRUE; +} + +void +tridentCursorEnable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + tridentLoadCursor (pScreen, x, y); + } + else + tridentUnloadCursor (pScreen); + } +} + +void +tridentCursorDisable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!pScreenPriv->enabled) + return; + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + tridentUnloadCursor (pScreen); + } + } +} + +void +tridentCursorFini (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + pCurPriv->pCursor = NULL; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/nvidia/nvidiavideo.c +++ xorg-server-1.4.99.906/hw/kdrive/nvidia/nvidiavideo.c @@ -0,0 +1,1016 @@ +/* + * Copyright © 2003 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "nvidia.h" + +#include +#include "fourcc.h" + +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +static Atom xvBrightness, xvSaturation, xvColorKey; + +#define IMAGE_MAX_WIDTH 720 +#define IMAGE_MAX_HEIGHT 576 + +static void +nvidiaStopVideo(KdScreenInfo *screen, pointer data, Bool exit) +{ + ScreenPtr pScreen = screen->pScreen; + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; + NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; + NvidiaPortPrivPtr pPortPriv = nvidias->pAdaptor->pPortPrivates[0].ptr; + Reg *reg = nvidiac->reg; + MediaReg *media = nvidiac->media_reg; + + REGION_EMPTY(screen->pScreen, &pPortPriv->clip); + + if (!media) + return; + + if(pPortPriv->videoOn) + { + nvidiaWaitIdle (reg); + /* wait for buffer to be displayed */ + while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf) + ; + /* wait for buffer to be finished */ + while (((media->TRIG_CNTL >> 6) & 1) != 0) + ; + nvidiaWaitAvail (reg, 1); + media->OVERLAY_SCALE_CNTL = 0; + pPortPriv->videoOn = FALSE; + nvidiaWaitIdle (reg); + } +} + +static int +nvidiaSetPortAttribute(KdScreenInfo *screen, + Atom attribute, + int value, + pointer data) +{ + ScreenPtr pScreen = screen->pScreen; + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; + NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; + NvidiaPortPrivPtr pPortPriv = nvidias->pAdaptor->pPortPrivates[0].ptr; + MediaReg *media = nvidiac->media_reg; + + if(attribute == xvBrightness) + { + if(value < -1000) + value = -1000; + if (value > 1000) + value = 1000; + pPortPriv->brightness = value; + } + else if(attribute == xvSaturation) + { + if (value < -1000) + value = -1000; + if (value > 1000) + value = 1000; + pPortPriv->saturation = value; + } + else if(attribute == xvColorKey) + { + if (pPortPriv->colorKey != value) + { + pPortPriv->colorKey = value; + REGION_EMPTY(screen->pScreen, &pPortPriv->clip); + } + } + else + return BadMatch; + + return Success; +} + +static int +nvidiaGetPortAttribute(KdScreenInfo *screen, + Atom attribute, + int *value, + pointer data) +{ + NvidiaPortPrivPtr pPortPriv = (NvidiaPortPrivPtr)data; + + if(attribute == xvBrightness) + *value = pPortPriv->brightness; + else if(attribute == xvSaturation) + *value = pPortPriv->saturation; + else if(attribute == xvColorKey) + *value = pPortPriv->colorKey; + else + return BadMatch; + + return Success; +} + +static void +nvidiaQueryBestSize(KdScreenInfo *screen, + Bool motion, + short vid_w, + short vid_h, + short drw_w, + short drw_h, + unsigned int *p_w, + unsigned int *p_h, + pointer data) +{ + *p_w = drw_w; + *p_h = drw_h; +} + + +static void +nvidiaCopyPackedData(KdScreenInfo *screen, + unsigned char *buf, + int randr, + int srcPitch, + int dstPitch, + int srcW, + int srcH, + int top, + int left, + int h, + int w) +{ + ScreenPtr pScreen = screen->pScreen; + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; + NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; + NvidiaPortPrivPtr pPortPriv = nvidias->pAdaptor->pPortPrivates[0].ptr; + CARD8 *src, *dst; + int srcDown, srcRight, srcNext; + int p; + + switch (randr & RR_Rotate_All) { + case RR_Rotate_0: + src = buf; + srcDown = srcPitch; + srcRight = 2; + break; + case RR_Rotate_90: + src = buf + (srcH - 1) * 2; + srcDown = -2; + srcRight = srcPitch; + break; + case RR_Rotate_180: + src = buf + srcPitch * (srcH - 1) + (srcW - 1) * 2; + srcDown = -srcPitch; + srcRight = -2; + break; + case RR_Rotate_270: + src = buf + srcPitch * (srcW - 1); + srcDown = 2; + srcRight = -srcPitch; + break; + } + + src = src + top*srcDown + left*srcRight; + + if (pPortPriv->currentBuf == 0) + dst = (CARD8 *) nvidias->vesa.fb + pPortPriv->YBuf0Offset; + else + dst = (CARD8 *) nvidias->vesa.fb + pPortPriv->YBuf1Offset; + + w >>= 1; + srcRight >>= 1; + srcNext = srcRight >> 1; + while(h--) + { + CARD16 *s = (CARD16 *) src; + CARD32 *d = (CARD32 *) dst; + p = w; + while (p--) + { + *d++ = s[0] | (s[srcNext] << 16); + s += srcRight; + } + src += srcPitch; + dst += dstPitch; + } +} + +static void +nvidiaCopyPlanarData(KdScreenInfo *screen, + unsigned char *buf, + int randr, + int srcPitch, + int srcPitch2, + int dstPitch, /* of chroma */ + int srcW, + int srcH, + int height, + int top, + int left, + int h, + int w, + int id) +{ + ScreenPtr pScreen = screen->pScreen; + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; + NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; + NvidiaPortPrivPtr pPortPriv = nvidias->pAdaptor->pPortPrivates[0].ptr; + int i, j; + CARD8 *src1, *src2, *src3, *dst1; + int srcDown, srcDown2, srcRight, srcRight2, srcNext; + + /* compute source data pointers */ + src1 = buf; + src2 = src1 + height * srcPitch; + src3 = src2 + (height >> 1) * srcPitch2; + switch (randr & RR_Rotate_All) { + case RR_Rotate_0: + srcDown = srcPitch; + srcDown2 = srcPitch2; + srcRight = 2; + srcRight2 = 1; + srcNext = 1; + break; + case RR_Rotate_90: + src1 = src1 + srcH - 1; + src2 = src2 + (srcH >> 1) - 1; + src3 = src3 + (srcH >> 1) - 1; + srcDown = -1; + srcDown2 = -1; + srcRight = srcPitch * 2; + srcRight2 = srcPitch2; + srcNext = srcPitch; + break; + case RR_Rotate_180: + src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1); + src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1); + src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1); + srcDown = -srcPitch; + srcDown2 = -srcPitch2; + srcRight = -2; + srcRight2 = -1; + srcNext = -1; + break; + case RR_Rotate_270: + src1 = src1 + srcPitch * (srcW - 1); + src2 = src2 + srcPitch2 * ((srcW >> 1) - 1); + src3 = src3 + srcPitch2 * ((srcW >> 1) - 1); + srcDown = 1; + srcDown2 = 1; + srcRight = -srcPitch * 2; + srcRight2 = -srcPitch2; + srcNext = -srcPitch; + break; + } + + /* adjust for origin */ + src1 += top * srcDown + left * srcNext; + src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2; + src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2; + + if (id == FOURCC_I420) + { + CARD8 *srct = src2; + src2 = src3; + src3 = srct; + } + + if (pPortPriv->currentBuf == 0) + dst1 = (CARD8 *) nvidias->vesa.fb + pPortPriv->YBuf0Offset; + else + dst1 = (CARD8 *) nvidias->vesa.fb + pPortPriv->YBuf1Offset; + + w >>= 1; + for (j = 0; j < h; j++) + { + CARD32 *dst = (CARD32 *) dst1; + CARD8 *s1l = src1; + CARD8 *s1r = src1 + srcNext; + CARD8 *s2 = src2; + CARD8 *s3 = src3; + + for (i = 0; i < w; i++) + { + *dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24); + s1l += srcRight; + s1r += srcRight; + s2 += srcRight2; + s3 += srcRight2; + } + src1 += srcDown; + dst1 += dstPitch; + if (j & 1) + { + src2 += srcDown2; + src3 += srcDown2; + } + } +} + +static void +nvidiaPaintRegion (ScreenPtr pScreen, RegionPtr pRgn, Pixel fg) +{ + WindowPtr pRoot = WindowTable[pScreen->myNum]; + GCPtr pGC; + CARD32 val[2]; + xRectangle *rects, *r; + BoxPtr pBox = REGION_RECTS (pRgn); + int nBox = REGION_NUM_RECTS (pRgn); + + rects = xalloc (nBox * sizeof (xRectangle)); + if (!rects) + goto bail0; + r = rects; + while (nBox--) + { + r->x = pBox->x1; + r->y = pBox->y1; + r->width = pBox->x2 - pBox->x1; + r->height = pBox->y2 - pBox->y1; + r++; + pBox++; + } + + pGC = GetScratchGC (pRoot->drawable.depth, pScreen); + if (!pGC) + goto bail1; + + val[0] = fg; + val[1] = IncludeInferiors; + ChangeGC (pGC, GCForeground|GCSubwindowMode, val); + + ValidateGC (&pRoot->drawable, pGC); + + (*pGC->ops->PolyFillRect) (&pRoot->drawable, pGC, + REGION_NUM_RECTS (pRgn), rects); + + FreeScratchGC (pGC); +bail1: + xfree (rects); +bail0: + ; +} + +/* NvidiaClipVideo - + + Takes the dst box in standard X BoxRec form (top and left + edges inclusive, bottom and right exclusive). The new dst + box is returned. The source boundaries are given (x1, y1 + inclusive, x2, y2 exclusive) and returned are the new source + boundaries in 16.16 fixed point. +*/ + +static void +NvidiaClipVideo(BoxPtr dst, + INT32 *x1, + INT32 *x2, + INT32 *y1, + INT32 *y2, + BoxPtr extents, /* extents of the clip region */ + INT32 width, + INT32 height) +{ + INT32 vscale, hscale, delta; + int diff; + + hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); + vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); + + *x1 <<= 16; *x2 <<= 16; + *y1 <<= 16; *y2 <<= 16; + + diff = extents->x1 - dst->x1; + if(diff > 0) { + dst->x1 = extents->x1; + *x1 += diff * hscale; + } + diff = dst->x2 - extents->x2; + if(diff > 0) { + dst->x2 = extents->x2; + *x2 -= diff * hscale; + } + diff = extents->y1 - dst->y1; + if(diff > 0) { + dst->y1 = extents->y1; + *y1 += diff * vscale; + } + diff = dst->y2 - extents->y2; + if(diff > 0) { + dst->y2 = extents->y2; + *y2 -= diff * vscale; + } + + if(*x1 < 0) { + diff = (- *x1 + hscale - 1)/ hscale; + dst->x1 += diff; + *x1 += diff * hscale; + } + delta = *x2 - (width << 16); + if(delta > 0) { + diff = (delta + hscale - 1)/ hscale; + dst->x2 -= diff; + *x2 -= diff * hscale; + } + if(*y1 < 0) { + diff = (- *y1 + vscale - 1)/ vscale; + dst->y1 += diff; + *y1 += diff * vscale; + } + delta = *y2 - (height << 16); + if(delta > 0) { + diff = (delta + vscale - 1)/ vscale; + dst->y2 -= diff; + *y2 -= diff * vscale; + } +} + +static void +nvidiaDisplayVideo(KdScreenInfo *screen, + int id, + int dstPitch, /* of chroma for 4:2:0 */ + int x1, + int y1, + int x2, + int y2, + int dst_x1, + int dst_y1, + int dst_x2, + int dst_y2, + short src_w, + short src_h, + short drw_w, + short drw_h) +{ + ScreenPtr pScreen = screen->pScreen; + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; + NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; + NvidiaPortPrivPtr pPortPriv = nvidias->pAdaptor->pPortPrivates[0].ptr; + Reg *reg = nvidiac->reg; + MediaReg *media = nvidiac->media_reg; + int xscaleInt, xscaleFract, yscaleInt, yscaleFract; + int xscaleIntUV = 0, xscaleFractUV = 0; + int yscaleIntUV = 0, yscaleFractUV = 0; + int randr = nvidias->vesa.randr; + int HORZ_INC, VERT_INC; + CARD32 SCALER_IN; + CARD32 OVERLAY_SCALE_CNTL; + int tmp; + int left; + int bright; + int sat; + + if (id == FOURCC_UYVY) + SCALER_IN = SCALER_IN_YVYU422; + else + SCALER_IN = SCALER_IN_VYUY422; + + nvidiaWaitAvail (reg, 4); + + media->VIDEO_FORMAT = SCALER_IN | VIDEO_IN_VYUY422; + + /* color key */ + media->OVERLAY_GRAPHICS_KEY_MSK = (1 << screen->fb[0].depth) - 1; + media->OVERLAY_GRAPHICS_KEY_CLR = pPortPriv->colorKey; + /* set key control to obey only graphics color key */ + media->OVERLAY_KEY_CNTL = 0x50; + + nvidiaWaitAvail (reg, 9); + media->CAPTURE_DEBUG = 0; + /* no exclusive video region */ + media->OVERLAY_EXCLUSIVE_HORZ = 0; + media->OVERLAY_EXCLUSIVE_VERT = 0; + /* scaling coefficients */ + media->SCALER_H_COEFF0 = 0x00002000; + media->SCALER_H_COEFF1 = 0x0D06200D; + media->SCALER_H_COEFF2 = 0x0D0A1C0D; + media->SCALER_H_COEFF3 = 0x0C0E1A0C; + media->SCALER_H_COEFF4 = 0x0C14140C; + media->SCALER_TEST = 0; + + nvidiaWaitAvail (reg, 2); + media->OVERLAY_SCALE_CNTL = (SCALE_PIX_EXPAND | + SCALE_GAMMA_BRIGHT | + SCALE_BANDWIDTH | + SCALE_OVERLAY_EN | + SCALE_EN); + + bright = (pPortPriv->brightness * 64 / 1000); + if (bright < -0x40) + bright = -0x40; + if (bright > 0x3f) + bright = 0x3f; + bright = bright & 0x7f; + sat = ((pPortPriv->saturation * 31 + 31000) / 2000); + if (sat > 0x1f) + sat = 0x1f; + if (sat < 0) + sat = 0; + + media->SCALER_COLOUR_CNTL = ((bright << 0) | /* BRIGHTNESS */ + (sat << 8) | /* SATURATION_U */ + (sat << 16) | /* SATURATION_V */ + (0 << 21) | /* SCALER_VERT_ADJ_UV */ + (0 << 28)); /* SCALER_HORZ_ADJ_UV */ + + VERT_INC = (src_h << 12) / drw_h; + HORZ_INC = (src_w << 12) / drw_w; + + nvidiaWaitAvail (reg, 13); + + /* lock registers to prevent non-atomic update */ + media->OVERLAY_Y_X_START = 0x80000000 | NVIDIA_YX (dst_x1, dst_y1); + /* ending screen coordinate */ + media->OVERLAY_Y_X_END = 0x80000000 | NVIDIA_YX (dst_x2, dst_y2); + + media->OVERLAY_SCALE_INC = NVIDIA_YX(HORZ_INC, VERT_INC); + + media->SCALER_BUF0_OFFSET = pPortPriv->YBuf0Offset; + media->SCALER_BUF1_OFFSET = pPortPriv->YBuf1Offset; + + media->SCALER_BUF0_OFFSET_U = pPortPriv->YBuf0Offset; + media->SCALER_BUF1_OFFSET_U = pPortPriv->YBuf1Offset; + + media->SCALER_BUF0_OFFSET_V = pPortPriv->YBuf0Offset; + media->SCALER_BUF1_OFFSET_V = pPortPriv->YBuf1Offset; + + media->SCALER_BUF_PITCH = dstPitch >> 1; + media->SCALER_HEIGHT_WIDTH = NVIDIA_YX(src_w - (x1 >> 16), src_h - (y1 >> 16)); + + media->CAPTURE_CONFIG = pPortPriv->currentBuf << 28; + + /* set XY location and unlock */ + media->OVERLAY_Y_X_START = NVIDIA_YX (dst_x1, dst_y1); +} + +static int +nvidiaPutImage(KdScreenInfo *screen, + short src_x, + short src_y, + short drw_x, + short drw_y, + short src_w, + short src_h, + short drw_w, + short drw_h, + int id, + unsigned char *buf, + short width, + short height, + Bool sync, + RegionPtr clipBoxes, + pointer data) +{ + KdCardInfo *card = screen->card; + NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; + NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; + NvidiaPortPrivPtr pPortPriv = (NvidiaPortPrivPtr)data; + Reg *reg = nvidiac->reg; + MediaReg *media = nvidiac->media_reg; + INT32 x1, x2, y1, y2; + int randr = nvidias->vesa.randr; + int srcPitch, srcPitch2, dstPitch; + int top, left, npixels, nlines, size; + BoxRec dstBox; + int dst_width = width, dst_height = height; + int rot_x1, rot_y1, rot_x2, rot_y2; + int dst_x1, dst_y1, dst_x2, dst_y2; + int rot_src_w, rot_src_h, rot_drw_w, rot_drw_h; + + /* Clip */ + x1 = src_x; + x2 = src_x + src_w; + y1 = src_y; + y2 = src_y + src_h; + + dstBox.x1 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; + + NvidiaClipVideo(&dstBox, &x1, &x2, &y1, &y2, + REGION_EXTENTS(pScreen, clipBoxes), width, height); + + if((x1 >= x2) || (y1 >= y2)) + return Success; + + if (!media) + return BadAlloc; + + if (randr & (RR_Rotate_0|RR_Rotate_180)) + { + dst_width = width; + dst_height = height; + rot_src_w = src_w; + rot_src_h = src_h; + rot_drw_w = drw_w; + rot_drw_h = drw_h; + } + else + { + dst_width = height; + dst_height = width; + rot_src_w = src_h; + rot_src_h = src_w; + rot_drw_w = drw_h; + rot_drw_h = drw_w; + } + + switch (randr & RR_Rotate_All) { + case RR_Rotate_0: + dst_x1 = dstBox.x1; + dst_y1 = dstBox.y1; + dst_x2 = dstBox.x2; + dst_y2 = dstBox.y2; + rot_x1 = x1; + rot_y1 = y1; + rot_x2 = x2; + rot_y2 = y2; + break; + case RR_Rotate_90: + dst_x1 = dstBox.y1; + dst_y1 = screen->height - dstBox.x2; + dst_x2 = dstBox.y2; + dst_y2 = screen->height - dstBox.x1; + + rot_x1 = y1; + rot_y1 = (src_w << 16) - x2; + rot_x2 = y2; + rot_y2 = (src_w << 16) - x1; + break; + case RR_Rotate_180: + dst_x1 = screen->width - dstBox.x2; + dst_y1 = screen->height - dstBox.y2; + dst_x2 = screen->width - dstBox.x1; + dst_y2 = screen->height - dstBox.y1; + rot_x1 = (src_w << 16) - x2; + rot_y1 = (src_h << 16) - y2; + rot_x2 = (src_w << 16) - x1; + rot_y2 = (src_h << 16) - y1; + break; + case RR_Rotate_270: + dst_x1 = screen->width - dstBox.y2; + dst_y1 = dstBox.x1; + dst_x2 = screen->width - dstBox.y1; + dst_y2 = dstBox.x2; + rot_x1 = (src_h << 16) - y2; + rot_y1 = x1; + rot_x2 = (src_h << 16) - y1; + rot_y2 = x2; + break; + } + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + dstPitch = ((dst_width << 1) + 15) & ~15; + srcPitch = (width + 3) & ~3; + srcPitch2 = ((width >> 1) + 3) & ~3; + size = dstPitch * (int) dst_height; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + dstPitch = ((dst_width << 1) + 15) & ~15; + srcPitch = (width << 1); + size = dstPitch * (int) dst_height; + break; + } + + pPortPriv->offset = nvidias->off_screen - (CARD8 *) nvidias->vesa.fb; + /* fixup pointers */ + + pPortPriv->YBuf0Offset = pPortPriv->offset; + pPortPriv->YBuf1Offset = pPortPriv->offset + size; + +#if 0 + nvidiaWaitIdle (reg); + + if (pPortPriv->videoOn) + { + /* wait for buffer to be displayed */ + while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf) + ; + } +#endif + /* + * Use the other buffer + */ + pPortPriv->currentBuf = 1 - pPortPriv->currentBuf; + + /* copy data */ + top = rot_y1 >> 16; + left = (rot_x1 >> 16) & ~1; + npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + top &= ~1; + nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top; + nvidiaCopyPlanarData(screen, buf, randr, + srcPitch, srcPitch2, dstPitch, + rot_src_w, rot_src_h, height, + top, left, nlines, npixels, id); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + nlines = ((rot_y2 + 0xffff) >> 16) - top; + nvidiaCopyPackedData(screen, buf, randr, + srcPitch, dstPitch, + rot_src_w, rot_src_h, + top, left, nlines, + npixels); + break; + } + + nvidiaDisplayVideo(screen, id, dstPitch, + rot_x1, rot_y1, rot_x2, rot_y2, + dst_x1, dst_y1, + dst_x2, dst_y2, + rot_src_w, rot_src_h, rot_drw_w, rot_drw_h); + + /* update cliplist */ + if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes)) + { + REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes); + nvidiaPaintRegion (screen->pScreen, &pPortPriv->clip, pPortPriv->colorKey); + } + + pPortPriv->videoOn = TRUE; + + return Success; +} + +static int +nvidiaQueryImageAttributes(KdScreenInfo *screen, + int id, + unsigned short *w, + unsigned short *h, + int *pitches, + int *offsets) +{ + int size, tmp; + + if(*w > IMAGE_MAX_WIDTH) + *w = IMAGE_MAX_WIDTH; + if(*h > IMAGE_MAX_HEIGHT) + *h = IMAGE_MAX_HEIGHT; + + *w = (*w + 1) & ~1; + if(offsets) offsets[0] = 0; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + *h = (*h + 1) & ~1; + size = (*w + 3) & ~3; + if(pitches) + pitches[0] = size; + size *= *h; + if(offsets) + offsets[1] = size; + tmp = ((*w >> 1) + 3) & ~3; + if(pitches) + pitches[1] = pitches[2] = tmp; + tmp *= (*h >> 1); + size += tmp; + if(offsets) + offsets[2] = size; + size += tmp; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = *w << 1; + if(pitches) + pitches[0] = size; + size *= *h; + break; + } + + return size; +} + + +/* client libraries expect an encoding */ +static KdVideoEncodingRec DummyEncoding[1] = +{ + { + 0, + "XV_IMAGE", + IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, + {1, 1} + } +}; + +#define NUM_FORMATS 3 + +static KdVideoFormatRec Formats[NUM_FORMATS] = +{ + {15, TrueColor}, {16, TrueColor}, {24, TrueColor} +}; + +#define NUM_ATTRIBUTES 3 + +static KdAttributeRec Attributes[NUM_ATTRIBUTES] = +{ + {XvSettable | XvGettable, 0, ~0, "XV_COLORKEY"}, + {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"}, + {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"} +}; + +#define NUM_IMAGES 4 + +static KdImageRec Images[NUM_IMAGES] = +{ + XVIMAGE_YUY2, + XVIMAGE_YV12, + XVIMAGE_I420, + XVIMAGE_UYVY +}; + +static void nvidiaResetVideo(KdScreenInfo *screen) +{ + ScreenPtr pScreen = screen->pScreen; + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; + NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; + NvidiaPortPrivPtr pPortPriv = nvidias->pAdaptor->pPortPrivates[0].ptr; + MediaReg *media = nvidiac->media_reg; + + /* + * Default to maximum image size in YV12 + */ + +} + +static int +nvidiaReputImage (KdScreenInfo *screen, + short drw_x, + short drw_y, + RegionPtr clipBoxes, + pointer data) +{ + ScreenPtr pScreen = screen->pScreen; + NvidiaPortPrivPtr pPortPriv = (NvidiaPortPrivPtr)data; + BoxPtr pOldExtents = REGION_EXTENTS (pScreen, &pPortPriv->clip); + BoxPtr pNewExtents = REGION_EXTENTS (pScreen, clipBoxes); + + if (pOldExtents->x1 == pNewExtents->x1 && + pOldExtents->x2 == pNewExtents->x2 && + pOldExtents->y1 == pNewExtents->y1 && + pOldExtents->y2 == pNewExtents->y2) + { + /* update cliplist */ + if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes)) + { + REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes); + nvidiaPaintRegion (screen->pScreen, &pPortPriv->clip, pPortPriv->colorKey); + } + return Success; + } + return BadMatch; +} + +static KdVideoAdaptorPtr +nvidiaSetupImageVideo(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + nvidiaCardInfo(pScreenPriv); + nvidiaScreenInfo(pScreenPriv); + KdScreenInfo *screen = pScreenPriv->screen; + KdCardInfo *card = pScreenPriv->card; + KdVideoAdaptorPtr adapt; + NvidiaPortPrivPtr pPortPriv; + + if(!(adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) + + sizeof(NvidiaPortPrivRec) + + sizeof(DevUnion)))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "Nvidia Video Overlay"; + adapt->nEncodings = 1; + adapt->pEncodings = DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->pPortPrivates = (DevUnion*)(&adapt[1]); + + pPortPriv = (NvidiaPortPrivPtr)(&adapt->pPortPrivates[1]); + + adapt->pPortPrivates[0].ptr = (pointer)(pPortPriv); + adapt->pAttributes = Attributes; + adapt->nImages = NUM_IMAGES; + adapt->nAttributes = NUM_ATTRIBUTES; + adapt->pImages = Images; + adapt->PutVideo = NULL; + adapt->PutStill = NULL; + adapt->GetVideo = NULL; + adapt->GetStill = NULL; + adapt->StopVideo = nvidiaStopVideo; + adapt->SetPortAttribute = nvidiaSetPortAttribute; + adapt->GetPortAttribute = nvidiaGetPortAttribute; + adapt->QueryBestSize = nvidiaQueryBestSize; + adapt->PutImage = nvidiaPutImage; + adapt->ReputImage = nvidiaReputImage; + adapt->QueryImageAttributes = nvidiaQueryImageAttributes; + + pPortPriv->colorKey = nvidias->colorKey; + pPortPriv->videoOn = FALSE; + pPortPriv->brightness = 0; + pPortPriv->saturation = 0; + pPortPriv->currentBuf = 0; + + /* gotta uninit this someplace */ + REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0); + + nvidias->pAdaptor = adapt; + + xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); + xvSaturation = MAKE_ATOM("XV_SATURATION"); + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + + nvidiaResetVideo(screen); + + return adapt; +} + +Bool nvidiaInitVideo(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL; + KdVideoAdaptorPtr newAdaptor = NULL; + int num_adaptors; + KdCardInfo *card = pScreenPriv->card; + NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver; + NvidiaCardInfo *nvidiac = (NvidiaCardInfo *) card->driver; + + if (!nvidiac->media_reg) + return FALSE; + + newAdaptor = nvidiaSetupImageVideo(pScreen); + + num_adaptors = KdXVListGenericAdaptors(screen, &adaptors); + + if(newAdaptor) + { + if(!num_adaptors) + { + num_adaptors = 1; + adaptors = &newAdaptor; + } + else + { + newAdaptors = xalloc((num_adaptors + 1) * + sizeof(KdVideoAdaptorPtr*)); + if(newAdaptors) + { + memcpy(newAdaptors, adaptors, + num_adaptors * sizeof(KdVideoAdaptorPtr)); + newAdaptors[num_adaptors] = newAdaptor; + adaptors = newAdaptors; + num_adaptors++; + } + } + } + + if(num_adaptors) + KdXVScreenInit(pScreen, adaptors, num_adaptors); + + if(newAdaptors) + xfree(newAdaptors); + return TRUE; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/fbdev/Xfbdev.man +++ xorg-server-1.4.99.906/hw/kdrive/fbdev/Xfbdev.man @@ -0,0 +1,28 @@ +.\" $RCSId: xc/programs/Xserver/hw/kdrive/fbdev/Xfbdev.man,v 1.4 2001/01/27 18:20:40 dawes Exp $ +.\" +.TH Xfbdev 1 __vendorversion__ +.SH NAME +Xfbdev \- Linux framebuffer device tiny X server +.SH SYNOPSIS +.B Xfbdev +.RI [ :display ] +.RI [ option ...] +.SH DESCRIPTION +.B Xfbdev +is a generic X server for Linux. +.B Xfbdev +doesn't know about any particular hardware, and uses the framebuffer +provided by the Linux framebuffer device. +.SH OPTIONS +.B Xfbdev +accepts the common options of the Xkdrive family of servers. Please +see Xkdrive(1). +.SH KEYBOARD +To be written. +.SH SEE ALSO +X(__miscmansuffix__), Xserver(1), Xkdrive(1), xdm(1), xinit(1). +.SH AUTHORS +The +.B Xfbdev +server was written by Keith Packard. + --- xorg-server-1.4.99.906.orig/hw/kdrive/mach64/mach64curs.c +++ xorg-server-1.4.99.906/hw/kdrive/mach64/mach64curs.c @@ -0,0 +1,389 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "trident.h" +#include "cursorstr.h" + +#define SetupCursor(s) KdScreenPriv(s); \ + tridentCardInfo(pScreenPriv); \ + tridentScreenInfo(pScreenPriv); \ + TridentCursor *pCurPriv = &tridents->cursor + +static void +_tridentMoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CARD8 xlow, xhigh, ylow, yhigh; + CARD8 xoff, yoff; + + x -= pCurPriv->xhot; + xoff = 0; + if (x < 0) + { + xoff = -x; + x = 0; + } + y -= pCurPriv->yhot; + yoff = 0; + if (y < 0) + { + yoff = -y; + y = 0; + } + xlow = (CARD8) x; + xhigh = (CARD8) (x >> 8); + ylow = (CARD8) y; + yhigh = (CARD8) (y >> 8); + + + /* This is the recommended order to move the cursor */ + + tridentWriteIndex (tridentc, 0x3d4, 0x41, xhigh); + tridentWriteIndex (tridentc, 0x3d4, 0x40, xlow); + tridentWriteIndex (tridentc, 0x3d4, 0x42, ylow); + tridentWriteIndex (tridentc, 0x3d4, 0x46, xoff); + tridentWriteIndex (tridentc, 0x3d4, 0x47, yoff); + tridentWriteIndex (tridentc, 0x3d4, 0x43, yhigh); +} + +static void +tridentMoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor (pScreen); + + if (!pCurPriv->has_cursor) + return; + + if (!pScreenPriv->enabled) + return; + + _tridentMoveCursor (pScreen, x, y); +} + +static void +tridentAllocCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + + KdAllocateCursorPixels (pScreen, 0, pCursor, + &pCurPriv->source, &pCurPriv->mask); + switch (pScreenPriv->screen->fb[0].bitsPerPixel) { + case 4: + pCurPriv->source |= pCurPriv->source << 4; + pCurPriv->mask |= pCurPriv->mask << 4; + case 8: + pCurPriv->source |= pCurPriv->source << 8; + pCurPriv->mask |= pCurPriv->mask << 8; + case 16: + pCurPriv->source |= pCurPriv->source << 16; + pCurPriv->mask |= pCurPriv->mask << 16; + } +} + +static void +tridentSetCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + CARD32 fg, bg; + + fg = pCurPriv->source; + bg = pCurPriv->mask; + tridentWriteIndex (tridentc, 0x3d4, 0x48, fg); + tridentWriteIndex (tridentc, 0x3d4, 0x49, fg >> 8); + tridentWriteIndex (tridentc, 0x3d4, 0x4a, fg >> 16); + + tridentWriteIndex (tridentc, 0x3d4, 0x4c, bg); + tridentWriteIndex (tridentc, 0x3d4, 0x4d, bg >> 8); + tridentWriteIndex (tridentc, 0x3d4, 0x4e, bg >> 16); +} + +void +tridentRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + xColorItem sourceColor, maskColor; + + if (!pCurPriv->has_cursor || !pCursor) + return; + + if (!pScreenPriv->enabled) + return; + + if (pdef) + { + while (ndef) + { + if (pdef->pixel == pCurPriv->source || + pdef->pixel == pCurPriv->mask) + break; + ndef--; + } + if (!ndef) + return; + } + tridentAllocCursorColors (pScreen); + tridentSetCursorColors (pScreen); +} + +#define InvertBits32(v) { \ + v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ + v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ + v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ +} + +static void +tridentLoadCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + CursorBitsPtr bits = pCursor->bits; + int w, h; + CARD32 *ram, *msk, *mskLine, *src, *srcLine; + int i, j; + int cursor_address; + int lwsrc; + unsigned char ramdac_control_; + CARD32 offset; + + /* + * Allocate new colors + */ + tridentAllocCursorColors (pScreen); + + pCurPriv->pCursor = pCursor; + pCurPriv->xhot = pCursor->bits->xhot; + pCurPriv->yhot = pCursor->bits->yhot; + + /* + * Stick new image into cursor memory + */ + ram = (CARD32 *) tridents->cursor_base; + mskLine = (CARD32 *) bits->mask; + srcLine = (CARD32 *) bits->source; + + h = bits->height; + if (h > TRIDENT_CURSOR_HEIGHT) + h = TRIDENT_CURSOR_HEIGHT; + + lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */ + + for (i = 0; i < TRIDENT_CURSOR_HEIGHT; i++) { + msk = mskLine; + src = srcLine; + mskLine += lwsrc; + srcLine += lwsrc; + for (j = 0; j < TRIDENT_CURSOR_WIDTH / 32; j++) { + + CARD32 m, s; + +#if 1 + if (i < h && j < lwsrc) + { + m = *msk++; + s = *src++; + InvertBits32(m); + InvertBits32(s); + } + else + { + m = 0; + s = 0; + } +#endif + *ram++ = m; + *ram++ = s; + } + } + + /* Set address for cursor bits */ + offset = tridents->cursor_base - (CARD8 *) tridents->screen; + offset >>= 10; + tridentWriteIndex (tridentc, 0x3d4, 0x44, (CARD8) (offset & 0xff)); + tridentWriteIndex (tridentc, 0x3d4, 0x45, (CARD8) (offset >> 8)); + + /* Set new color */ + tridentSetCursorColors (pScreen); + + /* Enable the cursor */ + tridentWriteIndex (tridentc, 0x3d4, 0x50, 0xc1); + + /* Move to new position */ + tridentMoveCursor (pScreen, x, y); +} + +static void +tridentUnloadCursor (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + /* Disable cursor */ + tridentWriteIndex (tridentc, 0x3d4, 0x50, 0); +} + +static Bool +tridentRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + SetupCursor(pScreen); + + if (!pScreenPriv->enabled) + return TRUE; + + /* miRecolorCursor does this */ + if (pCurPriv->pCursor == pCursor) + { + if (pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + tridentLoadCursor (pScreen, x, y); + } + } + return TRUE; +} + +static Bool +tridentUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + return TRUE; +} + +static void +tridentSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +{ + SetupCursor(pScreen); + + pCurPriv->pCursor = pCursor; + + if (!pScreenPriv->enabled) + return; + + if (pCursor) + tridentLoadCursor (pScreen, x, y); + else + tridentUnloadCursor (pScreen); +} + +miPointerSpriteFuncRec tridentPointerSpriteFuncs = { + tridentRealizeCursor, + tridentUnrealizeCursor, + tridentSetCursor, + tridentMoveCursor, +}; + +static void +tridentQueryBestSize (int class, + unsigned short *pwidth, unsigned short *pheight, + ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + switch (class) + { + case CursorShape: + if (*pwidth > pCurPriv->width) + *pwidth = pCurPriv->width; + if (*pheight > pCurPriv->height) + *pheight = pCurPriv->height; + if (*pwidth > pScreen->width) + *pwidth = pScreen->width; + if (*pheight > pScreen->height) + *pheight = pScreen->height; + break; + default: + fbQueryBestSize (class, pwidth, pheight, pScreen); + break; + } +} + +Bool +tridentCursorInit (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!tridents->cursor_base) + { + pCurPriv->has_cursor = FALSE; + return FALSE; + } + + pCurPriv->width = TRIDENT_CURSOR_WIDTH; + pCurPriv->height= TRIDENT_CURSOR_HEIGHT; + pScreen->QueryBestSize = tridentQueryBestSize; + miPointerInitialize (pScreen, + &tridentPointerSpriteFuncs, + &kdPointerScreenFuncs, + FALSE); + pCurPriv->has_cursor = TRUE; + pCurPriv->pCursor = NULL; + return TRUE; +} + +void +tridentCursorEnable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + tridentLoadCursor (pScreen, x, y); + } + else + tridentUnloadCursor (pScreen); + } +} + +void +tridentCursorDisable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!pScreenPriv->enabled) + return; + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + tridentUnloadCursor (pScreen); + } + } +} + +void +tridentCursorFini (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + pCurPriv->pCursor = NULL; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/ts300/ts300.c +++ xorg-server-1.4.99.906/hw/kdrive/ts300/ts300.c @@ -0,0 +1,136 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "kdrive.h" + +extern KdCardFuncs sisFuncs; +extern KdCardFuncs s3Funcs; + +/* + * Kludgy code to parse the ascii /proc/pci file as the TS300 + * is running a 2.0 kernel + */ +BOOL +HasPCI (char *name, KdCardAttr *attr) +{ + FILE *f; + char line[1024]; + BOOL waiting; + BOOL found = FALSE; + char *mem; + + f = fopen ("/proc/pci", "r"); + if (!f) + return FALSE; + waiting = FALSE; + attr->naddr = 0; + while (fgets (line, sizeof (line), f)) + { + if (waiting) + { + + if (mem = strstr (line, "memory at ")) + { + mem += strlen ("memory at "); + attr->address[attr->naddr++] = strtoul (mem, NULL, 0); + found = TRUE; + } + else if (mem = strstr (line, "I/O at ")) + { + mem += strlen ("I/O at "); + attr->io = strtoul (mem, NULL, 0); + found = TRUE; + } + else if (strstr (line, "Bus") && strstr (line, "device") && + strstr (line, "function")) + break; + } + else if (strstr (line, "VGA compatible controller")) + { + if (strstr (line, name)) + waiting = TRUE; + } + } + fclose (f); + return found; +} + +typedef struct _PCICard { + char *user; + char *name; + KdCardFuncs *funcs; +} PCICard; + +PCICard PCICards[] = { + "sis", "Silicon Integrated Systems", &sisFuncs, + "s3", "S3 Inc.", &s3Funcs, +}; + +#define NUM_PCI_CARDS (sizeof (PCICards) / sizeof (PCICards[0])) + +void +InitCard (char *name) +{ + KdCardInfo *card; + CARD32 fb; + int i; + KdCardAttr attr; + + for (i = 0; i < NUM_PCI_CARDS; i++) + { + if (!name || !strcmp (name, PCICards[i].user)) + { + if (HasPCI (PCICards[i].name, &attr)) + { + KdCardInfoAdd (PCICards[i].funcs, &attr, 0); + return; + } + } + } +} + +void +InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) +{ + KdInitOutput (pScreenInfo, argc, argv); +} + +void +InitInput (int argc, char **argv) +{ + KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); +} + +void +ddxUseMsg (void) +{ + KdUseMsg(); +} + +int +ddxProcessArgument (int argc, char **argv, int i) +{ + return KdProcessArgument (argc, argv, i); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/src/kloadmap.c +++ xorg-server-1.4.99.906/hw/kdrive/src/kloadmap.c @@ -0,0 +1,199 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "kdrive.h" + +#ifdef WINDOWS +#define KM_BUF 1024 +#define KM_EOF -1 + +typedef struct _km_file { + HANDLE handle; + char buf[KM_BUF]; + char *bufptr; + DWORD remain; +} km_file; + +int +km_fill (km_file *kf) +{ + BOOL r; + + NCD_DEBUG ((DEBUG_INIT, "km_fill")); + r = ReadFile (kf->handle, kf->buf, KM_BUF, + &kf->remain, NULL); + NCD_DEBUG ((DEBUG_INIT, "Got %d", kf->remain)); + if (!r || !kf->remain) + return KM_EOF; + kf->bufptr = kf->buf; + --kf->remain; + return *kf->bufptr++; +} + +#define km_getchar(kf) ((kf)->remain-- ? *kf->bufptr++ : km_fill (kf)) +#else +#define km_getchar(kf) getc(kf) +#endif + +BOOL +km_word (km_file *kf, char *buf, int len) +{ + int c; + + for (;;) + { + switch (c = km_getchar (kf)) { + case KM_EOF: + return FALSE; + case ' ': + case '\t': + case '\n': + case '\r': + continue; + } + break; + } + len--; + while (len--) + { + *buf++ = c; + switch (c = km_getchar (kf)) { + case KM_EOF: + case ' ': + case '\t': + case '\n': + case '\r': + *buf++ = '\0'; + return TRUE; + } + } + return FALSE; +} + +BOOL +km_int (km_file *kf, int *r) +{ + char word[64]; + + if (km_word (kf, word, sizeof (word))) + { + *r = strtol (word, NULL, 0); + return TRUE; + } + return FALSE; +} + +WCHAR *winKbdExtensions[] = { + L".xku", + L".xkb" +}; + +#define NUM_KBD_EXTENSIONS (sizeof (winKbdExtensions) / sizeof (winKbdExtensions[0])) + +BOOL +winLoadKeymap (void) +{ + WCHAR file[32 + KL_NAMELENGTH]; + WCHAR name[KL_NAMELENGTH]; + HKL layout; + km_file kf; + int width; + BOOL ret; + KeySym *m; + int scancode; + int w; + int e; + + layout = GetKeyboardLayout (0); + /* + * Pre-build 46 versions of ThinSTAR software return 0 + * for all layouts + */ + if (!layout) + return FALSE; + NCD_DEBUG ((DEBUG_INIT, "Keyboard layout 0x%x", layout)); + for (e = 0; e < NUM_KBD_EXTENSIONS; e++) + { + wstrcpy (file, L"\\Storage Card\\"); + wsprintf (name, TEXT("%08x"), layout); + wstrcat (file, name); + wstrcat (file, winKbdExtensions[e]); + NCD_DEBUG ((DEBUG_INIT, "Loading keymap from %S", file)); + kf.handle = CreateFile (file, + GENERIC_READ, + FILE_SHARE_READ|FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (kf.handle != INVALID_HANDLE_VALUE) + break; + } + if (kf.handle == INVALID_HANDLE_VALUE) + { + NCD_DEBUG ((DEBUG_INIT, "No such file")); + return FALSE; + } + ret = FALSE; + kf.remain = 0; + /* + * Keymap format: + * + * flags (optional) + * width + * keycode -> keysym array (num_keycodes * width) + */ + if (!km_int (&kf, &width)) + goto bail1; + if (width & KEYMAP_FLAGS) + { + CEKeymapFlags = (unsigned long) width; + if (!km_int (&kf, &width)) + goto bail1; + } + else + CEKeymapFlags = 0; + if (width > MAX_WIDTH) + goto bail1; + NCD_DEBUG ((DEBUG_INIT, "Keymap width %d flags 0x%x", + width, CEKeymapFlags)); + m = CEKeymap; + for (scancode = MIN_SCANCODE; scancode <= MAX_SCANCODE; scancode++) + { + for (w = 0; w < width; w++) + { + if (!km_int (&kf, m)) + break; + m++; + } + if (w != width) + break; + } + CEKeySyms.mapWidth = width; + ret = TRUE; +bail1: + CloseHandle (kf.handle); + return ret; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/src/kkeymap.h +++ xorg-server-1.4.99.906/hw/kdrive/src/kkeymap.h @@ -0,0 +1,55 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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. + */ +/* + * All global variables and functions pertaining to keyboard key mapping + * live in this header file. + */ + +#ifndef _KKEYMAP_H +#define _KKEYMAP_H + +/* Offset of MIN_SCANCODE to 8 (X minimum scancode value) */ +#define KD_KEY_OFFSET (8 - kdMinScanCode) + +#define KD_MIN_KEYCODE 8 +#define KD_MAX_KEYCODE 254 +#define KD_MAX_WIDTH 4 +#define KD_MAX_LENGTH (KD_MAX_KEYCODE - KD_MIN_KEYCODE + 1) + +extern int kdMinScanCode; +extern int kdMaxScanCode; +extern int kdMinKeyCode; +extern int kdMaxKeyCode; +extern int kdKeymapWidth; + +extern KeySym kdKeymap[KD_MAX_LENGTH * KD_MAX_WIDTH]; + +extern CARD8 kdModMap[MAP_LENGTH]; + +extern KeySymsRec kdKeySyms; + +typedef struct { + KeySym modsym; + int modbit; +} KdKeySymModsRec; + +#endif /* _KKEYMAP_H */ --- xorg-server-1.4.99.906.orig/hw/kdrive/src/kcolor.c +++ xorg-server-1.4.99.906/hw/kdrive/src/kcolor.c @@ -0,0 +1,881 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "kdrive.h" +#include +#include "os.h" +#include "opaque.h" +#include + +unsigned char +KdToLower (unsigned char a) +{ + if ((a >= XK_A) && (a <= XK_Z)) + return a + (XK_a - XK_A); + else if ((a >= XK_Agrave) && (a <= XK_Odiaeresis)) + return a + (XK_agrave - XK_Agrave); + else if ((a >= XK_Ooblique) && (a <= XK_Thorn)) + return a + (XK_oslash - XK_Ooblique); + else + return a; +} + +int +KdStrCaseCmp (const unsigned char *s1, const unsigned char *s2, int l2) +{ + unsigned char c1, c2; + + for (;;) + { + c1 = KdToLower (*s1++); + if (l2 == 0) + c2 = '\0'; + else + c2 = KdToLower (*s2++); + if (!c1 || !c2) + break; + if (c1 != c2) + break; + l2--; + } + return c2 - c1; +} + +typedef struct _kdNamedColor { + unsigned short red; + unsigned short green; + unsigned short blue; + const unsigned char *name; +} KdNamedColor; + +#define C 0x101 + +const KdNamedColor KdColors[] = { + { 240*C, 248*C, 255*C, "alice blue" }, + { 240*C, 248*C, 255*C, "AliceBlue" }, + { 250*C, 235*C, 215*C, "antique white" }, + { 250*C, 235*C, 215*C, "AntiqueWhite" }, + { 255*C, 239*C, 219*C, "AntiqueWhite1" }, + { 238*C, 223*C, 204*C, "AntiqueWhite2" }, + { 205*C, 192*C, 176*C, "AntiqueWhite3" }, + { 139*C, 131*C, 120*C, "AntiqueWhite4" }, + { 127*C, 255*C, 212*C, "aquamarine" }, + { 127*C, 255*C, 212*C, "aquamarine1" }, + { 118*C, 238*C, 198*C, "aquamarine2" }, + { 102*C, 205*C, 170*C, "aquamarine3" }, + { 69*C, 139*C, 116*C, "aquamarine4" }, + { 240*C, 255*C, 255*C, "azure" }, + { 240*C, 255*C, 255*C, "azure1" }, + { 224*C, 238*C, 238*C, "azure2" }, + { 193*C, 205*C, 205*C, "azure3" }, + { 131*C, 139*C, 139*C, "azure4" }, + { 245*C, 245*C, 220*C, "beige" }, + { 255*C, 228*C, 196*C, "bisque" }, + { 255*C, 228*C, 196*C, "bisque1" }, + { 238*C, 213*C, 183*C, "bisque2" }, + { 205*C, 183*C, 158*C, "bisque3" }, + { 139*C, 125*C, 107*C, "bisque4" }, + { 0*C, 0*C, 0*C, "black" }, + { 255*C, 235*C, 205*C, "blanched almond" }, + { 255*C, 235*C, 205*C, "BlanchedAlmond" }, + { 0*C, 0*C, 255*C, "blue" }, + { 138*C, 43*C, 226*C, "blue violet" }, + { 0*C, 0*C, 255*C, "blue1" }, + { 0*C, 0*C, 238*C, "blue2" }, + { 0*C, 0*C, 205*C, "blue3" }, + { 0*C, 0*C, 139*C, "blue4" }, + { 138*C, 43*C, 226*C, "BlueViolet" }, + { 165*C, 42*C, 42*C, "brown" }, + { 255*C, 64*C, 64*C, "brown1" }, + { 238*C, 59*C, 59*C, "brown2" }, + { 205*C, 51*C, 51*C, "brown3" }, + { 139*C, 35*C, 35*C, "brown4" }, + { 222*C, 184*C, 135*C, "burlywood" }, + { 255*C, 211*C, 155*C, "burlywood1" }, + { 238*C, 197*C, 145*C, "burlywood2" }, + { 205*C, 170*C, 125*C, "burlywood3" }, + { 139*C, 115*C, 85*C, "burlywood4" }, + { 95*C, 158*C, 160*C, "cadet blue" }, + { 95*C, 158*C, 160*C, "CadetBlue" }, + { 152*C, 245*C, 255*C, "CadetBlue1" }, + { 142*C, 229*C, 238*C, "CadetBlue2" }, + { 122*C, 197*C, 205*C, "CadetBlue3" }, + { 83*C, 134*C, 139*C, "CadetBlue4" }, + { 127*C, 255*C, 0*C, "chartreuse" }, + { 127*C, 255*C, 0*C, "chartreuse1" }, + { 118*C, 238*C, 0*C, "chartreuse2" }, + { 102*C, 205*C, 0*C, "chartreuse3" }, + { 69*C, 139*C, 0*C, "chartreuse4" }, + { 210*C, 105*C, 30*C, "chocolate" }, + { 255*C, 127*C, 36*C, "chocolate1" }, + { 238*C, 118*C, 33*C, "chocolate2" }, + { 205*C, 102*C, 29*C, "chocolate3" }, + { 139*C, 69*C, 19*C, "chocolate4" }, + { 255*C, 127*C, 80*C, "coral" }, + { 255*C, 114*C, 86*C, "coral1" }, + { 238*C, 106*C, 80*C, "coral2" }, + { 205*C, 91*C, 69*C, "coral3" }, + { 139*C, 62*C, 47*C, "coral4" }, + { 100*C, 149*C, 237*C, "cornflower blue" }, + { 100*C, 149*C, 237*C, "CornflowerBlue" }, + { 255*C, 248*C, 220*C, "cornsilk" }, + { 255*C, 248*C, 220*C, "cornsilk1" }, + { 238*C, 232*C, 205*C, "cornsilk2" }, + { 205*C, 200*C, 177*C, "cornsilk3" }, + { 139*C, 136*C, 120*C, "cornsilk4" }, + { 0*C, 255*C, 255*C, "cyan" }, + { 0*C, 255*C, 255*C, "cyan1" }, + { 0*C, 238*C, 238*C, "cyan2" }, + { 0*C, 205*C, 205*C, "cyan3" }, + { 0*C, 139*C, 139*C, "cyan4" }, + { 0*C, 0*C, 139*C, "dark blue" }, + { 0*C, 139*C, 139*C, "dark cyan" }, + { 184*C, 134*C, 11*C, "dark goldenrod" }, + { 169*C, 169*C, 169*C, "dark gray" }, + { 0*C, 100*C, 0*C, "dark green" }, + { 169*C, 169*C, 169*C, "dark grey" }, + { 189*C, 183*C, 107*C, "dark khaki" }, + { 139*C, 0*C, 139*C, "dark magenta" }, + { 85*C, 107*C, 47*C, "dark olive green" }, + { 255*C, 140*C, 0*C, "dark orange" }, + { 153*C, 50*C, 204*C, "dark orchid" }, + { 139*C, 0*C, 0*C, "dark red" }, + { 233*C, 150*C, 122*C, "dark salmon" }, + { 143*C, 188*C, 143*C, "dark sea green" }, + { 72*C, 61*C, 139*C, "dark slate blue" }, + { 47*C, 79*C, 79*C, "dark slate gray" }, + { 47*C, 79*C, 79*C, "dark slate grey" }, + { 0*C, 206*C, 209*C, "dark turquoise" }, + { 148*C, 0*C, 211*C, "dark violet" }, + { 0*C, 0*C, 139*C, "DarkBlue" }, + { 0*C, 139*C, 139*C, "DarkCyan" }, + { 184*C, 134*C, 11*C, "DarkGoldenrod" }, + { 255*C, 185*C, 15*C, "DarkGoldenrod1" }, + { 238*C, 173*C, 14*C, "DarkGoldenrod2" }, + { 205*C, 149*C, 12*C, "DarkGoldenrod3" }, + { 139*C, 101*C, 8*C, "DarkGoldenrod4" }, + { 169*C, 169*C, 169*C, "DarkGray" }, + { 0*C, 100*C, 0*C, "DarkGreen" }, + { 169*C, 169*C, 169*C, "DarkGrey" }, + { 189*C, 183*C, 107*C, "DarkKhaki" }, + { 139*C, 0*C, 139*C, "DarkMagenta" }, + { 85*C, 107*C, 47*C, "DarkOliveGreen" }, + { 202*C, 255*C, 112*C, "DarkOliveGreen1" }, + { 188*C, 238*C, 104*C, "DarkOliveGreen2" }, + { 162*C, 205*C, 90*C, "DarkOliveGreen3" }, + { 110*C, 139*C, 61*C, "DarkOliveGreen4" }, + { 255*C, 140*C, 0*C, "DarkOrange" }, + { 255*C, 127*C, 0*C, "DarkOrange1" }, + { 238*C, 118*C, 0*C, "DarkOrange2" }, + { 205*C, 102*C, 0*C, "DarkOrange3" }, + { 139*C, 69*C, 0*C, "DarkOrange4" }, + { 153*C, 50*C, 204*C, "DarkOrchid" }, + { 191*C, 62*C, 255*C, "DarkOrchid1" }, + { 178*C, 58*C, 238*C, "DarkOrchid2" }, + { 154*C, 50*C, 205*C, "DarkOrchid3" }, + { 104*C, 34*C, 139*C, "DarkOrchid4" }, + { 139*C, 0*C, 0*C, "DarkRed" }, + { 233*C, 150*C, 122*C, "DarkSalmon" }, + { 143*C, 188*C, 143*C, "DarkSeaGreen" }, + { 193*C, 255*C, 193*C, "DarkSeaGreen1" }, + { 180*C, 238*C, 180*C, "DarkSeaGreen2" }, + { 155*C, 205*C, 155*C, "DarkSeaGreen3" }, + { 105*C, 139*C, 105*C, "DarkSeaGreen4" }, + { 72*C, 61*C, 139*C, "DarkSlateBlue" }, + { 47*C, 79*C, 79*C, "DarkSlateGray" }, + { 151*C, 255*C, 255*C, "DarkSlateGray1" }, + { 141*C, 238*C, 238*C, "DarkSlateGray2" }, + { 121*C, 205*C, 205*C, "DarkSlateGray3" }, + { 82*C, 139*C, 139*C, "DarkSlateGray4" }, + { 47*C, 79*C, 79*C, "DarkSlateGrey" }, + { 0*C, 206*C, 209*C, "DarkTurquoise" }, + { 148*C, 0*C, 211*C, "DarkViolet" }, + { 255*C, 20*C, 147*C, "deep pink" }, + { 0*C, 191*C, 255*C, "deep sky blue" }, + { 255*C, 20*C, 147*C, "DeepPink" }, + { 255*C, 20*C, 147*C, "DeepPink1" }, + { 238*C, 18*C, 137*C, "DeepPink2" }, + { 205*C, 16*C, 118*C, "DeepPink3" }, + { 139*C, 10*C, 80*C, "DeepPink4" }, + { 0*C, 191*C, 255*C, "DeepSkyBlue" }, + { 0*C, 191*C, 255*C, "DeepSkyBlue1" }, + { 0*C, 178*C, 238*C, "DeepSkyBlue2" }, + { 0*C, 154*C, 205*C, "DeepSkyBlue3" }, + { 0*C, 104*C, 139*C, "DeepSkyBlue4" }, + { 105*C, 105*C, 105*C, "dim gray" }, + { 105*C, 105*C, 105*C, "dim grey" }, + { 105*C, 105*C, 105*C, "DimGray" }, + { 105*C, 105*C, 105*C, "DimGrey" }, + { 30*C, 144*C, 255*C, "dodger blue" }, + { 30*C, 144*C, 255*C, "DodgerBlue" }, + { 30*C, 144*C, 255*C, "DodgerBlue1" }, + { 28*C, 134*C, 238*C, "DodgerBlue2" }, + { 24*C, 116*C, 205*C, "DodgerBlue3" }, + { 16*C, 78*C, 139*C, "DodgerBlue4" }, + { 178*C, 34*C, 34*C, "firebrick" }, + { 255*C, 48*C, 48*C, "firebrick1" }, + { 238*C, 44*C, 44*C, "firebrick2" }, + { 205*C, 38*C, 38*C, "firebrick3" }, + { 139*C, 26*C, 26*C, "firebrick4" }, + { 255*C, 250*C, 240*C, "floral white" }, + { 255*C, 250*C, 240*C, "FloralWhite" }, + { 34*C, 139*C, 34*C, "forest green" }, + { 34*C, 139*C, 34*C, "ForestGreen" }, + { 220*C, 220*C, 220*C, "gainsboro" }, + { 248*C, 248*C, 255*C, "ghost white" }, + { 248*C, 248*C, 255*C, "GhostWhite" }, + { 255*C, 215*C, 0*C, "gold" }, + { 255*C, 215*C, 0*C, "gold1" }, + { 238*C, 201*C, 0*C, "gold2" }, + { 205*C, 173*C, 0*C, "gold3" }, + { 139*C, 117*C, 0*C, "gold4" }, + { 218*C, 165*C, 32*C, "goldenrod" }, + { 255*C, 193*C, 37*C, "goldenrod1" }, + { 238*C, 180*C, 34*C, "goldenrod2" }, + { 205*C, 155*C, 29*C, "goldenrod3" }, + { 139*C, 105*C, 20*C, "goldenrod4" }, + { 190*C, 190*C, 190*C, "gray" }, + { 0*C, 0*C, 0*C, "gray0" }, + { 3*C, 3*C, 3*C, "gray1" }, + { 26*C, 26*C, 26*C, "gray10" }, + { 255*C, 255*C, 255*C, "gray100" }, + { 28*C, 28*C, 28*C, "gray11" }, + { 31*C, 31*C, 31*C, "gray12" }, + { 33*C, 33*C, 33*C, "gray13" }, + { 36*C, 36*C, 36*C, "gray14" }, + { 38*C, 38*C, 38*C, "gray15" }, + { 41*C, 41*C, 41*C, "gray16" }, + { 43*C, 43*C, 43*C, "gray17" }, + { 46*C, 46*C, 46*C, "gray18" }, + { 48*C, 48*C, 48*C, "gray19" }, + { 5*C, 5*C, 5*C, "gray2" }, + { 51*C, 51*C, 51*C, "gray20" }, + { 54*C, 54*C, 54*C, "gray21" }, + { 56*C, 56*C, 56*C, "gray22" }, + { 59*C, 59*C, 59*C, "gray23" }, + { 61*C, 61*C, 61*C, "gray24" }, + { 64*C, 64*C, 64*C, "gray25" }, + { 66*C, 66*C, 66*C, "gray26" }, + { 69*C, 69*C, 69*C, "gray27" }, + { 71*C, 71*C, 71*C, "gray28" }, + { 74*C, 74*C, 74*C, "gray29" }, + { 8*C, 8*C, 8*C, "gray3" }, + { 77*C, 77*C, 77*C, "gray30" }, + { 79*C, 79*C, 79*C, "gray31" }, + { 82*C, 82*C, 82*C, "gray32" }, + { 84*C, 84*C, 84*C, "gray33" }, + { 87*C, 87*C, 87*C, "gray34" }, + { 89*C, 89*C, 89*C, "gray35" }, + { 92*C, 92*C, 92*C, "gray36" }, + { 94*C, 94*C, 94*C, "gray37" }, + { 97*C, 97*C, 97*C, "gray38" }, + { 99*C, 99*C, 99*C, "gray39" }, + { 10*C, 10*C, 10*C, "gray4" }, + { 102*C, 102*C, 102*C, "gray40" }, + { 105*C, 105*C, 105*C, "gray41" }, + { 107*C, 107*C, 107*C, "gray42" }, + { 110*C, 110*C, 110*C, "gray43" }, + { 112*C, 112*C, 112*C, "gray44" }, + { 115*C, 115*C, 115*C, "gray45" }, + { 117*C, 117*C, 117*C, "gray46" }, + { 120*C, 120*C, 120*C, "gray47" }, + { 122*C, 122*C, 122*C, "gray48" }, + { 125*C, 125*C, 125*C, "gray49" }, + { 13*C, 13*C, 13*C, "gray5" }, + { 127*C, 127*C, 127*C, "gray50" }, + { 130*C, 130*C, 130*C, "gray51" }, + { 133*C, 133*C, 133*C, "gray52" }, + { 135*C, 135*C, 135*C, "gray53" }, + { 138*C, 138*C, 138*C, "gray54" }, + { 140*C, 140*C, 140*C, "gray55" }, + { 143*C, 143*C, 143*C, "gray56" }, + { 145*C, 145*C, 145*C, "gray57" }, + { 148*C, 148*C, 148*C, "gray58" }, + { 150*C, 150*C, 150*C, "gray59" }, + { 15*C, 15*C, 15*C, "gray6" }, + { 153*C, 153*C, 153*C, "gray60" }, + { 156*C, 156*C, 156*C, "gray61" }, + { 158*C, 158*C, 158*C, "gray62" }, + { 161*C, 161*C, 161*C, "gray63" }, + { 163*C, 163*C, 163*C, "gray64" }, + { 166*C, 166*C, 166*C, "gray65" }, + { 168*C, 168*C, 168*C, "gray66" }, + { 171*C, 171*C, 171*C, "gray67" }, + { 173*C, 173*C, 173*C, "gray68" }, + { 176*C, 176*C, 176*C, "gray69" }, + { 18*C, 18*C, 18*C, "gray7" }, + { 179*C, 179*C, 179*C, "gray70" }, + { 181*C, 181*C, 181*C, "gray71" }, + { 184*C, 184*C, 184*C, "gray72" }, + { 186*C, 186*C, 186*C, "gray73" }, + { 189*C, 189*C, 189*C, "gray74" }, + { 191*C, 191*C, 191*C, "gray75" }, + { 194*C, 194*C, 194*C, "gray76" }, + { 196*C, 196*C, 196*C, "gray77" }, + { 199*C, 199*C, 199*C, "gray78" }, + { 201*C, 201*C, 201*C, "gray79" }, + { 20*C, 20*C, 20*C, "gray8" }, + { 204*C, 204*C, 204*C, "gray80" }, + { 207*C, 207*C, 207*C, "gray81" }, + { 209*C, 209*C, 209*C, "gray82" }, + { 212*C, 212*C, 212*C, "gray83" }, + { 214*C, 214*C, 214*C, "gray84" }, + { 217*C, 217*C, 217*C, "gray85" }, + { 219*C, 219*C, 219*C, "gray86" }, + { 222*C, 222*C, 222*C, "gray87" }, + { 224*C, 224*C, 224*C, "gray88" }, + { 227*C, 227*C, 227*C, "gray89" }, + { 23*C, 23*C, 23*C, "gray9" }, + { 229*C, 229*C, 229*C, "gray90" }, + { 232*C, 232*C, 232*C, "gray91" }, + { 235*C, 235*C, 235*C, "gray92" }, + { 237*C, 237*C, 237*C, "gray93" }, + { 240*C, 240*C, 240*C, "gray94" }, + { 242*C, 242*C, 242*C, "gray95" }, + { 245*C, 245*C, 245*C, "gray96" }, + { 247*C, 247*C, 247*C, "gray97" }, + { 250*C, 250*C, 250*C, "gray98" }, + { 252*C, 252*C, 252*C, "gray99" }, + { 0*C, 255*C, 0*C, "green" }, + { 173*C, 255*C, 47*C, "green yellow" }, + { 0*C, 255*C, 0*C, "green1" }, + { 0*C, 238*C, 0*C, "green2" }, + { 0*C, 205*C, 0*C, "green3" }, + { 0*C, 139*C, 0*C, "green4" }, + { 173*C, 255*C, 47*C, "GreenYellow" }, + { 190*C, 190*C, 190*C, "grey" }, + { 0*C, 0*C, 0*C, "grey0" }, + { 3*C, 3*C, 3*C, "grey1" }, + { 26*C, 26*C, 26*C, "grey10" }, + { 255*C, 255*C, 255*C, "grey100" }, + { 28*C, 28*C, 28*C, "grey11" }, + { 31*C, 31*C, 31*C, "grey12" }, + { 33*C, 33*C, 33*C, "grey13" }, + { 36*C, 36*C, 36*C, "grey14" }, + { 38*C, 38*C, 38*C, "grey15" }, + { 41*C, 41*C, 41*C, "grey16" }, + { 43*C, 43*C, 43*C, "grey17" }, + { 46*C, 46*C, 46*C, "grey18" }, + { 48*C, 48*C, 48*C, "grey19" }, + { 5*C, 5*C, 5*C, "grey2" }, + { 51*C, 51*C, 51*C, "grey20" }, + { 54*C, 54*C, 54*C, "grey21" }, + { 56*C, 56*C, 56*C, "grey22" }, + { 59*C, 59*C, 59*C, "grey23" }, + { 61*C, 61*C, 61*C, "grey24" }, + { 64*C, 64*C, 64*C, "grey25" }, + { 66*C, 66*C, 66*C, "grey26" }, + { 69*C, 69*C, 69*C, "grey27" }, + { 71*C, 71*C, 71*C, "grey28" }, + { 74*C, 74*C, 74*C, "grey29" }, + { 8*C, 8*C, 8*C, "grey3" }, + { 77*C, 77*C, 77*C, "grey30" }, + { 79*C, 79*C, 79*C, "grey31" }, + { 82*C, 82*C, 82*C, "grey32" }, + { 84*C, 84*C, 84*C, "grey33" }, + { 87*C, 87*C, 87*C, "grey34" }, + { 89*C, 89*C, 89*C, "grey35" }, + { 92*C, 92*C, 92*C, "grey36" }, + { 94*C, 94*C, 94*C, "grey37" }, + { 97*C, 97*C, 97*C, "grey38" }, + { 99*C, 99*C, 99*C, "grey39" }, + { 10*C, 10*C, 10*C, "grey4" }, + { 102*C, 102*C, 102*C, "grey40" }, + { 105*C, 105*C, 105*C, "grey41" }, + { 107*C, 107*C, 107*C, "grey42" }, + { 110*C, 110*C, 110*C, "grey43" }, + { 112*C, 112*C, 112*C, "grey44" }, + { 115*C, 115*C, 115*C, "grey45" }, + { 117*C, 117*C, 117*C, "grey46" }, + { 120*C, 120*C, 120*C, "grey47" }, + { 122*C, 122*C, 122*C, "grey48" }, + { 125*C, 125*C, 125*C, "grey49" }, + { 13*C, 13*C, 13*C, "grey5" }, + { 127*C, 127*C, 127*C, "grey50" }, + { 130*C, 130*C, 130*C, "grey51" }, + { 133*C, 133*C, 133*C, "grey52" }, + { 135*C, 135*C, 135*C, "grey53" }, + { 138*C, 138*C, 138*C, "grey54" }, + { 140*C, 140*C, 140*C, "grey55" }, + { 143*C, 143*C, 143*C, "grey56" }, + { 145*C, 145*C, 145*C, "grey57" }, + { 148*C, 148*C, 148*C, "grey58" }, + { 150*C, 150*C, 150*C, "grey59" }, + { 15*C, 15*C, 15*C, "grey6" }, + { 153*C, 153*C, 153*C, "grey60" }, + { 156*C, 156*C, 156*C, "grey61" }, + { 158*C, 158*C, 158*C, "grey62" }, + { 161*C, 161*C, 161*C, "grey63" }, + { 163*C, 163*C, 163*C, "grey64" }, + { 166*C, 166*C, 166*C, "grey65" }, + { 168*C, 168*C, 168*C, "grey66" }, + { 171*C, 171*C, 171*C, "grey67" }, + { 173*C, 173*C, 173*C, "grey68" }, + { 176*C, 176*C, 176*C, "grey69" }, + { 18*C, 18*C, 18*C, "grey7" }, + { 179*C, 179*C, 179*C, "grey70" }, + { 181*C, 181*C, 181*C, "grey71" }, + { 184*C, 184*C, 184*C, "grey72" }, + { 186*C, 186*C, 186*C, "grey73" }, + { 189*C, 189*C, 189*C, "grey74" }, + { 191*C, 191*C, 191*C, "grey75" }, + { 194*C, 194*C, 194*C, "grey76" }, + { 196*C, 196*C, 196*C, "grey77" }, + { 199*C, 199*C, 199*C, "grey78" }, + { 201*C, 201*C, 201*C, "grey79" }, + { 20*C, 20*C, 20*C, "grey8" }, + { 204*C, 204*C, 204*C, "grey80" }, + { 207*C, 207*C, 207*C, "grey81" }, + { 209*C, 209*C, 209*C, "grey82" }, + { 212*C, 212*C, 212*C, "grey83" }, + { 214*C, 214*C, 214*C, "grey84" }, + { 217*C, 217*C, 217*C, "grey85" }, + { 219*C, 219*C, 219*C, "grey86" }, + { 222*C, 222*C, 222*C, "grey87" }, + { 224*C, 224*C, 224*C, "grey88" }, + { 227*C, 227*C, 227*C, "grey89" }, + { 23*C, 23*C, 23*C, "grey9" }, + { 229*C, 229*C, 229*C, "grey90" }, + { 232*C, 232*C, 232*C, "grey91" }, + { 235*C, 235*C, 235*C, "grey92" }, + { 237*C, 237*C, 237*C, "grey93" }, + { 240*C, 240*C, 240*C, "grey94" }, + { 242*C, 242*C, 242*C, "grey95" }, + { 245*C, 245*C, 245*C, "grey96" }, + { 247*C, 247*C, 247*C, "grey97" }, + { 250*C, 250*C, 250*C, "grey98" }, + { 252*C, 252*C, 252*C, "grey99" }, + { 240*C, 255*C, 240*C, "honeydew" }, + { 240*C, 255*C, 240*C, "honeydew1" }, + { 224*C, 238*C, 224*C, "honeydew2" }, + { 193*C, 205*C, 193*C, "honeydew3" }, + { 131*C, 139*C, 131*C, "honeydew4" }, + { 255*C, 105*C, 180*C, "hot pink" }, + { 255*C, 105*C, 180*C, "HotPink" }, + { 255*C, 110*C, 180*C, "HotPink1" }, + { 238*C, 106*C, 167*C, "HotPink2" }, + { 205*C, 96*C, 144*C, "HotPink3" }, + { 139*C, 58*C, 98*C, "HotPink4" }, + { 205*C, 92*C, 92*C, "indian red" }, + { 205*C, 92*C, 92*C, "IndianRed" }, + { 255*C, 106*C, 106*C, "IndianRed1" }, + { 238*C, 99*C, 99*C, "IndianRed2" }, + { 205*C, 85*C, 85*C, "IndianRed3" }, + { 139*C, 58*C, 58*C, "IndianRed4" }, + { 255*C, 255*C, 240*C, "ivory" }, + { 255*C, 255*C, 240*C, "ivory1" }, + { 238*C, 238*C, 224*C, "ivory2" }, + { 205*C, 205*C, 193*C, "ivory3" }, + { 139*C, 139*C, 131*C, "ivory4" }, + { 240*C, 230*C, 140*C, "khaki" }, + { 255*C, 246*C, 143*C, "khaki1" }, + { 238*C, 230*C, 133*C, "khaki2" }, + { 205*C, 198*C, 115*C, "khaki3" }, + { 139*C, 134*C, 78*C, "khaki4" }, + { 230*C, 230*C, 250*C, "lavender" }, + { 255*C, 240*C, 245*C, "lavender blush" }, + { 255*C, 240*C, 245*C, "LavenderBlush" }, + { 255*C, 240*C, 245*C, "LavenderBlush1" }, + { 238*C, 224*C, 229*C, "LavenderBlush2" }, + { 205*C, 193*C, 197*C, "LavenderBlush3" }, + { 139*C, 131*C, 134*C, "LavenderBlush4" }, + { 124*C, 252*C, 0*C, "lawn green" }, + { 124*C, 252*C, 0*C, "LawnGreen" }, + { 255*C, 250*C, 205*C, "lemon chiffon" }, + { 255*C, 250*C, 205*C, "LemonChiffon" }, + { 255*C, 250*C, 205*C, "LemonChiffon1" }, + { 238*C, 233*C, 191*C, "LemonChiffon2" }, + { 205*C, 201*C, 165*C, "LemonChiffon3" }, + { 139*C, 137*C, 112*C, "LemonChiffon4" }, + { 173*C, 216*C, 230*C, "light blue" }, + { 240*C, 128*C, 128*C, "light coral" }, + { 224*C, 255*C, 255*C, "light cyan" }, + { 238*C, 221*C, 130*C, "light goldenrod" }, + { 250*C, 250*C, 210*C, "light goldenrod yellow" }, + { 211*C, 211*C, 211*C, "light gray" }, + { 144*C, 238*C, 144*C, "light green" }, + { 211*C, 211*C, 211*C, "light grey" }, + { 255*C, 182*C, 193*C, "light pink" }, + { 255*C, 160*C, 122*C, "light salmon" }, + { 32*C, 178*C, 170*C, "light sea green" }, + { 135*C, 206*C, 250*C, "light sky blue" }, + { 132*C, 112*C, 255*C, "light slate blue" }, + { 119*C, 136*C, 153*C, "light slate gray" }, + { 119*C, 136*C, 153*C, "light slate grey" }, + { 176*C, 196*C, 222*C, "light steel blue" }, + { 255*C, 255*C, 224*C, "light yellow" }, + { 173*C, 216*C, 230*C, "LightBlue" }, + { 191*C, 239*C, 255*C, "LightBlue1" }, + { 178*C, 223*C, 238*C, "LightBlue2" }, + { 154*C, 192*C, 205*C, "LightBlue3" }, + { 104*C, 131*C, 139*C, "LightBlue4" }, + { 240*C, 128*C, 128*C, "LightCoral" }, + { 224*C, 255*C, 255*C, "LightCyan" }, + { 224*C, 255*C, 255*C, "LightCyan1" }, + { 209*C, 238*C, 238*C, "LightCyan2" }, + { 180*C, 205*C, 205*C, "LightCyan3" }, + { 122*C, 139*C, 139*C, "LightCyan4" }, + { 238*C, 221*C, 130*C, "LightGoldenrod" }, + { 255*C, 236*C, 139*C, "LightGoldenrod1" }, + { 238*C, 220*C, 130*C, "LightGoldenrod2" }, + { 205*C, 190*C, 112*C, "LightGoldenrod3" }, + { 139*C, 129*C, 76*C, "LightGoldenrod4" }, + { 250*C, 250*C, 210*C, "LightGoldenrodYellow" }, + { 211*C, 211*C, 211*C, "LightGray" }, + { 144*C, 238*C, 144*C, "LightGreen" }, + { 211*C, 211*C, 211*C, "LightGrey" }, + { 255*C, 182*C, 193*C, "LightPink" }, + { 255*C, 174*C, 185*C, "LightPink1" }, + { 238*C, 162*C, 173*C, "LightPink2" }, + { 205*C, 140*C, 149*C, "LightPink3" }, + { 139*C, 95*C, 101*C, "LightPink4" }, + { 255*C, 160*C, 122*C, "LightSalmon" }, + { 255*C, 160*C, 122*C, "LightSalmon1" }, + { 238*C, 149*C, 114*C, "LightSalmon2" }, + { 205*C, 129*C, 98*C, "LightSalmon3" }, + { 139*C, 87*C, 66*C, "LightSalmon4" }, + { 32*C, 178*C, 170*C, "LightSeaGreen" }, + { 135*C, 206*C, 250*C, "LightSkyBlue" }, + { 176*C, 226*C, 255*C, "LightSkyBlue1" }, + { 164*C, 211*C, 238*C, "LightSkyBlue2" }, + { 141*C, 182*C, 205*C, "LightSkyBlue3" }, + { 96*C, 123*C, 139*C, "LightSkyBlue4" }, + { 132*C, 112*C, 255*C, "LightSlateBlue" }, + { 119*C, 136*C, 153*C, "LightSlateGray" }, + { 119*C, 136*C, 153*C, "LightSlateGrey" }, + { 176*C, 196*C, 222*C, "LightSteelBlue" }, + { 202*C, 225*C, 255*C, "LightSteelBlue1" }, + { 188*C, 210*C, 238*C, "LightSteelBlue2" }, + { 162*C, 181*C, 205*C, "LightSteelBlue3" }, + { 110*C, 123*C, 139*C, "LightSteelBlue4" }, + { 255*C, 255*C, 224*C, "LightYellow" }, + { 255*C, 255*C, 224*C, "LightYellow1" }, + { 238*C, 238*C, 209*C, "LightYellow2" }, + { 205*C, 205*C, 180*C, "LightYellow3" }, + { 139*C, 139*C, 122*C, "LightYellow4" }, + { 50*C, 205*C, 50*C, "lime green" }, + { 50*C, 205*C, 50*C, "LimeGreen" }, + { 250*C, 240*C, 230*C, "linen" }, + { 255*C, 0*C, 255*C, "magenta" }, + { 255*C, 0*C, 255*C, "magenta1" }, + { 238*C, 0*C, 238*C, "magenta2" }, + { 205*C, 0*C, 205*C, "magenta3" }, + { 139*C, 0*C, 139*C, "magenta4" }, + { 176*C, 48*C, 96*C, "maroon" }, + { 255*C, 52*C, 179*C, "maroon1" }, + { 238*C, 48*C, 167*C, "maroon2" }, + { 205*C, 41*C, 144*C, "maroon3" }, + { 139*C, 28*C, 98*C, "maroon4" }, + { 102*C, 205*C, 170*C, "medium aquamarine" }, + { 0*C, 0*C, 205*C, "medium blue" }, + { 186*C, 85*C, 211*C, "medium orchid" }, + { 147*C, 112*C, 219*C, "medium purple" }, + { 60*C, 179*C, 113*C, "medium sea green" }, + { 123*C, 104*C, 238*C, "medium slate blue" }, + { 0*C, 250*C, 154*C, "medium spring green" }, + { 72*C, 209*C, 204*C, "medium turquoise" }, + { 199*C, 21*C, 133*C, "medium violet red" }, + { 102*C, 205*C, 170*C, "MediumAquamarine" }, + { 0*C, 0*C, 205*C, "MediumBlue" }, + { 186*C, 85*C, 211*C, "MediumOrchid" }, + { 224*C, 102*C, 255*C, "MediumOrchid1" }, + { 209*C, 95*C, 238*C, "MediumOrchid2" }, + { 180*C, 82*C, 205*C, "MediumOrchid3" }, + { 122*C, 55*C, 139*C, "MediumOrchid4" }, + { 147*C, 112*C, 219*C, "MediumPurple" }, + { 171*C, 130*C, 255*C, "MediumPurple1" }, + { 159*C, 121*C, 238*C, "MediumPurple2" }, + { 137*C, 104*C, 205*C, "MediumPurple3" }, + { 93*C, 71*C, 139*C, "MediumPurple4" }, + { 60*C, 179*C, 113*C, "MediumSeaGreen" }, + { 123*C, 104*C, 238*C, "MediumSlateBlue" }, + { 0*C, 250*C, 154*C, "MediumSpringGreen" }, + { 72*C, 209*C, 204*C, "MediumTurquoise" }, + { 199*C, 21*C, 133*C, "MediumVioletRed" }, + { 25*C, 25*C, 112*C, "midnight blue" }, + { 25*C, 25*C, 112*C, "MidnightBlue" }, + { 245*C, 255*C, 250*C, "mint cream" }, + { 245*C, 255*C, 250*C, "MintCream" }, + { 255*C, 228*C, 225*C, "misty rose" }, + { 255*C, 228*C, 225*C, "MistyRose" }, + { 255*C, 228*C, 225*C, "MistyRose1" }, + { 238*C, 213*C, 210*C, "MistyRose2" }, + { 205*C, 183*C, 181*C, "MistyRose3" }, + { 139*C, 125*C, 123*C, "MistyRose4" }, + { 255*C, 228*C, 181*C, "moccasin" }, + { 255*C, 222*C, 173*C, "navajo white" }, + { 255*C, 222*C, 173*C, "NavajoWhite" }, + { 255*C, 222*C, 173*C, "NavajoWhite1" }, + { 238*C, 207*C, 161*C, "NavajoWhite2" }, + { 205*C, 179*C, 139*C, "NavajoWhite3" }, + { 139*C, 121*C, 94*C, "NavajoWhite4" }, + { 0*C, 0*C, 128*C, "navy" }, + { 0*C, 0*C, 128*C, "navy blue" }, + { 0*C, 0*C, 128*C, "NavyBlue" }, + { 253*C, 245*C, 230*C, "old lace" }, + { 253*C, 245*C, 230*C, "OldLace" }, + { 107*C, 142*C, 35*C, "olive drab" }, + { 107*C, 142*C, 35*C, "OliveDrab" }, + { 192*C, 255*C, 62*C, "OliveDrab1" }, + { 179*C, 238*C, 58*C, "OliveDrab2" }, + { 154*C, 205*C, 50*C, "OliveDrab3" }, + { 105*C, 139*C, 34*C, "OliveDrab4" }, + { 255*C, 165*C, 0*C, "orange" }, + { 255*C, 69*C, 0*C, "orange red" }, + { 255*C, 165*C, 0*C, "orange1" }, + { 238*C, 154*C, 0*C, "orange2" }, + { 205*C, 133*C, 0*C, "orange3" }, + { 139*C, 90*C, 0*C, "orange4" }, + { 255*C, 69*C, 0*C, "OrangeRed" }, + { 255*C, 69*C, 0*C, "OrangeRed1" }, + { 238*C, 64*C, 0*C, "OrangeRed2" }, + { 205*C, 55*C, 0*C, "OrangeRed3" }, + { 139*C, 37*C, 0*C, "OrangeRed4" }, + { 218*C, 112*C, 214*C, "orchid" }, + { 255*C, 131*C, 250*C, "orchid1" }, + { 238*C, 122*C, 233*C, "orchid2" }, + { 205*C, 105*C, 201*C, "orchid3" }, + { 139*C, 71*C, 137*C, "orchid4" }, + { 238*C, 232*C, 170*C, "pale goldenrod" }, + { 152*C, 251*C, 152*C, "pale green" }, + { 175*C, 238*C, 238*C, "pale turquoise" }, + { 219*C, 112*C, 147*C, "pale violet red" }, + { 238*C, 232*C, 170*C, "PaleGoldenrod" }, + { 152*C, 251*C, 152*C, "PaleGreen" }, + { 154*C, 255*C, 154*C, "PaleGreen1" }, + { 144*C, 238*C, 144*C, "PaleGreen2" }, + { 124*C, 205*C, 124*C, "PaleGreen3" }, + { 84*C, 139*C, 84*C, "PaleGreen4" }, + { 175*C, 238*C, 238*C, "PaleTurquoise" }, + { 187*C, 255*C, 255*C, "PaleTurquoise1" }, + { 174*C, 238*C, 238*C, "PaleTurquoise2" }, + { 150*C, 205*C, 205*C, "PaleTurquoise3" }, + { 102*C, 139*C, 139*C, "PaleTurquoise4" }, + { 219*C, 112*C, 147*C, "PaleVioletRed" }, + { 255*C, 130*C, 171*C, "PaleVioletRed1" }, + { 238*C, 121*C, 159*C, "PaleVioletRed2" }, + { 205*C, 104*C, 137*C, "PaleVioletRed3" }, + { 139*C, 71*C, 93*C, "PaleVioletRed4" }, + { 255*C, 239*C, 213*C, "papaya whip" }, + { 255*C, 239*C, 213*C, "PapayaWhip" }, + { 255*C, 218*C, 185*C, "peach puff" }, + { 255*C, 218*C, 185*C, "PeachPuff" }, + { 255*C, 218*C, 185*C, "PeachPuff1" }, + { 238*C, 203*C, 173*C, "PeachPuff2" }, + { 205*C, 175*C, 149*C, "PeachPuff3" }, + { 139*C, 119*C, 101*C, "PeachPuff4" }, + { 205*C, 133*C, 63*C, "peru" }, + { 255*C, 192*C, 203*C, "pink" }, + { 255*C, 181*C, 197*C, "pink1" }, + { 238*C, 169*C, 184*C, "pink2" }, + { 205*C, 145*C, 158*C, "pink3" }, + { 139*C, 99*C, 108*C, "pink4" }, + { 221*C, 160*C, 221*C, "plum" }, + { 255*C, 187*C, 255*C, "plum1" }, + { 238*C, 174*C, 238*C, "plum2" }, + { 205*C, 150*C, 205*C, "plum3" }, + { 139*C, 102*C, 139*C, "plum4" }, + { 176*C, 224*C, 230*C, "powder blue" }, + { 176*C, 224*C, 230*C, "PowderBlue" }, + { 160*C, 32*C, 240*C, "purple" }, + { 155*C, 48*C, 255*C, "purple1" }, + { 145*C, 44*C, 238*C, "purple2" }, + { 125*C, 38*C, 205*C, "purple3" }, + { 85*C, 26*C, 139*C, "purple4" }, + { 255*C, 0*C, 0*C, "red" }, + { 255*C, 0*C, 0*C, "red1" }, + { 238*C, 0*C, 0*C, "red2" }, + { 205*C, 0*C, 0*C, "red3" }, + { 139*C, 0*C, 0*C, "red4" }, + { 188*C, 143*C, 143*C, "rosy brown" }, + { 188*C, 143*C, 143*C, "RosyBrown" }, + { 255*C, 193*C, 193*C, "RosyBrown1" }, + { 238*C, 180*C, 180*C, "RosyBrown2" }, + { 205*C, 155*C, 155*C, "RosyBrown3" }, + { 139*C, 105*C, 105*C, "RosyBrown4" }, + { 65*C, 105*C, 225*C, "royal blue" }, + { 65*C, 105*C, 225*C, "RoyalBlue" }, + { 72*C, 118*C, 255*C, "RoyalBlue1" }, + { 67*C, 110*C, 238*C, "RoyalBlue2" }, + { 58*C, 95*C, 205*C, "RoyalBlue3" }, + { 39*C, 64*C, 139*C, "RoyalBlue4" }, + { 139*C, 69*C, 19*C, "saddle brown" }, + { 139*C, 69*C, 19*C, "SaddleBrown" }, + { 250*C, 128*C, 114*C, "salmon" }, + { 255*C, 140*C, 105*C, "salmon1" }, + { 238*C, 130*C, 98*C, "salmon2" }, + { 205*C, 112*C, 84*C, "salmon3" }, + { 139*C, 76*C, 57*C, "salmon4" }, + { 244*C, 164*C, 96*C, "sandy brown" }, + { 244*C, 164*C, 96*C, "SandyBrown" }, + { 46*C, 139*C, 87*C, "sea green" }, + { 46*C, 139*C, 87*C, "SeaGreen" }, + { 84*C, 255*C, 159*C, "SeaGreen1" }, + { 78*C, 238*C, 148*C, "SeaGreen2" }, + { 67*C, 205*C, 128*C, "SeaGreen3" }, + { 46*C, 139*C, 87*C, "SeaGreen4" }, + { 255*C, 245*C, 238*C, "seashell" }, + { 255*C, 245*C, 238*C, "seashell1" }, + { 238*C, 229*C, 222*C, "seashell2" }, + { 205*C, 197*C, 191*C, "seashell3" }, + { 139*C, 134*C, 130*C, "seashell4" }, + { 160*C, 82*C, 45*C, "sienna" }, + { 255*C, 130*C, 71*C, "sienna1" }, + { 238*C, 121*C, 66*C, "sienna2" }, + { 205*C, 104*C, 57*C, "sienna3" }, + { 139*C, 71*C, 38*C, "sienna4" }, + { 135*C, 206*C, 235*C, "sky blue" }, + { 135*C, 206*C, 235*C, "SkyBlue" }, + { 135*C, 206*C, 255*C, "SkyBlue1" }, + { 126*C, 192*C, 238*C, "SkyBlue2" }, + { 108*C, 166*C, 205*C, "SkyBlue3" }, + { 74*C, 112*C, 139*C, "SkyBlue4" }, + { 106*C, 90*C, 205*C, "slate blue" }, + { 112*C, 128*C, 144*C, "slate gray" }, + { 112*C, 128*C, 144*C, "slate grey" }, + { 106*C, 90*C, 205*C, "SlateBlue" }, + { 131*C, 111*C, 255*C, "SlateBlue1" }, + { 122*C, 103*C, 238*C, "SlateBlue2" }, + { 105*C, 89*C, 205*C, "SlateBlue3" }, + { 71*C, 60*C, 139*C, "SlateBlue4" }, + { 112*C, 128*C, 144*C, "SlateGray" }, + { 198*C, 226*C, 255*C, "SlateGray1" }, + { 185*C, 211*C, 238*C, "SlateGray2" }, + { 159*C, 182*C, 205*C, "SlateGray3" }, + { 108*C, 123*C, 139*C, "SlateGray4" }, + { 112*C, 128*C, 144*C, "SlateGrey" }, + { 255*C, 250*C, 250*C, "snow" }, + { 255*C, 250*C, 250*C, "snow1" }, + { 238*C, 233*C, 233*C, "snow2" }, + { 205*C, 201*C, 201*C, "snow3" }, + { 139*C, 137*C, 137*C, "snow4" }, + { 0*C, 255*C, 127*C, "spring green" }, + { 0*C, 255*C, 127*C, "SpringGreen" }, + { 0*C, 255*C, 127*C, "SpringGreen1" }, + { 0*C, 238*C, 118*C, "SpringGreen2" }, + { 0*C, 205*C, 102*C, "SpringGreen3" }, + { 0*C, 139*C, 69*C, "SpringGreen4" }, + { 70*C, 130*C, 180*C, "steel blue" }, + { 70*C, 130*C, 180*C, "SteelBlue" }, + { 99*C, 184*C, 255*C, "SteelBlue1" }, + { 92*C, 172*C, 238*C, "SteelBlue2" }, + { 79*C, 148*C, 205*C, "SteelBlue3" }, + { 54*C, 100*C, 139*C, "SteelBlue4" }, + { 210*C, 180*C, 140*C, "tan" }, + { 255*C, 165*C, 79*C, "tan1" }, + { 238*C, 154*C, 73*C, "tan2" }, + { 205*C, 133*C, 63*C, "tan3" }, + { 139*C, 90*C, 43*C, "tan4" }, + { 216*C, 191*C, 216*C, "thistle" }, + { 255*C, 225*C, 255*C, "thistle1" }, + { 238*C, 210*C, 238*C, "thistle2" }, + { 205*C, 181*C, 205*C, "thistle3" }, + { 139*C, 123*C, 139*C, "thistle4" }, + { 255*C, 99*C, 71*C, "tomato" }, + { 255*C, 99*C, 71*C, "tomato1" }, + { 238*C, 92*C, 66*C, "tomato2" }, + { 205*C, 79*C, 57*C, "tomato3" }, + { 139*C, 54*C, 38*C, "tomato4" }, + { 64*C, 224*C, 208*C, "turquoise" }, + { 0*C, 245*C, 255*C, "turquoise1" }, + { 0*C, 229*C, 238*C, "turquoise2" }, + { 0*C, 197*C, 205*C, "turquoise3" }, + { 0*C, 134*C, 139*C, "turquoise4" }, + { 238*C, 130*C, 238*C, "violet" }, + { 208*C, 32*C, 144*C, "violet red" }, + { 208*C, 32*C, 144*C, "VioletRed" }, + { 255*C, 62*C, 150*C, "VioletRed1" }, + { 238*C, 58*C, 140*C, "VioletRed2" }, + { 205*C, 50*C, 120*C, "VioletRed3" }, + { 139*C, 34*C, 82*C, "VioletRed4" }, + { 245*C, 222*C, 179*C, "wheat" }, + { 255*C, 231*C, 186*C, "wheat1" }, + { 238*C, 216*C, 174*C, "wheat2" }, + { 205*C, 186*C, 150*C, "wheat3" }, + { 139*C, 126*C, 102*C, "wheat4" }, + { 255*C, 255*C, 255*C, "white" }, + { 245*C, 245*C, 245*C, "white smoke" }, + { 245*C, 245*C, 245*C, "WhiteSmoke" }, + { 255*C, 255*C, 0*C, "yellow" }, + { 154*C, 205*C, 50*C, "yellow green" }, + { 255*C, 255*C, 0*C, "yellow1" }, + { 238*C, 238*C, 0*C, "yellow2" }, + { 205*C, 205*C, 0*C, "yellow3" }, + { 139*C, 139*C, 0*C, "yellow4" }, + { 154*C, 205*C, 50*C, "YellowGreen" } +}; + +#undef C + +#define NUM_KD_COLORS (sizeof (KdColors) / sizeof (KdColors[0])) + +Bool +OsInitColors() +{ + return TRUE; +} + +Bool +OsLookupColor(int screen, + char *s_name, + unsigned int len, + unsigned short *pred, + unsigned short *pgreen, + unsigned short *pblue) +{ + const KdNamedColor *c; + unsigned char *name = (unsigned char *) s_name; + int low, mid, high; + int r; + + low = 0; + high = NUM_KD_COLORS; + while (high - low > 0) + { + mid = (low + high) / 2; + c = &KdColors[mid]; + r = KdStrCaseCmp (c->name, name, len); + if (r == 0) + { + *pred = c->red; + *pgreen = c->green; + *pblue = c->blue; + return TRUE; + } + if (r < 0) + { + if (high == mid) + break; + high = mid; + } + else + { + if (low == mid) + break; + low = mid; + } + } + return FALSE; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/vxworks/vxworks.c +++ xorg-server-1.4.99.906/hw/kdrive/vxworks/vxworks.c @@ -0,0 +1,42 @@ +/* + * Copyright © 1999 Network Computing Devices, Inc. All rights reserved. + * + * Author: Keith Packard + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "kdrive.h" +#include + +Bool +VxWorksSpecialKey (KeySym sym) +{ + switch (sym) { + case XK_Sys_Req: + download(1, "setup", 0); + return TRUE; + case XK_Break: + download(1, "launcher", 0); + return TRUE; + } + return FALSE; +} + +void +KdOsAddInputDrivers (void) +{ + KdAddPointerDriver(&VxWorksMouseDriver); + KdAddPointerDriver(&VxWorksKeyboardDriver); +} + +KdOsFuncs VxWorksFuncs = { + .SpecialKey = VxWorksSpecialKey, +}; + +void +OsVendorInit (void) +{ + KdOsInit (&VxWorksFuncs); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/vxworks/vxmouse.c +++ xorg-server-1.4.99.906/hw/kdrive/vxworks/vxmouse.c @@ -0,0 +1,122 @@ +/* + * Copyright © 1999 Network Computing Devices, Inc. All rights reserved. + * + * Author: Keith Packard + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#define NEED_EVENTS +#include +#include +#include "inputstr.h" +#include "scrnintstr.h" +#include "kdrive.h" +#include "Xpoll.h" +#include +#include + +static unsigned long mouseState; + +#define BUTTON1 0x01 +#define BUTTON2 0x02 +#define BUTTON3 0x04 + +#include + +static int mouseFd = -1; + +static eventqueue *eventQueue; + +void +VxMouseRead (int mousePort) +{ + Event ev; + int dx, dy; + unsigned long flags; + unsigned long mask; + int n; + + while (eventQueue->head != eventQueue->tail) + { + ev = *eventQueue->head; + if (eventQueue->head >= &eventQueue->events[eventQueue->size-1]) + eventQueue->head = &eventQueue->events[0]; + else + eventQueue->head++; + switch (ev.e_type) { + case E_BUTTON: + switch (ev.e_device) { + case E_MOUSE: + switch (ev.e_key) { + case BUTTON1: + mask = KD_BUTTON_1; + break; + case BUTTON2: + mask = KD_BUTTON_2; + break; + case BUTTON3: + mask = KD_BUTTON_3; + break; + default: + mask = 0; + break; + } + if (ev.e_direction == E_KBUP) + mouseState &= ~mask; + else + mouseState |= mask; + KdEnqueueMouseEvent (mouseState | KD_MOUSE_DELTA, 0, 0); + break; + case E_DKB: + KdEnqueueKeyboardEvent (ev.e_key, ev.e_direction == E_KBUP); + break; + } + break; + case E_MMOTION: + KdEnqueueMouseEvent (mouseState | KD_MOUSE_DELTA, + ev.e_x, ev.e_y); + break; + } + } +} + +int +VxMouseInit (void) +{ + int mousePort; + unsigned long ev_size; + + mouseState = 0; + mousePort = open ("/dev/xdev", O_RDONLY, 0); + if (mousePort < 0) + ErrorF ("event port open failure %d\n", errno); + mouseFd = open ("/dev/mouse", O_RDONLY, 0); + if (mouseFd < 0) + ErrorF ("mouse open failure %d\n", errno); + if (eventQueue == 0) + { + ioctl (mousePort, EVENT_QUEUE_SMSIZE, &ev_size); + eventQueue = (eventqueue *) smem_get ("event", ev_size, (SM_READ|SM_WRITE)); + } + return mousePort; +} + +void +VxMouseFini (int mousePort) +{ + if (mousePort >= 0) + close (mousePort); + if (mouseFd >= 0) + { + close (mouseFd); + mouseFd = -1; + } +} + +KdMouseFuncs VxWorksMouseFuncs = { + VxMouseInit, + VxMouseRead, + VxMouseFini +}; --- xorg-server-1.4.99.906.orig/hw/kdrive/vxworks/vxkbd.c +++ xorg-server-1.4.99.906/hw/kdrive/vxworks/vxkbd.c @@ -0,0 +1,263 @@ +/* + * Copyright © 1999 Network Computing Devices, Inc. All rights reserved. + * + * Author: Keith Packard + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "kdrive.h" +#include "kkeymap.h" +#include +#include + +#define VXWORKS_WIDTH 2 + +KeySym VxWorksKeymap[] = { +/*7 f1 */ XK_F1, NoSymbol, +/*8 escape */ XK_Escape, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, +/*13 tab */ XK_Tab, NoSymbol, +/*14 ` */ XK_grave, XK_asciitilde, +/*15 f2 */ XK_F2, NoSymbol, + NoSymbol, NoSymbol, +/*17 lctrl */ XK_Control_L, NoSymbol, +/*18 lshift */ XK_Shift_L, NoSymbol, + NoSymbol, NoSymbol, +/*20 lock */ XK_Caps_Lock, NoSymbol, +/*21 q */ XK_Q, NoSymbol, +/*22 1 */ XK_1, XK_exclam, +/*23 f3 */ XK_F3, NoSymbol, + NoSymbol, NoSymbol, +/*25 lalt */ XK_Meta_L, XK_Alt_L, +/*26 z */ XK_Z, NoSymbol, +/*27 s */ XK_S, NoSymbol, +/*28 a */ XK_A, NoSymbol, +/*29 w */ XK_W, NoSymbol, +/*30 2 */ XK_2, XK_at, +/*31 f4 */ XK_F4, NoSymbol, + NoSymbol, NoSymbol, +/*33 c */ XK_C, NoSymbol, +/*34 x */ XK_X, NoSymbol, +/*35 d */ XK_D, NoSymbol, +/*36 e */ XK_E, NoSymbol, +/*37 4 */ XK_4, XK_dollar, +/*38 3 */ XK_3, XK_numbersign, +/*39 f5 */ XK_F5, NoSymbol, + NoSymbol, NoSymbol, +/*41 space */ XK_space, NoSymbol, +/*42 v */ XK_V, NoSymbol, +/*43 f */ XK_F, NoSymbol, +/*44 t */ XK_T, NoSymbol, +/*45 r */ XK_R, NoSymbol, +/*46 5 */ XK_5, XK_percent, +/*47 f6 */ XK_F6, NoSymbol, + NoSymbol, NoSymbol, +/*49 n */ XK_N, NoSymbol, +/*50 b */ XK_B, NoSymbol, +/*51 h */ XK_H, NoSymbol, +/*52 g */ XK_G, NoSymbol, +/*53 y */ XK_Y, NoSymbol, +/*54 6 */ XK_6, XK_asciicircum, +/*55 f7 */ XK_F7, NoSymbol, + NoSymbol, NoSymbol, +/*57 ralt */ XK_Meta_R, XK_Alt_R, +/*58 m */ XK_M, NoSymbol, +/*59 j */ XK_J, NoSymbol, +/*60 u */ XK_U, NoSymbol, +/*61 7 */ XK_7, XK_ampersand, +/*62 8 */ XK_8, XK_asterisk, +/*63 f8 */ XK_F8, NoSymbol, + NoSymbol, NoSymbol, +/*65 , */ XK_comma, XK_less, +/*66 k */ XK_K, NoSymbol, +/*67 i */ XK_I, NoSymbol, +/*68 o */ XK_O, NoSymbol, +/*69 0 */ XK_0, XK_parenright, +/*70 9 */ XK_9, XK_parenleft, +/*71 f9 */ XK_F9, NoSymbol, + NoSymbol, NoSymbol, +/*73 . */ XK_period, XK_greater, +/*74 / */ XK_slash, XK_question, +/*75 l */ XK_L, NoSymbol, +/*76 ; */ XK_semicolon, XK_colon, +/*77 p */ XK_P, NoSymbol, +/*78 - */ XK_minus, XK_underscore, +/*79 f10 */ XK_F10, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, +/*82 ' */ XK_apostrophe, XK_quotedbl, + NoSymbol, NoSymbol, +/*84 [ */ XK_bracketleft, XK_braceleft, +/*85 = */ XK_equal, XK_plus, +/*86 f11 */ XK_F11, NoSymbol, +/*87 sysrq */ XK_Sys_Req, XK_Print, +/*88 rctrl */ XK_Control_R, NoSymbol, +/*89 rshift */ XK_Shift_R, NoSymbol, +/*90 enter */ XK_Return, NoSymbol, +/*91 ] */ XK_bracketright, XK_braceright, +/*92 \ */ XK_backslash, XK_bar, + NoSymbol, NoSymbol, +/*94 f12 */ XK_F12, NoSymbol, +/*95 scrolllock*/ XK_Scroll_Lock, NoSymbol, +/*96 down */ XK_Down, NoSymbol, +/*97 left */ XK_Left, NoSymbol, +/*98 pause */ XK_Break, XK_Pause, +/*99 up */ XK_Up, NoSymbol, +/*100 delete */ XK_Delete, NoSymbol, +/*101 end */ XK_End, NoSymbol, +/*102 bs */ XK_BackSpace, NoSymbol, +/*103 insert */ XK_Insert, NoSymbol, + NoSymbol, NoSymbol, +/*105 np 1 */ XK_KP_End, XK_KP_1, +/*106 right */ XK_Right, NoSymbol, +/*107 np 4 */ XK_KP_Left, XK_KP_4, +/*108 np 7 */ XK_KP_Home, XK_KP_7, +/*109 pgdn */ XK_Page_Down, NoSymbol, +/*110 home */ XK_Home, NoSymbol, +/*111 pgup */ XK_Page_Up, NoSymbol, +/*112 np 0 */ XK_KP_Insert, XK_KP_0, +/*113 np . */ XK_KP_Delete, XK_KP_Decimal, +/*114 np 2 */ XK_KP_Down, XK_KP_2, +/*115 np 5 */ XK_KP_5, NoSymbol, +/*116 np 6 */ XK_KP_Right, XK_KP_6, +/*117 np 8 */ XK_KP_Up, XK_KP_8, +/*118 numlock */ XK_Num_Lock, NoSymbol, +/*119 np / */ XK_KP_Divide, NoSymbol, + NoSymbol, NoSymbol, +/*121 np enter */ XK_KP_Enter, NoSymbol, +/*122 np 3 */ XK_KP_Page_Down, XK_KP_3, + NoSymbol, NoSymbol, +/*124 np + */ XK_KP_Add, NoSymbol, +/*125 np 9 */ XK_KP_Page_Up, XK_KP_9, +/*126 np * */ XK_KP_Multiply, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, +/*132 np - */ XK_KP_Subtract, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, +/*139 lwin */ XK_Super_L, NoSymbol, +/*140 rwin */ XK_Super_R, NoSymbol, +/*141 menu */ XK_Menu, NoSymbol, +}; + +void +VxWorksKeyboardLoad (void) +{ + KeySym *k; + + kdMinScanCode = 7; + kdKeymapWidth = VXWORKS_WIDTH; + kdMaxScanCode = 141; + memcpy (kdKeymap, VxWorksKeymap, sizeof (VxWorksKeymap)); +} + +static int kbdFd = -1; + +#include +#include +#include + +extern KeyboardCtrl defaultKeyboardControl; + +static void +VxWorksSetAutorepeat (unsigned char *repeats, Bool on) +{ + int i; + unsigned char mask; + int scan_code; + int key_code; + unsigned char realkc; + + if (on) + { + realkc = 1; + ioctl (kbdFd, KBD_ALL_REPEAT, &realkc); + for (scan_code = 7; scan_code <= 141; scan_code++) + { + key_code = scan_code + 1; + i = key_code >> 3; + mask = 1 << (key_code & 7); + if ((repeats[i] & mask) == 0) + { + realkc = scan_code; + ioctl (kbdFd, KBD_NO_REPEAT, &realkc); + } + } + } + else + { + realkc = 0; + ioctl (kbdFd, KBD_ALL_REPEAT, &realkc); + } +} + +int +VxWorksKeyboardInit (void) +{ + + kbdFd = open ("/dev/kbd", O_RDONLY, 0); + if (kbdFd < 0) + ErrorF ("keyboard open failure %d\n", errno); + VxWorksSetAutorepeat (defaultKeyboardControl.autoRepeats, TRUE); + return -1; +} + +void +VxWorksKeyboardFini (int fd) +{ + if (kbdFd >= 0) + { + close (kbdFd); + kbdFd = -1; + } +} + +void +VxWorksKeyboardRead (int fd) +{ +} + +void +VxWorksKeyboardLeds (int leds) +{ + DeviceIntPtr pKeyboard = inputInfo.keyboard; + KeyboardCtrl *ctrl = &pKeyboard->kbdfeed->ctrl; + led_ioctl_info led_info; + int i; + + VxWorksSetAutorepeat (ctrl->autoRepeats, ctrl->autoRepeat); + for (i = 0; i < 3; i++) + { + led_info.bit_n = 1 << i; + led_info.OFF_or_ON = (leds & (1 << i)) != 0; + led_info.reversed = 0; + ioctl (kbdFd, KBD_SET_LED, &led_info); + } +} + +void +VxWorksKeyboardBell (int volume, int frequency, int duration) +{ +} + +KdKeyboardFuncs VxWorksKeyboardFuncs = { + VxWorksKeyboardLoad, + VxWorksKeyboardInit, + VxWorksKeyboardRead, + VxWorksKeyboardLeds, + VxWorksKeyboardBell, + VxWorksKeyboardFini, + 3, +}; --- xorg-server-1.4.99.906.orig/hw/kdrive/Kdrive.tmpl +++ xorg-server-1.4.99.906/hw/kdrive/Kdrive.tmpl @@ -0,0 +1,17 @@ +XCOMM $RCSId: xc/programs/Xserver/hw/kdrive/Kdrive.tmpl,v 1.3tsi Exp $ + +#include + +#if BuildRender +RENDERINCS=-I$(KDRIVE)/../../render +#endif + +#if BuildRandR +RANDRINCS=-I$(KDRIVE)/../../randr +#endif + +KDINCS = -I$(KDRIVE) -I$(XBUILDINCDIR) -I$(FONTINCSRC) \ + -I$(KDRIVE)/../../fb -I$(KDRIVE)/../../mi -I$(KDRIVE)/../../Xext \ + -I$(KDRIVE)/../../miext/shadow -I$(KDRIVE)/../../miext/layer \ + -I$(KDRIVE)/../../include -I$(KDRIVE)/../../os \ + -I$(EXTINCSRC) -I$(XINCLUDESRC) $(RENDERINCS) $(RANDRINCS) --- xorg-server-1.4.99.906.orig/hw/kdrive/sis530/sisstub.c +++ xorg-server-1.4.99.906/hw/kdrive/sis530/sisstub.c @@ -0,0 +1,67 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "sis.h" + +static const int sisCards[] = { 0x6306, 0x0200 }; + +#define numSisCards (sizeof (sisCards) / sizeof (sisCards[0])) + +void +InitCard (char *name) +{ + KdCardAttr attr; + int i; + + for (i = 0; i < numSisCards; i++) + if (LinuxFindPci (0x1039, sisCards[i], 0, &attr)) + KdCardInfoAdd (&sisFuncs, &attr, (void *) sisCards[i]); +} + +void +InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) +{ + KdInitOutput (pScreenInfo, argc, argv); +} + +void +InitInput (int argc, char **argv) +{ + KdOsAddInputDrivers (); + KdInitInput (); +} + +void +ddxUseMsg (void) +{ + KdUseMsg(); +} + +int +ddxProcessArgument (int argc, char **argv, int i) +{ + return KdProcessArgument (argc, argv, i); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/sis530/sisdraw.c +++ xorg-server-1.4.99.906/hw/kdrive/sis530/sisdraw.c @@ -0,0 +1,1649 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "sis.h" +#include "sisdraw.h" + +#include "Xmd.h" +#include "gcstruct.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "regionstr.h" +#include "mistruct.h" +#include "fontstruct.h" +#include "dixfontstr.h" +#include "fb.h" +#include "migc.h" +#include "miline.h" + +CARD8 sisPatRop[16] = { + /* GXclear */ 0x00, /* 0 */ + /* GXand */ 0xa0, /* src AND dst */ + /* GXandReverse */ 0x50, /* src AND NOT dst */ + /* GXcopy */ 0xf0, /* src */ + /* GXandInverted*/ 0x0a, /* NOT src AND dst */ + /* GXnoop */ 0xaa, /* dst */ + /* GXxor */ 0x5a, /* src XOR dst */ + /* GXor */ 0xfa, /* src OR dst */ + /* GXnor */ 0x05, /* NOT src AND NOT dst */ + /* GXequiv */ 0xa5, /* NOT src XOR dst */ + /* GXinvert */ 0x55, /* NOT dst */ + /* GXorReverse */ 0xf5, /* src OR NOT dst */ + /* GXcopyInverted*/ 0x0f, /* NOT src */ + /* GXorInverted */ 0xaf, /* NOT src OR dst */ + /* GXnand */ 0x5f, /* NOT src OR NOT dst */ + /* GXset */ 0xff, /* 1 */ +}; + +CARD8 sisBltRop[16] = { + /* GXclear */ 0x00, /* 0 */ + /* GXand */ 0x88, /* src AND dst */ + /* GXandReverse */ 0x44, /* src AND NOT dst */ + /* GXcopy */ 0xcc, /* src */ + /* GXandInverted*/ 0x22, /* NOT src AND dst */ + /* GXnoop */ 0xaa, /* dst */ + /* GXxor */ 0x66, /* src XOR dst */ + /* GXor */ 0xee, /* src OR dst */ + /* GXnor */ 0x11, /* NOT src AND NOT dst */ + /* GXequiv */ 0x99, /* NOT src XOR dst */ + /* GXinvert */ 0x55, /* NOT dst */ + /* GXorReverse */ 0xdd, /* src OR NOT dst */ + /* GXcopyInverted*/ 0x33, /* NOT src */ + /* GXorInverted */ 0xbb, /* NOT src OR dst */ + /* GXnand */ 0x77, /* NOT src OR NOT dst */ + /* GXset */ 0xff, /* 1 */ +}; + +/* Align blts to this boundary or risk trashing an in-progress expand */ +#define SIS_MIN_PATTERN 8 + +/* Do plane bits in this increment to balance CPU and graphics engine */ +#define SIS_PATTERN_INC 1024 + +typedef struct _SisExpand { + SisCardInfo *sisc; + SisScreenInfo *siss; + CARD32 off; + int last; +} SisExpand; + +static void +sisExpandInit (ScreenPtr pScreen, + SisExpand *e) +{ + KdScreenPriv(pScreen); + sisCardInfo(pScreenPriv); + sisScreenInfo(pScreenPriv); + + e->sisc = sisc; + e->siss = siss; + e->off = siss->expand_off; + e->last = 0; +} + +static CARD32 * +sisExpandAlloc (SisExpand *e, + int nb) +{ + SisCardInfo *sisc = e->sisc; + SisScreenInfo *siss = e->siss; + SisPtr sis = sisc->sis; + CARD32 off; + + /* round up to alignment boundary */ + nb = (nb + SIS_MIN_PATTERN-1) & ~(SIS_MIN_PATTERN-1); + + off = e->off + e->last; + if (off + nb > siss->expand_off + siss->expand_len) + { + _sisWaitIdleEmpty (sis); + off = siss->expand_off; + } + e->off = off; + e->last = nb; + return (CARD32 *) (sisc->frameBuffer + off); +} + +void +sisGlyphBltClipped (DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppciInit, + Bool imageBlt) +{ + SetupSis(pDrawable->pScreen); + FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); + int height; + int width; + int xBack, yBack; + int hBack, wBack; + int nb, bwidth, nl; + FontPtr pfont = pGC->font; + CharInfoPtr pci; + CARD8 *bits8, b; + CARD16 *bits16; + CARD32 *bits32; + BoxPtr extents; + BoxRec bbox; + unsigned char alu; + CARD32 cmd; + SisExpand expand; + CARD32 *dst, d; + int nbytes; + int shift; + int x1, y1, x2, y2; + RegionPtr pClip = fbGetCompositeClip(pGC); + BoxPtr pBox; + int nbox; + int rect_in; + int widthBlt; + CharInfoPtr *ppci; + + x += pDrawable->x; + y += pDrawable->y; + + if (imageBlt) + { + xBack = x; + yBack = y - FONTASCENT(pGC->font); + wBack = 0; + hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); + if (hBack) + { + height = nglyph; + ppci = ppciInit; + while (height--) + wBack += (*ppci++)->metrics.characterWidth; + } + if (wBack < 0) + { + xBack = xBack + wBack; + wBack = -wBack; + } + if (hBack < 0) + { + yBack = yBack + hBack; + hBack = -hBack; + } + alu = GXcopy; + } + else + { + wBack = 0; + alu = pGC->alu; + } + + if (wBack) + { + _sisSetSolidRect (sis, pGC->bgPixel, GXcopy, cmd); + for (nbox = REGION_NUM_RECTS (pClip), + pBox = REGION_RECTS (pClip); + nbox--; + pBox++) + { + x1 = xBack; + x2 = xBack + wBack; + y1 = yBack; + y2 = yBack + hBack; + if (x1 < pBox->x1) x1 = pBox->x1; + if (x2 > pBox->x2) x2 = pBox->x2; + if (y1 < pBox->y1) y1 = pBox->y1; + if (y2 > pBox->y2) y2 = pBox->y2; + if (x1 < x2 && y1 < y2) + { + _sisRect (sis, x1, y1, x2 - x1, y2 - y1, cmd); + } + } + } + + sisExpandInit (pDrawable->pScreen, &expand); + + sis->u.general.src_fg = pGC->fgPixel; + sis->u.general.src_pitch = 0; + sis->u.general.src_x = 0; + sis->u.general.src_y = 0; + + cmd = (SIS_CMD_ENH_COLOR_EXPAND | + SIS_CMD_SRC_SCREEN | + SIS_CMD_PAT_FG | + (sisBltRop[alu] << 8) | + SIS_CMD_INC_X | + SIS_CMD_INC_Y | + SIS_CMD_RECT_CLIP_ENABLE | + SIS_CMD_TRANSPARENT); + + ppci = ppciInit; + while (nglyph--) + { + pci = *ppci++; + height = pci->metrics.ascent + pci->metrics.descent; + width = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; + widthBlt = (width + 31) & ~31; + nb = (widthBlt >> 3) * height; + if (nb) + { + x1 = x + pci->metrics.leftSideBearing; + y1 = y - pci->metrics.ascent; + bbox.x1 = x1; + bbox.y1 = y1; + bbox.x2 = x1 + width; + bbox.y2 = y1 + height; + rect_in = RECT_IN_REGION(pGC->pScreen, pClip, &bbox); + if (rect_in != rgnOUT) + { + dst = sisExpandAlloc (&expand, nb); + + sis->u.general.src_base = expand.off; + sis->u.general.dst_x = x1; + sis->u.general.dst_y = y1; + sis->u.general.rect_width = widthBlt; + sis->u.general.rect_height = height; + nb >>= 2; + bits32 = (CARD32 *) pci->bits; + while (nb--) + { + d = *bits32++; + SisInvertBits32 (d); + *dst++ = d; + } + if (rect_in == rgnPART) + { + for (nbox = REGION_NUM_RECTS (pClip), + pBox = REGION_RECTS (pClip); + nbox--; + pBox++) + { + _sisClip (sis, pBox->x1, pBox->y1, pBox->x2, pBox->y2); + sis->u.general.command = cmd; + } + } + else + { + _sisClip (sis, 0, 0, x1+width, pScreenPriv->screen->height); + sis->u.general.command = cmd; + } + } + } + x += pci->metrics.characterWidth; + } + _sisClip (sis, 0, 0, + pScreenPriv->screen->width, pScreenPriv->screen->height); + KdMarkSync (pDrawable->pScreen); +} + +Bool +sisTEGlyphBlt (DrawablePtr pDrawable, + GCPtr pGC, + int xInit, + int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + Bool imageBlt) +{ + SetupSis(pDrawable->pScreen); + int x, y; + int widthGlyphs, widthGlyph; + int widthBlt; + FbBits depthMask; + int glyphsPer; + FontPtr pfont = pGC->font; + unsigned long *char1, *char2, *char3, *char4, *char5; + CARD8 alu; + CARD32 *dst, tmp; + CARD8 *dst8, *bits8; + int nb; + int bwidth; + CARD32 cmd; + int h; + BoxRec bbox; + SisExpand expand; + int lwTmp, lw; + int extra, n; + + widthGlyph = FONTMAXBOUNDS(pfont,characterWidth); + if (!widthGlyph) + return TRUE; + + h = FONTASCENT(pfont) + FONTDESCENT(pfont); + if (!h) + return TRUE; + + x = xInit + FONTMAXBOUNDS(pfont,leftSideBearing) + pDrawable->x; + y = yInit - FONTASCENT(pfont) + pDrawable->y; + + bbox.x1 = x; + bbox.x2 = x + (widthGlyph * nglyph); + bbox.y1 = y; + bbox.y2 = y + h; + + switch (RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox)) + { + case rgnPART: + if (x < 0 || y < 0) + return FALSE; + sisGlyphBltClipped (pDrawable, pGC, xInit, yInit, nglyph, ppci, imageBlt); + case rgnOUT: + return TRUE; + } + + if (widthGlyph <= 6) + glyphsPer = 5; + else if (widthGlyph <= 8) + glyphsPer = 4; + else if (widthGlyph <= 10) + glyphsPer = 3; + else if (widthGlyph <= 16) + glyphsPer = 2; + else + glyphsPer = 1; + + widthGlyphs = widthGlyph * glyphsPer; + widthBlt = widthGlyphs; + + /* make sure scanlines are 32-bit aligned */ + if (widthGlyphs <= 24) + widthBlt = 25; + + cmd = (SIS_CMD_ENH_COLOR_EXPAND | + SIS_CMD_SRC_SCREEN | + SIS_CMD_PAT_FG | + SIS_CMD_INC_X | + SIS_CMD_INC_Y); + + if (imageBlt) + { + sis->u.general.clip_right = bbox.x2; + cmd |= ((sisBltRop[GXcopy] << 8) | + SIS_CMD_OPAQUE | + SIS_CMD_RECT_CLIP_ENABLE); + } + else + { + cmd |= ((sisBltRop[pGC->alu] << 8) | + SIS_CMD_TRANSPARENT | + SIS_CMD_RECT_CLIP_DISABLE); + } + + sisExpandInit (pDrawable->pScreen, &expand); + + sis->u.general.src_fg = pGC->fgPixel; + sis->u.general.src_bg = pGC->bgPixel; + + bwidth = (widthBlt + 7) >> 3; + + nb = bwidth * h; + +#define LoopIt(count, loadup, fetch) \ + while (nglyph >= count) \ + { \ + nglyph -= count; \ + dst = sisExpandAlloc (&expand, nb); \ + sis->u.general.src_base = expand.off; \ + sis->u.general.src_pitch = 0; \ + sis->u.general.src_x = 0; \ + sis->u.general.src_y = 0; \ + sis->u.general.dst_x = x; \ + sis->u.general.dst_y = y; \ + sis->u.general.rect_width = widthBlt; \ + sis->u.general.rect_height = h; \ + x += widthGlyphs; \ + loadup \ + lwTmp = h; \ + while (lwTmp--) { \ + tmp = fetch; \ + SisInvertBits32(tmp); \ + *dst++ = tmp; \ + } \ + sis->u.general.command = cmd; \ + } + + switch (glyphsPer) { + case 5: + LoopIt(5, + char1 = (unsigned long *) (*ppci++)->bits; + char2 = (unsigned long *) (*ppci++)->bits; + char3 = (unsigned long *) (*ppci++)->bits; + char4 = (unsigned long *) (*ppci++)->bits; + char5 = (unsigned long *) (*ppci++)->bits;, + (*char1++ | ((*char2++ | ((*char3++ | ((*char4++ | (*char5++ + << widthGlyph)) + << widthGlyph)) + << widthGlyph)) + << widthGlyph))); + break; + case 4: + LoopIt(4, + char1 = (unsigned long *) (*ppci++)->bits; + char2 = (unsigned long *) (*ppci++)->bits; + char3 = (unsigned long *) (*ppci++)->bits; + char4 = (unsigned long *) (*ppci++)->bits;, + (*char1++ | ((*char2++ | ((*char3++ | (*char4++ + << widthGlyph)) + << widthGlyph)) + << widthGlyph))); + break; + case 3: + LoopIt(3, + char1 = (unsigned long *) (*ppci++)->bits; + char2 = (unsigned long *) (*ppci++)->bits; + char3 = (unsigned long *) (*ppci++)->bits;, + (*char1++ | ((*char2++ | (*char3++ << widthGlyph)) << widthGlyph))); + break; + case 2: + LoopIt(2, + char1 = (unsigned long *) (*ppci++)->bits; + char2 = (unsigned long *) (*ppci++)->bits;, + (*char1++ | (*char2++ << widthGlyph))); + break; + } + + widthBlt = (widthGlyph + 31) & ~31; + + bwidth = widthBlt >> 3; + + nb = bwidth * h; + + lw = (widthBlt >> 5) * h; + + while (nglyph--) + { + dst = (CARD32 *) sisExpandAlloc (&expand, nb); + char1 = (CARD32 *) (*ppci++)->bits; + sis->u.general.src_base = expand.off; + sis->u.general.src_pitch = 0; + sis->u.general.src_x = 0; + sis->u.general.src_y = 0; + sis->u.general.dst_x = x; + sis->u.general.dst_y = y; + sis->u.general.rect_width = widthBlt; + sis->u.general.rect_height = h; + lwTmp = lw; + while (lwTmp--) + { + tmp = *char1++; + SisInvertBits32 (tmp); + *dst++ = tmp; + } + sis->u.general.command = cmd; + x += widthGlyph; + } + if (imageBlt) + sis->u.general.clip_right = pScreenPriv->screen->width; + KdMarkSync (pDrawable->pScreen); + return TRUE; +} + +Bool +sisGlyphBlt(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppciInit, + Bool imageBlt) +{ + SetupSis(pDrawable->pScreen); + int height; + int width; + int xBack, yBack; + int hBack, wBack; + int nb, bwidth, nl; + FontPtr pfont = pGC->font; + CharInfoPtr pci; + CARD8 *bits8, b; + CARD16 *bits16; + CARD32 *bits32; + BoxPtr extents; + BoxRec bbox; + CharInfoPtr *ppci; + unsigned char alu; + CARD32 cmd; + SisExpand expand; + CARD32 *dst, d; + int nbytes; + int shift; + + x += pDrawable->x; + y += pDrawable->y; + + /* compute an approximate (but covering) bounding box */ + ppci = ppciInit; + width = 0; + height = nglyph; + while (height--) + width += (*ppci++)->metrics.characterWidth; + if (width < 0) + { + bbox.x1 = x + width; + bbox.x2 = x; + } + else + { + bbox.x1 = x; + bbox.x2 = x + width; + } + width = FONTMINBOUNDS(pfont,leftSideBearing); + if (width < 0) + bbox.x1 += width; + width = FONTMAXBOUNDS(pfont, rightSideBearing) - FONTMINBOUNDS(pfont, characterWidth); + if (width > 0) + bbox.x2 += width; + bbox.y1 = y - FONTMAXBOUNDS(pfont,ascent); + bbox.y2 = y + FONTMAXBOUNDS(pfont,descent); + + switch (RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox)) + { + case rgnPART: + if (bbox.x1 < 0 || bbox.y1 < 0) + return FALSE; + sisGlyphBltClipped (pDrawable, pGC, + x - pDrawable->x, y - pDrawable->y, + nglyph, ppciInit, imageBlt); + case rgnOUT: + return TRUE; + } + + if (imageBlt) + { + xBack = x; + yBack = y - FONTASCENT(pGC->font); + wBack = 0; + hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); + if (hBack) + { + height = nglyph; + ppci = ppciInit; + while (height--) + wBack += (*ppci++)->metrics.characterWidth; + } + if (wBack < 0) + { + xBack = xBack + wBack; + wBack = -wBack; + } + if (hBack < 0) + { + yBack = yBack + hBack; + hBack = -hBack; + } + alu = GXcopy; + } + else + { + wBack = 0; + alu = pGC->alu; + } + + if (wBack) + { + _sisSetSolidRect (sis, pGC->bgPixel, GXcopy, cmd); + _sisRect (sis, xBack, yBack, wBack, hBack, cmd); + } + + sisExpandInit (pDrawable->pScreen, &expand); + + sis->u.general.src_fg = pGC->fgPixel; + + cmd = (SIS_CMD_ENH_COLOR_EXPAND | + SIS_CMD_SRC_SCREEN | + SIS_CMD_PAT_FG | + (sisBltRop[alu] << 8) | + SIS_CMD_INC_X | + SIS_CMD_INC_Y | + SIS_CMD_RECT_CLIP_DISABLE | + SIS_CMD_TRANSPARENT); + + ppci = ppciInit; + while (nglyph--) + { + pci = *ppci++; + height = pci->metrics.ascent + pci->metrics.descent; + width = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; + /* + * For glyphs wider than 16 pixels, expand the blt to the nearest multiple + * of 32; this allows the scanlines to be padded to a 32-bit boundary + * instead of requiring byte packing + */ + if (width > 16) + width = (width + 31) & ~31; + bwidth = (width + 7) >> 3; + nb = bwidth * height; + if (nb) + { + dst = sisExpandAlloc (&expand, nb); + + sis->u.general.src_base = expand.off; + sis->u.general.src_pitch = 0; + sis->u.general.src_x = 0; + sis->u.general.src_y = 0; + sis->u.general.dst_x = x + pci->metrics.leftSideBearing; + sis->u.general.dst_y = y - pci->metrics.ascent; + sis->u.general.rect_width = width; + sis->u.general.rect_height = height; + switch (bwidth) { + case 1: + bits8 = (CARD8 *) pci->bits; + while (height >= 4) + { + d = (bits8[0] | (bits8[4] << 8) | + (bits8[8] << 16) | (bits8[12] << 24)); + SisInvertBits32(d); + *dst++ = d; + bits8 += 16; + height -= 4; + } + if (height) + { + switch (height) { + case 3: + d = bits8[0] | (bits8[4] << 8) | (bits8[8] << 16); + break; + case 2: + d = bits8[0] | (bits8[4] << 8); + break; + case 1: + d = bits8[0]; + break; + } + SisInvertBits32(d); + *dst++ = d; + } + break; + case 2: + bits16 = (CARD16 *) pci->bits; + while (height >= 2) + { + d = bits16[0] | (bits16[2] << 16); + SisInvertBits32(d); + *dst++ = d; + bits16 += 4; + height -= 2; + } + if (height) + { + d = bits16[0]; + SisInvertBits32(d); + *dst++ = d; + } + break; + default: + nb >>= 2; + bits32 = (CARD32 *) pci->bits; + while (nb--) + { + d = *bits32++; + SisInvertBits32 (d); + *dst++ = d; + } + } + sis->u.general.command = cmd; + } + x += pci->metrics.characterWidth; + } + KdMarkSync (pDrawable->pScreen); + return TRUE; +} +/* + * Blt glyphs using Sis image transfer register, this does both + * poly glyph blt and image glyph blt (when pglyphBase == 1) + */ + +void +sisPolyGlyphBlt (DrawablePtr pDrawable, + GCPtr pGC, + int x, int y, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase) +{ + FbBits depthMask; + + depthMask = FbFullMask (pDrawable->depth); + if ((pGC->planemask & depthMask) == depthMask && + pGC->fillStyle == FillSolid) + { + if (TERMINALFONT(pGC->font)) + { + if (sisTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE)) + return; + } + else + { + if (sisGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE)) + return; + } + } + KdCheckPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); +} + +void +sisImageGlyphBlt (DrawablePtr pDrawable, + GCPtr pGC, + int x, int y, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase) +{ + FbBits depthMask; + + depthMask = FbFullMask (pDrawable->depth); + if ((pGC->planemask & depthMask) == depthMask) + { + if (TERMINALFONT(pGC->font)) + { + if (sisTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE)) + return; + } + else + { + if (sisGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE)) + return; + } + } + KdCheckImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); +} + +#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3)) + +#define sisPatternDimOk(d) ((d) <= 8 && (((d) & ((d) - 1)) == 0)) + +BOOL +sisFillOk (GCPtr pGC) +{ + FbBits depthMask; + + depthMask = FbFullMask(pGC->depth); + if ((pGC->planemask & depthMask) != depthMask) + return FALSE; + switch (pGC->fillStyle) { + case FillSolid: + return TRUE; + case FillTiled: + return (sisPatternDimOk (pGC->tile.pixmap->drawable.width) && + sisPatternDimOk (pGC->tile.pixmap->drawable.height)); + case FillStippled: + case FillOpaqueStippled: + return (sisPatternDimOk (pGC->stipple->drawable.width) && + sisPatternDimOk (pGC->stipple->drawable.height)); + } +} + +CARD32 +sisStipplePrepare (DrawablePtr pDrawable, GCPtr pGC) +{ + SetupSis(pGC->pScreen); + PixmapPtr pStip = pGC->stipple; + int stipHeight = pStip->drawable.height; + int xRot, yRot; + int rot, stipX, stipY; + FbStip *stip, *stipEnd, bits; + FbStride stipStride; + int stipBpp; + int stipXoff, stipYoff; /* XXX assumed to be zero */ + int y; + CARD32 cmd; + + xRot = pGC->patOrg.x + pDrawable->x; + yRot = pGC->patOrg.y + pDrawable->y; + modulus (- yRot, stipHeight, stipY); + modulus (- xRot, FB_UNIT, stipX); + rot = stipX; + + fbGetStipDrawable (&pStip->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff); + for (y = 0; y < 8; y++) + { + bits = stip[stipY<<1]; + FbRotLeft(bits, rot); + SisInvertBits32(bits); + sis->u.general.mask[y] = (CARD8) bits; + stipY++; + if (stipY == stipHeight) + stipY = 0; + } + sis->u.general.pattern_fg = pGC->fgPixel; + + cmd = (SIS_CMD_BITBLT | + SIS_CMD_SRC_SCREEN | + SIS_CMD_PAT_MONO | + (sisPatRop[pGC->alu] << 8) | + SIS_CMD_INC_X | + SIS_CMD_INC_Y | + SIS_CMD_RECT_CLIP_DISABLE | + SIS_CMD_RECT_CLIP_DONT_MERGE); + if (pGC->fillStyle == FillOpaqueStippled) + { + sis->u.general.pattern_bg = pGC->bgPixel; + cmd |= SIS_CMD_OPAQUE; + } + else + cmd |= SIS_CMD_TRANSPARENT; + return cmd; +} + +CARD32 +sisTilePrepare (PixmapPtr pTile, int xRot, int yRot, CARD8 alu) +{ + SetupSis(pTile->drawable.pScreen); + int tileHeight = pTile->drawable.height; + int tileWidth = pTile->drawable.width; + FbBits *tile; + FbStride tileStride; + int tileBpp; + int tileXoff, tileYoff; /* XXX assumed to be zero */ + + fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp, tileXoff, tileYoff); + + /* + * Tile the pattern register + */ + fbTile ((FbBits *) sis->u.general.pattern, + (8 * tileBpp) >> FB_SHIFT, + 0, + + 8 * tileBpp, 8, + + tile, + tileStride, + tileWidth * tileBpp, + tileHeight, + GXcopy, FB_ALLONES, tileBpp, + xRot * tileBpp, + yRot); + + return (SIS_CMD_BITBLT | + SIS_CMD_SRC_SCREEN | + SIS_CMD_PAT_PATTERN | + (sisPatRop[alu] << 8) | + SIS_CMD_INC_X | + SIS_CMD_INC_Y | + SIS_CMD_RECT_CLIP_DISABLE | + SIS_CMD_RECT_CLIP_DONT_MERGE); +} + +void +sisFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, + unsigned long pixel, int alu) +{ + SetupSis(pDrawable->pScreen); + CARD32 cmd; + + _sisSetSolidRect(sis,pixel,alu,cmd); + + while (nBox--) + { + _sisRect(sis,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd); + pBox++; + } + KdMarkSync (pDrawable->pScreen); +} + +void +sisFillBoxStipple (DrawablePtr pDrawable, GCPtr pGC, + int nBox, BoxPtr pBox) +{ + SetupSis(pDrawable->pScreen); + CARD32 cmd; + + cmd = sisStipplePrepare (pDrawable, pGC); + + while (nBox--) + { + _sisRect(sis,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd); + pBox++; + } + KdMarkSync (pDrawable->pScreen); +} + +void +sisFillBoxTiled (DrawablePtr pDrawable, + int nBox, BoxPtr pBox, + PixmapPtr pTile, int xRot, int yRot, CARD8 alu) +{ + SetupSis (pDrawable->pScreen); + CARD32 cmd; + + cmd = sisTilePrepare (pTile, xRot, yRot, alu); + + while (nBox--) + { + _sisRect(sis,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd); + pBox++; + } + KdMarkSync (pDrawable->pScreen); +} + +/* + sisDoBitBlt + ============= + Bit Blit for all window to window blits. +*/ + +void +sisCopyNtoN (DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pbox, + int nbox, + int dx, + int dy, + Bool reverse, + Bool upsidedown, + Pixel bitplane, + void *closure) +{ + SetupSis(pDstDrawable->pScreen); + int srcX, srcY, dstX, dstY; + int w, h; + CARD32 flags; + CARD32 cmd; + CARD8 alu; + + if (pGC) + { + alu = pGC->alu; + if (sourceInvarient (pGC->alu)) + { + sisFillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu); + return; + } + } + else + alu = GXcopy; + + _sisSetBlt(sis,alu,cmd); + while (nbox--) + { + w = pbox->x2 - pbox->x1; + h = pbox->y2 - pbox->y1; + flags = 0; + if (reverse) + { + dstX = pbox->x2 - 1; + } + else + { + dstX = pbox->x1; + flags |= SIS_CMD_INC_X; + } + srcX = dstX + dx; + + if (upsidedown) + { + dstY = pbox->y2 - 1; + } + else + { + dstY = pbox->y1; + flags |= SIS_CMD_INC_Y; + } + srcY = dstY + dy; + + _sisBlt (sis, srcX, srcY, dstX, dstY, w, h, cmd|flags); + pbox++; + } + KdMarkSync (pDstDrawable->pScreen); +} + +RegionPtr +sisCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, + int srcx, int srcy, int width, int height, int dstx, int dsty) +{ + KdScreenPriv(pDstDrawable->pScreen); + FbBits depthMask; + + depthMask = FbFullMask (pDstDrawable->depth); + if ((pGC->planemask & depthMask) == depthMask && + pSrcDrawable->type == DRAWABLE_WINDOW && + pDstDrawable->type == DRAWABLE_WINDOW) + { + return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, + dstx, dsty, sisCopyNtoN, 0, 0); + } + return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, dstx, dsty); +} + +typedef struct _sis1toNargs { + unsigned long copyPlaneFG, copyPlaneBG; +} sis1toNargs; + +void +_sisStipple (ScreenPtr pScreen, + FbStip *psrcBase, + FbStride widthSrc, + CARD8 alu, + int srcx, + int srcy, + int dstx, + int dsty, + int width, + int height) +{ + SetupSis(pScreen); + FbStip *psrcLine, *psrc; + FbStride widthRest; + FbStip bits, tmp, lastTmp; + int leftShift, rightShift; + int nl, nlMiddle; + int r; + SisExpand expand; + CARD32 *dst; + int hthis; + int hper; + int bwidth; + CARD32 cmd; + + sisExpandInit (pScreen, &expand); + + /* Compute blt address and parameters */ + psrc = psrcBase + srcy * widthSrc + (srcx >> 5); + nlMiddle = (width + 31) >> 5; + leftShift = srcx & 0x1f; + rightShift = 32 - leftShift; + widthRest = widthSrc - nlMiddle; + + cmd = (SIS_CMD_ENH_COLOR_EXPAND | + SIS_CMD_SRC_SCREEN | + SIS_CMD_PAT_FG | + (sisBltRop[alu] << 8) | + SIS_CMD_INC_X | + SIS_CMD_INC_Y | + SIS_CMD_OPAQUE | + SIS_CMD_RECT_CLIP_ENABLE); + + if (leftShift != 0) + widthRest--; + + sis->u.general.src_x = 0; + sis->u.general.src_y = 0; + sis->u.general.dst_x = dstx; + sis->u.general.rect_width = (width + 31) & ~31; + sis->u.general.clip_right = (dstx + width); + + bwidth = nlMiddle << 2; + hper = SIS_PATTERN_INC / bwidth; + if (hper == 0) + hper = 1; + + while (height) + { + hthis = hper; + if (hthis > height) + hthis = height; + dst = sisExpandAlloc (&expand, bwidth * hthis); + sis->u.general.src_base = expand.off; + sis->u.general.dst_y = dsty; + sis->u.general.rect_height = hthis; + + dsty += hthis; + height -= hthis; + + if (leftShift == 0) + { + while (hthis--) + { + nl = nlMiddle; + while (nl--) + { + tmp = *psrc++; + SisInvertBits32(tmp); + *dst++ = tmp; + } + psrc += widthRest; + } + } + else + { + while (hthis--) + { + bits = *psrc++; + nl = nlMiddle; + while (nl--) + { + tmp = FbStipLeft(bits, leftShift); + bits = *psrc++; + tmp |= FbStipRight(bits, rightShift); + SisInvertBits32(tmp); + *dst++ = tmp; + } + psrc += widthRest; + } + } + sis->u.general.command = cmd; + } + sis->u.general.clip_right = pScreenPriv->screen->width; +} + +void +sisCopy1toN (DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pbox, + int nbox, + int dx, + int dy, + Bool reverse, + Bool upsidedown, + Pixel bitplane, + void *closure) +{ + SetupSis(pDstDrawable->pScreen); + + sis1toNargs *args = closure; + int dstx, dsty; + FbStip *psrcBase; + FbStride widthSrc; + int srcBpp; + int srcXoff, srcYoff; + + if (sourceInvarient (pGC->alu)) + { + sisFillBoxSolid (pDstDrawable, nbox, pbox, + pGC->bgPixel, pGC->alu); + return; + } + + fbGetStipDrawable (pSrcDrawable, psrcBase, widthSrc, srcBpp, srcXoff, srcYoff); + + sis->u.general.src_fg = args->copyPlaneFG; + sis->u.general.src_bg = args->copyPlaneBG; + + while (nbox--) + { + dstx = pbox->x1; + dsty = pbox->y1; + + _sisStipple (pDstDrawable->pScreen, + psrcBase, widthSrc, + pGC->alu, + dstx + dx - srcXoff, dsty + dy - srcYoff, + dstx, dsty, + pbox->x2 - dstx, pbox->y2 - dsty); + pbox++; + } + KdMarkSync (pDstDrawable->pScreen); +} + +RegionPtr +sisCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, + int srcx, int srcy, int width, int height, + int dstx, int dsty, unsigned long bitPlane) +{ + KdScreenPriv (pDstDrawable->pScreen); + RegionPtr ret; + sis1toNargs args; + FbBits depthMask; + + depthMask = FbFullMask (pDstDrawable->depth); + if ((pGC->planemask & depthMask) == depthMask && + pDstDrawable->type == DRAWABLE_WINDOW && + pSrcDrawable->depth == 1) + { + args.copyPlaneFG = pGC->fgPixel; + args.copyPlaneBG = pGC->bgPixel; + return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, + dstx, dsty, sisCopy1toN, bitPlane, &args); + } + return KdCheckCopyPlane(pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, + dstx, dsty, bitPlane); +} + +void +sisFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n, + DDXPointPtr ppt, int *pwidth, int fSorted) +{ + SetupSis(pDrawable->pScreen); + DDXPointPtr pptFree; + FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); + int *pwidthFree;/* copies of the pointers to free */ + CARD32 cmd; + int nTmp; + INT16 x, y; + int width; + + if (!sisFillOk (pGC)) + { + KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted); + return; + } + nTmp = n * miFindMaxBand(fbGetCompositeClip(pGC)); + pwidthFree = (int *)xalloc(nTmp * sizeof(int)); + pptFree = (DDXPointRec *)xalloc(nTmp * sizeof(DDXPointRec)); + if(!pptFree || !pwidthFree) + { + if (pptFree) xfree(pptFree); + if (pwidthFree) xfree(pwidthFree); + return; + } + n = miClipSpans(fbGetCompositeClip(pGC), + ppt, pwidth, n, + pptFree, pwidthFree, fSorted); + pwidth = pwidthFree; + ppt = pptFree; + switch (pGC->fillStyle) { + case FillSolid: + _sisSetSolidRect(sis,pGC->fgPixel,pGC->alu,cmd); + break; + case FillTiled: + cmd = sisTilePrepare (pGC->tile.pixmap, + pGC->patOrg.x + pDrawable->x, + pGC->patOrg.y + pDrawable->y, + pGC->alu); + break; + default: + cmd = sisStipplePrepare (pDrawable, pGC); + break; + } + while (n--) + { + x = ppt->x; + y = ppt->y; + ppt++; + width = *pwidth++; + if (width) + { + _sisRect(sis,x,y,width,1,cmd); + } + } + KdMarkSync (pDrawable->pScreen); + xfree(pptFree); + xfree(pwidthFree); +} + +#define NUM_STACK_RECTS 1024 + +void +sisPolyFillRect (DrawablePtr pDrawable, GCPtr pGC, + int nrectFill, xRectangle *prectInit) +{ + SetupSis(pDrawable->pScreen); + xRectangle *prect; + RegionPtr prgnClip; + register BoxPtr pbox; + register BoxPtr pboxClipped; + BoxPtr pboxClippedBase; + BoxPtr pextent; + BoxRec stackRects[NUM_STACK_RECTS]; + FbGCPrivPtr fbPriv = fbGetGCPrivate (pGC); + int numRects; + int n; + int xorg, yorg; + int x, y; + + if (!sisFillOk (pGC)) + { + KdCheckPolyFillRect (pDrawable, pGC, nrectFill, prectInit); + return; + } + prgnClip = fbGetCompositeClip(pGC); + xorg = pDrawable->x; + yorg = pDrawable->y; + + if (xorg || yorg) + { + prect = prectInit; + n = nrectFill; + while(n--) + { + prect->x += xorg; + prect->y += yorg; + prect++; + } + } + + prect = prectInit; + + numRects = REGION_NUM_RECTS(prgnClip) * nrectFill; + if (numRects > NUM_STACK_RECTS) + { + pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec)); + if (!pboxClippedBase) + return; + } + else + pboxClippedBase = stackRects; + + pboxClipped = pboxClippedBase; + + if (REGION_NUM_RECTS(prgnClip) == 1) + { + int x1, y1, x2, y2, bx2, by2; + + pextent = REGION_RECTS(prgnClip); + x1 = pextent->x1; + y1 = pextent->y1; + x2 = pextent->x2; + y2 = pextent->y2; + while (nrectFill--) + { + if ((pboxClipped->x1 = prect->x) < x1) + pboxClipped->x1 = x1; + + if ((pboxClipped->y1 = prect->y) < y1) + pboxClipped->y1 = y1; + + bx2 = (int) prect->x + (int) prect->width; + if (bx2 > x2) + bx2 = x2; + pboxClipped->x2 = bx2; + + by2 = (int) prect->y + (int) prect->height; + if (by2 > y2) + by2 = y2; + pboxClipped->y2 = by2; + + prect++; + if ((pboxClipped->x1 < pboxClipped->x2) && + (pboxClipped->y1 < pboxClipped->y2)) + { + pboxClipped++; + } + } + } + else + { + int x1, y1, x2, y2, bx2, by2; + + pextent = REGION_EXTENTS(pGC->pScreen, prgnClip); + x1 = pextent->x1; + y1 = pextent->y1; + x2 = pextent->x2; + y2 = pextent->y2; + while (nrectFill--) + { + BoxRec box; + + if ((box.x1 = prect->x) < x1) + box.x1 = x1; + + if ((box.y1 = prect->y) < y1) + box.y1 = y1; + + bx2 = (int) prect->x + (int) prect->width; + if (bx2 > x2) + bx2 = x2; + box.x2 = bx2; + + by2 = (int) prect->y + (int) prect->height; + if (by2 > y2) + by2 = y2; + box.y2 = by2; + + prect++; + + if ((box.x1 >= box.x2) || (box.y1 >= box.y2)) + continue; + + n = REGION_NUM_RECTS (prgnClip); + pbox = REGION_RECTS(prgnClip); + + /* clip the rectangle to each box in the clip region + this is logically equivalent to calling Intersect() + */ + while(n--) + { + pboxClipped->x1 = max(box.x1, pbox->x1); + pboxClipped->y1 = max(box.y1, pbox->y1); + pboxClipped->x2 = min(box.x2, pbox->x2); + pboxClipped->y2 = min(box.y2, pbox->y2); + pbox++; + + /* see if clipping left anything */ + if(pboxClipped->x1 < pboxClipped->x2 && + pboxClipped->y1 < pboxClipped->y2) + { + pboxClipped++; + } + } + } + } + if (pboxClipped != pboxClippedBase) + { + switch (pGC->fillStyle) { + case FillSolid: + sisFillBoxSolid(pDrawable, + pboxClipped-pboxClippedBase, pboxClippedBase, + pGC->fgPixel, pGC->alu); + break; + case FillTiled: + sisFillBoxTiled(pDrawable, + pboxClipped-pboxClippedBase, pboxClippedBase, + pGC->tile.pixmap, + pGC->patOrg.x + pDrawable->x, + pGC->patOrg.y + pDrawable->y, + pGC->alu); + break; + case FillStippled: + case FillOpaqueStippled: + sisFillBoxStipple (pDrawable, pGC, + pboxClipped-pboxClippedBase, pboxClippedBase); + break; + } + } + if (pboxClippedBase != stackRects) + xfree(pboxClippedBase); +} + +static const GCOps sisOps = { + sisFillSpans, + KdCheckSetSpans, + KdCheckPutImage, + sisCopyArea, + sisCopyPlane, + KdCheckPolyPoint, + KdCheckPolylines, + KdCheckPolySegment, + miPolyRectangle, + KdCheckPolyArc, + miFillPolygon, + sisPolyFillRect, + KdCheckPolyFillArc, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + sisImageGlyphBlt, + sisPolyGlyphBlt, + KdCheckPushPixels, +}; + +void +sisValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) +{ + FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); + + fbValidateGC (pGC, changes, pDrawable); + + if (pDrawable->type == DRAWABLE_WINDOW) + pGC->ops = (GCOps *) &sisOps; + else + pGC->ops = (GCOps *) &kdAsyncPixmapGCOps; +} + +GCFuncs sisGCFuncs = { + sisValidateGC, + miChangeGC, + miCopyGC, + miDestroyGC, + miChangeClip, + miDestroyClip, + miCopyClip +}; + +int +sisCreateGC (GCPtr pGC) +{ + if (!fbCreateGC (pGC)) + return FALSE; + + if (pGC->depth != 1) + pGC->funcs = &sisGCFuncs; + + pGC->ops = (GCOps *) &kdAsyncPixmapGCOps; + + return TRUE; +} + +void +sisCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + KdScreenPriv(pScreen); + RegionRec rgnDst; + int dx, dy; + WindowPtr pwinRoot; + + pwinRoot = WindowTable[pWin->drawable.pScreen->myNum]; + + dx = ptOldOrg.x - pWin->drawable.x; + dy = ptOldOrg.y - pWin->drawable.y; + REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy); + + REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0); + + REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc); + + fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, + 0, + &rgnDst, dx, dy, sisCopyNtoN, 0, 0); + + REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); +} + +Bool +sisDrawInit (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + sisScreenInfo(pScreenPriv); + + /* + * Hook up asynchronous drawing + */ + KdScreenInitAsync (pScreen); + /* + * Replace various fb screen functions + */ + pScreen->CreateGC = sisCreateGC; + pScreen->CopyWindow = sisCopyWindow; + + return TRUE; +} + +void +sisDrawEnable (ScreenPtr pScreen) +{ + SetupSis(pScreen); + sisScreenInfo(pScreenPriv); + CARD32 cmd; + CARD32 base; + CARD16 stride; + CARD16 op; + + base = pScreenPriv->screen->fb[0].frameBuffer - sisc->frameBuffer; + stride = pScreenPriv->screen->fb[0].byteStride; +#if 0 + sis->u.general.dst_base = base; + sis->u.general.dst_pitch = stride; + sis->u.general.src_pitch = stride; + sis->u.general._pad0 = stride; + sis->u.general.dst_height = pScreenPriv->screen->height; + _sisClip (sis, 0, 0, + pScreenPriv->screen->width, pScreenPriv->screen->height); + _sisSetSolidRect(sis, pScreen->blackPixel, GXcopy, cmd); + _sisRect (sis, 0, 0, + pScreenPriv->screen->width, pScreenPriv->screen->height, + cmd); +#endif + base = (CARD32) (pScreenPriv->screen->fb[0].frameBuffer); + fprintf (stderr, "src 0x%x\n", sis->u.accel.src_addr); + sis->u.accel.src_addr = (base & 0x3fffff); + fprintf (stderr, "src 0x%x\n", sis->u.accel.src_addr); + sis->u.accel.dst_addr = (base & 0x3fffff); + sis->u.accel.pitch = (stride << 16) | stride; + sis->u.accel.dimension = ((pScreenPriv->screen->height-1) << 16 | + (pScreenPriv->screen->width - 1)); + sis->u.accel.fg = (sisBltRop[GXcopy] << 24) | 0xf800; + sis->u.accel.bg = (sisBltRop[GXcopy] << 24) | 0x00; + +#define sisLEFT2RIGHT 0x10 +#define sisRIGHT2LEFT 0x00 +#define sisTOP2BOTTOM 0x20 +#define sisBOTTOM2TOP 0x00 + +#define sisSRCSYSTEM 0x03 +#define sisSRCVIDEO 0x02 +#define sisSRCFG 0x01 +#define sisSRCBG 0x00 + +#define sisCMDBLT 0x0000 +#define sisCMDBLTMSK 0x0100 +#define sisCMDCOLEXP 0x0200 +#define sisCMDLINE 0x0300 + +#define sisCMDENHCOLEXP 0x2000 + +#define sisXINCREASE 0x10 +#define sisYINCREASE 0x20 +#define sisCLIPENABL 0x40 +#define sisCLIPINTRN 0x80 +#define sisCLIPEXTRN 0x00 + + +#define sisPATREG 0x08 +#define sisPATFG 0x04 +#define sisPATBG 0x00 + +#define sisLASTPIX 0x0800 +#define sisXMAJOR 0x0400 + + op = sisCMDBLT | sisLEFT2RIGHT | sisTOP2BOTTOM | sisSRCFG | sisPATFG; + + sis->u.accel.cmd = op; + + KdMarkSync (pScreen); +} + +void +sisDrawSync (ScreenPtr pScreen) +{ + SetupSis(pScreen); + + _sisWaitIdleEmpty (sis); +} + +void +sisDrawDisable (ScreenPtr pScreen) +{ +} + +void +sisDrawFini (ScreenPtr pScreen) +{ +} --- xorg-server-1.4.99.906.orig/hw/kdrive/sis530/sis.c +++ xorg-server-1.4.99.906/hw/kdrive/sis530/sis.c @@ -0,0 +1,921 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "sis.h" + +#define MAX_FB_SIZE (4096 * 1024) + +#define MMIO_SIZE (64 * 1024) + +int sisMemoryTable[8] = { + 1, 2, 4, 0, 0, 2, 4, 8 +}; + +Bool +sisCardInit (KdCardInfo *card) +{ + SisCardInfo *sisc; + SisPtr sis; + int size; + CARD8 *registers; + CARD8 *temp_buffer; + CARD8 save_sr5; + + sisc = (SisCardInfo *) xalloc (sizeof (SisCardInfo)); + if (!sisc) + goto bail0; + + sisc->io_base = card->attr.io; + /* + * enable access to SiS ports (no MMIO available) + */ + iopl(3); + save_sr5 = GetSrtc(sisc,0x5); + if (save_sr5 != 0x21) + save_sr5 = 0x86; + PutSrtc(sisc,0x5,0x86); +#if 0 + { + int i; + + for (i = 0; i <= 0x3f; i++) + fprintf (stderr, "SR%02x = %02x\n", i, GetSrtc(sisc,i)); + } +#endif + sisc->memory = sisMemoryTable[GetSrtc(sisc,0xc)&0x7] * 1024 * 1024; + + PutSrtc(sisc,0x5,save_sr5); + + if (!sisc->memory) + { + ErrorF ("Can't detect SiS530 frame buffer\n"); + goto bail1; + } + + /* + * Map frame buffer and MMIO registers + */ + sisc->frameBuffer = KdMapDevice (card->attr.address[0], sisc->memory); + if (!sisc->frameBuffer) + goto bail1; + + sisc->registers = KdMapDevice (card->attr.address[1], MMIO_SIZE); + if (!sisc->registers) + goto bail2; + + /* + * Offset from base of MMIO to registers + */ + sisc->sis = (SisPtr) (sisc->registers + SIS_MMIO_OFFSET); + sisc->cpu_bitblt = (VOL32 *) sisc->registers; + + card->driver = sisc; + + return TRUE; +bail2: + KdUnmapDevice (sisc->frameBuffer, sisc->memory); +bail1: + xfree (sisc); +bail0: + return FALSE; +} + +Bool +sisModeSupported (KdScreenInfo *screen, const KdMonitorTiming *t) +{ + if (t->horizontal != 1600 && + t->horizontal != 1280 && + t->horizontal != 1152 && + t->horizontal != 1024 && + t->horizontal != 800 && + t->horizontal != 640) + return FALSE; + return TRUE; +} + +Bool +sisModeUsable (KdScreenInfo *screen) +{ + KdCardInfo *card = screen->card; + SisCardInfo *sisc = (SisCardInfo *) card->driver; + SisScreenInfo *siss; + int i; + KdMonitorTiming *t; + CARD32 memory; + int byte_width, pixel_width, screen_size; + + if (screen->fb[0].depth >= 24) + { + screen->fb[0].depth = 24; + screen->fb[0].bitsPerPixel = 24; + screen->dumb = TRUE; + } + else if (screen->fb[0].depth >= 16) + { + screen->fb[0].depth = 16; + screen->fb[0].bitsPerPixel = 16; + } + else if (screen->fb[0].depth >= 15) + { + screen->fb[0].depth = 15; + screen->fb[0].bitsPerPixel = 16; + } + else + { + screen->fb[0].depth = 8; + screen->fb[0].bitsPerPixel = 8; + } + byte_width = screen->width * (screen->fb[0].bitsPerPixel >> 3); + pixel_width = screen->width; + screen->fb[0].pixelStride = pixel_width; + screen->fb[0].byteStride = byte_width; + + screen_size = byte_width * screen->height; + + return screen_size <= sisc->memory; +} + +Bool +sisScreenInit (KdScreenInfo *screen) +{ + KdCardInfo *card = screen->card; + SisCardInfo *sisc = (SisCardInfo *) card->driver; + SisScreenInfo *siss; + int i; + const KdMonitorTiming *t; + CARD32 memory; + int byte_width, pixel_width, screen_size; + + siss = (SisScreenInfo *) xalloc (sizeof (SisScreenInfo)); + if (!siss) + return FALSE; + + memset (siss, '\0', sizeof (SisScreenInfo)); + + if (!screen->width || !screen->height) + { + screen->width = 800; + screen->height = 600; + screen->rate = 72; + } + if (!screen->fb[0].depth) + screen->fb[0].depth = 8; + + t = KdFindMode (screen, sisModeSupported); + + screen->rate = t->rate; + screen->width = t->horizontal; + screen->height = t->vertical; + + if (!KdTuneMode (screen, sisModeUsable, sisModeSupported)) + { + xfree (sisc); + return FALSE; + } + + memory = sisc->memory - screen_size; + + screen->fb[0].frameBuffer = sisc->frameBuffer; + + /* + * Cursor lives in the last 16k of memory + */ + if (memory >= 16384 && !screen->softCursor) + { + siss->cursor_base = sisc->frameBuffer + (sisc->memory - 16384); + siss->cursor_off = siss->cursor_base - sisc->frameBuffer; + memory -= 16384; + } + else + { + screen->softCursor = TRUE; + siss->cursor_base = 0; + siss->cursor_off = 0; + } + + if (memory > 8192) + { + siss->expand = screen->fb[0].frameBuffer + screen_size; + siss->expand_off = siss->expand - sisc->frameBuffer; + siss->expand_len = memory; + memory = 0; + } + else + { + siss->expand = 0; + siss->expand_len = 0; + } + + switch (screen->fb[0].depth) { + case 8: + screen->fb[0].visuals = ((1 << StaticGray) | + (1 << GrayScale) | + (1 << StaticColor) | + (1 << PseudoColor) | + (1 << TrueColor) | + (1 << DirectColor)); + screen->fb[0].blueMask = 0x00; + screen->fb[0].greenMask = 0x00; + screen->fb[0].redMask = 0x00; + break; + case 15: + screen->fb[0].visuals = (1 << TrueColor); + screen->fb[0].blueMask = 0x001f; + screen->fb[0].greenMask = 0x03e0; + screen->fb[0].redMask = 0x7c00; + break; + case 16: + screen->fb[0].visuals = (1 << TrueColor); + screen->fb[0].blueMask = 0x001f; + screen->fb[0].greenMask = 0x07e0; + screen->fb[0].redMask = 0xf800; + break; + case 24: + screen->fb[0].visuals = (1 << TrueColor); + screen->fb[0].blueMask = 0x0000ff; + screen->fb[0].greenMask = 0x00ff00; + screen->fb[0].redMask = 0xff0000; + break; + } + + screen->driver = siss; + + return TRUE; +} + +static void +_sisGetCrtc (SisCardInfo *sisc, SisCrtc *crtc) +{ + crtc->misc_output = _sisInb(sisc->io_base+0x4c); + crtc->h_total_0_7 = GetCrtc (sisc, 0x00); + crtc->h_display_end_0_7 = GetCrtc (sisc, 0x01); + crtc->h_blank_start_0_7 = GetCrtc (sisc, 0x02); + crtc->_h_blank_end = GetCrtc (sisc, 0x03); + crtc->h_sync_start_0_7 = GetCrtc (sisc, 0x04); + crtc->_h_sync_end = GetCrtc (sisc, 0x05); + crtc->v_total_0_7 = GetCrtc (sisc, 0x06); + crtc->crtc_overflow = GetCrtc (sisc, 0x07); + crtc->preset_row_scan = GetCrtc (sisc, 0x08); + crtc->_max_scan_line = GetCrtc (sisc, 0x09); + crtc->cursor_start = GetCrtc (sisc, 0x0a); + crtc->cursor_end = GetCrtc (sisc, 0x0a); + crtc->start_address_8_15 = GetCrtc (sisc, 0x0c); + crtc->start_address_0_7 = GetCrtc (sisc, 0x0d); + crtc->text_cursor_15_8 = GetCrtc (sisc, 0x0e); + crtc->text_cursor_7_0 = GetCrtc (sisc, 0x0f); + crtc->v_retrace_start_0_7 = GetCrtc (sisc, 0x10); + crtc->_v_retrace_end = GetCrtc (sisc, 0x11); + crtc->v_display_end_0_7 = GetCrtc (sisc, 0x12); + crtc->screen_off_0_7 = GetCrtc (sisc, 0x13); + crtc->_underline_location = GetCrtc (sisc, 0x14); + crtc->v_blank_start_0_7 = GetCrtc (sisc, 0x15); + crtc->v_blank_end_0_7 = GetCrtc (sisc, 0x16); + crtc->crtc_mode = GetCrtc (sisc, 0x17); + + crtc->line_compare_0_7 = GetCrtc (sisc, 0x18); + + crtc->mode_control = GetArtc (sisc, 0x10); + crtc->screen_border_color = GetArtc (sisc, 0x11); + crtc->enable_color_plane = GetArtc (sisc, 0x12); + crtc->horizontal_pixel_pan = GetArtc (sisc, 0x13); + + crtc->mode_register = GetGrtc (sisc, 0x5); + crtc->misc_register = GetGrtc (sisc, 0x6); + crtc->color_dont_care = GetGrtc (sisc, 0x7); + + crtc->clock_mode = GetSrtc (sisc, 0x1); + crtc->color_plane_w_enable = GetSrtc (sisc, 0x2); + crtc->memory_mode = GetSrtc (sisc, 0x4); + + crtc->graphics_mode = GetSrtc (sisc, 0x6); + crtc->misc_control_0 = GetSrtc (sisc, 0x7); + crtc->crt_cpu_threshold_control_0 = GetSrtc (sisc, 0x8); + crtc->crt_cpu_threshold_control_1 = GetSrtc (sisc, 0x9); + crtc->extended_crt_overflow = GetSrtc (sisc, 0xa); + crtc->misc_control_1 = GetSrtc (sisc, 0xb); + crtc->misc_control_2 = GetSrtc (sisc, 0xc); + + crtc->ddc_and_power_control = GetSrtc (sisc, 0x11); + crtc->extended_horizontal_overflow = GetSrtc (sisc, 0x12); + crtc->extended_clock_generator = GetSrtc (sisc, 0x13); + crtc->cursor_0_red = GetSrtc (sisc, 0x14); + crtc->cursor_0_green = GetSrtc (sisc, 0x15); + crtc->cursor_0_blue = GetSrtc (sisc, 0x16); + crtc->cursor_1_red = GetSrtc (sisc, 0x17); + crtc->cursor_1_green = GetSrtc (sisc, 0x18); + crtc->cursor_1_blue = GetSrtc (sisc, 0x19); + crtc->cursor_h_start_0_7 = GetSrtc (sisc, 0x1a); + crtc->cursor_h_start_1 = GetSrtc (sisc, 0x1b); + crtc->cursor_h_preset_0_5 = GetSrtc (sisc, 0x1c); + crtc->cursor_v_start_0_7 = GetSrtc (sisc, 0x1d); + crtc->cursor_v_start_1 = GetSrtc (sisc, 0x1e); + crtc->cursor_v_preset_0_5 = GetSrtc (sisc, 0x1f); + crtc->linear_base_19_26 = GetSrtc (sisc, 0x20); + crtc->linear_base_1 = GetSrtc (sisc, 0x21); + + crtc->graphics_engine_0 = GetSrtc (sisc, 0x26); + crtc->graphics_engine_1 = GetSrtc (sisc, 0x27); + crtc->internal_mclk_0 = GetSrtc (sisc, 0x28); + crtc->internal_mclk_1 = GetSrtc (sisc, 0x29); + crtc->internal_vclk_0 = GetSrtc (sisc, 0x2A); + crtc->internal_vclk_1 = GetSrtc (sisc, 0x2B); + + crtc->misc_control_7 = GetSrtc (sisc, 0x38); + + crtc->misc_control_11 = GetSrtc (sisc, 0x3E); + crtc->misc_control_12 = GetSrtc (sisc, 0x3F); +} + +static void +_sisSetBlank (SisCardInfo *sisc, Bool blank) +{ + CARD8 clock; + + clock = GetSrtc (sisc, 0x01); + if (blank) + clock |= 0x20; + else + clock &= ~0x20; + PutSrtc (sisc, 0x01, clock); +} + +static void +_sisSetCrtc (SisCardInfo *sisc, SisCrtc *crtc) +{ + _sisSetBlank (sisc, TRUE); + PutCrtc (sisc, 0x00, crtc->h_total_0_7); + PutCrtc (sisc, 0x01, crtc->h_display_end_0_7); + PutCrtc (sisc, 0x02, crtc->h_blank_start_0_7); + PutCrtc (sisc, 0x03, crtc->_h_blank_end); + PutCrtc (sisc, 0x04, crtc->h_sync_start_0_7); + PutCrtc (sisc, 0x05, crtc->_h_sync_end); + PutCrtc (sisc, 0x06, crtc->v_total_0_7); + PutCrtc (sisc, 0x07, crtc->crtc_overflow); + PutCrtc (sisc, 0x08, crtc->preset_row_scan); + PutCrtc (sisc, 0x09, crtc->_max_scan_line); + PutCrtc (sisc, 0x0a, crtc->cursor_start); + PutCrtc (sisc, 0x0b, crtc->cursor_end); + PutCrtc (sisc, 0x0c, crtc->start_address_8_15); + PutCrtc (sisc, 0x0d, crtc->start_address_0_7); + PutCrtc (sisc, 0x0e, crtc->text_cursor_15_8); + PutCrtc (sisc, 0x0f, crtc->text_cursor_7_0); + PutCrtc (sisc, 0x10, crtc->v_retrace_start_0_7); + PutCrtc (sisc, 0x11, crtc->_v_retrace_end); + PutCrtc (sisc, 0x12, crtc->v_display_end_0_7); + PutCrtc (sisc, 0x13, crtc->screen_off_0_7); + PutCrtc (sisc, 0x14, crtc->_underline_location); + PutCrtc (sisc, 0x15, crtc->v_blank_start_0_7); + PutCrtc (sisc, 0x16, crtc->v_blank_end_0_7); + PutCrtc (sisc, 0x17, crtc->crtc_mode); + PutCrtc (sisc, 0x18, crtc->line_compare_0_7); + + PutArtc (sisc, 0x10, crtc->mode_control); + PutArtc (sisc, 0x11, crtc->screen_border_color); + PutArtc (sisc, 0x12, crtc->enable_color_plane); + PutArtc (sisc, 0x13, crtc->horizontal_pixel_pan); + + PutGrtc (sisc, 0x5, crtc->mode_register); + PutGrtc (sisc, 0x6, crtc->misc_register); + PutGrtc (sisc, 0x7, crtc->color_dont_care); + + PutSrtc (sisc, 0x1, crtc->clock_mode | 0x20); + PutSrtc (sisc, 0x2, crtc->color_plane_w_enable); + PutSrtc (sisc, 0x4, crtc->memory_mode); + + PutSrtc (sisc, 0x6, crtc->graphics_mode); + PutSrtc (sisc, 0x7, crtc->misc_control_0); + PutSrtc (sisc, 0x8, crtc->crt_cpu_threshold_control_0); + PutSrtc (sisc, 0x9, crtc->crt_cpu_threshold_control_1); + PutSrtc (sisc, 0xa, crtc->extended_crt_overflow); + PutSrtc (sisc, 0xb, crtc->misc_control_1); + PutSrtc (sisc, 0xc, crtc->misc_control_2); + + PutSrtc (sisc, 0x11, crtc->ddc_and_power_control); + PutSrtc (sisc, 0x12, crtc->extended_horizontal_overflow); + PutSrtc (sisc, 0x13, crtc->extended_clock_generator); + PutSrtc (sisc, 0x14, crtc->cursor_0_red); + PutSrtc (sisc, 0x15, crtc->cursor_0_green); + PutSrtc (sisc, 0x16, crtc->cursor_0_blue); + PutSrtc (sisc, 0x17, crtc->cursor_1_red); + PutSrtc (sisc, 0x18, crtc->cursor_1_green); + PutSrtc (sisc, 0x19, crtc->cursor_1_blue); + PutSrtc (sisc, 0x1a, crtc->cursor_h_start_0_7); + PutSrtc (sisc, 0x1b, crtc->cursor_h_start_1); + PutSrtc (sisc, 0x1c, crtc->cursor_h_preset_0_5); + PutSrtc (sisc, 0x1d, crtc->cursor_v_start_0_7); + PutSrtc (sisc, 0x1e, crtc->cursor_v_start_1); + PutSrtc (sisc, 0x1f, crtc->cursor_v_preset_0_5); + PutSrtc (sisc, 0x20, crtc->linear_base_19_26); + PutSrtc (sisc, 0x21, crtc->linear_base_1); + + PutSrtc (sisc, 0x26, crtc->graphics_engine_0); + PutSrtc (sisc, 0x27, crtc->graphics_engine_1); + PutSrtc (sisc, 0x28, crtc->internal_mclk_0); + PutSrtc (sisc, 0x29, crtc->internal_mclk_1); + PutSrtc (sisc, 0x2A, crtc->internal_vclk_0); + PutSrtc (sisc, 0x2B, crtc->internal_vclk_1); + + PutSrtc (sisc, 0x38, crtc->misc_control_7); + + PutSrtc (sisc, 0x3E, crtc->misc_control_11); + PutSrtc (sisc, 0x3F, crtc->misc_control_12); + +#if 0 + PutCrtc (sisc, 0x5b, 0x27); + PutCrtc (sisc, 0x5c, 0xe1); + PutCrtc (sisc, 0x5d, 0x00); + + PutSrtc (sisc, 0x5a, 0xe6); + PutSrtc (sisc, 0x5d, 0xa1); + PutSrtc (sisc, 0x9a, 0xe6); + PutSrtc (sisc, 0x9d, 0xa1); + PutSrtc (sisc, 0xda, 0xe6); + PutSrtc (sisc, 0xdd, 0x6c); +#endif + + _sisOutb(crtc->misc_output, sisc->io_base+0x42); + + outw (0x3c4, 0x0100); + outw (0x3c4, 0x0300); + + _sisSetBlank (sisc, FALSE); +} + +CARD8 +_sisReadIndexRegister (CARD32 base, CARD8 index) +{ + CARD8 ret; + + _sisOutb (index, base); + ret = _sisInb (base+1); + return ret; +} + +void +_sisWriteIndexRegister (CARD32 base, CARD8 index, CARD8 value) +{ + _sisOutb (index, base); + _sisOutb (value, base+1); +} + +CARD8 +_sisReadArtc (CARD32 base, CARD8 index) +{ + CARD8 ret; + + _sisInb (base+0x1a); + _sisOutb (index,base); + ret = _sisInb (base+1); + _sisInb (base+0x1a); + _sisOutb (0x20,base); + return ret; +} + +void +_sisWriteArtc (CARD32 base, CARD8 index, CARD8 value) +{ + _sisInb (base+0x1a); + _sisOutb (index|0x20,base); + _sisOutb (value,base); + _sisInb (base+0x1a); + _sisOutb (0x20,base); +} + +void +sisPreserve (KdCardInfo *card) +{ + SisCardInfo *sisc = card->driver; + CARD8 *r = sisc->registers; + int a, i, l; + CARD8 line[16]; + CARD8 prev[16]; + BOOL gotone; + + sisc->save.sr5 = GetSrtc(sisc,0x5); + if (sisc->save.sr5 != 0x21) + sisc->save.sr5 = 0x86; + /* unlock extension registers */ + PutSrtc(sisc,0x5,0x86); + /* unlock CRTC registers */ + PutCrtc(sisc,0x11,GetCrtc(sisc,0x11)&~0x80); + /* enable vga */ + _sisOutb(0x1,sisc->io_base+0x43); + + /* enable MMIO access to registers */ + sisc->save.srb = GetSrtc(sisc,0xb); + PutSrtc(sisc, 0xb, sisc->save.srb | 0x60); + _sisGetCrtc (sisc, &sisc->save.crtc); + memcpy (sisc->save.text_save, sisc->frameBuffer, SIS_TEXT_SAVE); +} + +Bool +sisEnable (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + KdCardInfo *card = pScreenPriv->card; + SisCardInfo *sisc = card->driver; + SisScreenInfo *siss = screen->driver; + const KdMonitorTiming *t; + SisCrtc crtc; + unsigned long pixel; + + int hactive; + int hblank; + int hfp; + int hbp; + + int vactive; + int vblank; + int vfp; + int vbp; + + int h_total; + int h_display_end; + int h_blank_start; + int h_blank_end; + int h_sync_start; + int h_sync_end; + int h_screen_off; + + int h_adjust; + + int v_total; + int v_retrace_start; + int v_retrace_end; + int v_display_end; + int v_blank_start; + int v_blank_end; + + crtc = sisc->save.crtc; + + t = KdFindMode (screen, sisModeSupported); + + /* CR9 */ + crtc.max_scan_line = 0; + + /* CRA */ + crtc.cursor_start = 0; + + /* CRB */ + crtc.cursor_end = 0; + + /* CRE */ + crtc.text_cursor_15_8 = 0; + + /* CRF */ + crtc.text_cursor_7_0 = 0; + + /* CR11 */ + crtc.disable_v_retrace_int = 1; + + /* CR14 */ + crtc.underline_location = 0; + crtc.count_by_four = 0; + crtc.doubleword_mode = 1; + + /* 3CC/3C2 */ + crtc.io_address_select = 1; + crtc.display_ram_enable = 1; + crtc.clock_select = 3; + + /* SR1 */ + crtc.clock_mode = 0; + crtc.dot_clock_8_9 = 1; + + /* SR2 */ + crtc.color_plane_w_enable = 0xf; + + /* SR4 */ + crtc.memory_mode = 0; + crtc.chain_4_enable = 1; + crtc.odd_even_disable = 1; + crtc.extended_memory_sz = 1; + + /* SR6 */ + crtc.graphics_mode_linear = 1; + crtc.enhanced_graphics_mode = 1; + + /* SR9 */ + crtc.crt_cpu_threshold_control_1 = 0; + + /* SRB */ +#if 0 + crtc.cpu_bitblt_enable = 1; +#endif + crtc.memory_mapped_mode = 3; + + /* SRC */ + crtc.graphics_mode_32bit_enable = 1; + crtc.read_ahead_enable = 1; + + /* SR11 */ + crtc.acpi_enable = 0; + crtc.kbd_cursor_activate = 0; + crtc.video_memory_activate = 0; + crtc.vga_standby = 0; + crtc.vga_suspend = 0; + + crtc.cursor_0_red = 0x3f; + crtc.cursor_0_green = 0x3f; + crtc.cursor_0_blue = 0x3f; + + /* SR20 */ + crtc.linear_base_19_26 = (card->attr.address[0] & 0x07f80000) >> 19; + + /* SR21 */ + crtc.linear_base_27_31 = (card->attr.address[0] & 0xf8000000) >> 27; + crtc.linear_aperture = SIS_LINEAR_APERTURE_4M; + + /* SR27 */ + crtc.logical_screen_width = 3; + crtc.graphics_prog_enable = 1; + + /* SR38 */ + crtc.extended_clock_select = 0; + + /* AR10 */ + crtc.mode_control = 0; + crtc.graphics_mode_enable = 1; + /* AR11 */ + crtc.screen_border_color = 0; + /* AR12 */ + crtc.enable_color_plane = 0xf; + /* AR13 */ + crtc.horizontal_pixel_pan = 0; + + /* GR5 */ + crtc.mode_register = 0; + + /* GR6 */ + crtc.graphics_enable = 1; + crtc.chain_odd_even = 0; + crtc.memory_address_select = 1; + + /* GR7 */ + crtc.color_dont_care = 0xf; + if (siss->cursor_base) + { + crtc_set_cursor_start_addr (&crtc, siss->cursor_off); + crtc.graphics_mode_hw_cursor = 0; + } + + hactive = t->horizontal; + hblank = t->hblank; + hbp = t->hbp; + hfp = t->hfp; + + vactive = t->vertical; + vblank = t->vblank; + vbp = t->vbp; + vfp = t->vfp; + + pixel = (hactive + hblank) * (vactive + vblank) * t->rate; + + switch (screen->fb[0].bitsPerPixel) { + case 8: + hactive /= 8; + hblank /= 8; + hfp /= 8; + hbp /= 8; + + crtc.color_mode_256 = 1; + h_screen_off = hactive; + h_adjust = 1; + + break; + case 16: + hactive /= 8; + hblank /= 8; + hfp /= 8; + hbp /= 8; + + h_screen_off = hactive * 2; + h_adjust = 1; + + crtc.color_mode_256 = 0; + + if (screen->fb[0].depth == 15) + crtc.graphics_mode_32k = 1; + else + crtc.graphics_mode_64k = 1; + break; + case 24: + hactive /= 8; + hblank /= 8; + hfp /= 8; + hbp /= 8; + + h_screen_off = hactive * 3; + h_adjust = 1; + + crtc.color_mode_256 = 0; + + /* SR6 */ + crtc.graphics_mode_true = 1; + /* SR7 */ + crtc.direct_color_24bit = 0; + /* SR9 */ + crtc.true_color_32bpp = 0; + /* SRB */ + crtc.true_color_order = 1; + break; + case 32: + hactive /= 8; + hblank /= 8; + hfp /= 8; + hbp /= 8; + + h_screen_off = hactive * 4; + h_adjust = 1; + + crtc.color_mode_256 = 0; + + /* SR6 */ + crtc.graphics_mode_true = 1; + /* SR7 */ + crtc.direct_color_24bit = 0; + /* SR9 */ + crtc.true_color_32bpp = 1; + /* SRB */ + crtc.true_color_order = 1; + break; + } + + sisGetClock (pixel, &crtc); + + crtc.high_speed_dac_0 = crtc.high_speed_dac_1 = pixel > 135000000; + + sisEngThresh (&crtc, pixel, screen->fb[0].bitsPerPixel); + + /* + * Compute horizontal register values from timings + */ + h_total = hactive + hblank - 5; + h_display_end = hactive - 1; + h_blank_start = h_display_end; + h_blank_end = h_blank_start + hblank; + + h_sync_start = hactive + hfp + h_adjust; + h_sync_end = h_sync_start + hblank - hbp - hfp; + + crtc_set_h_total(&crtc, h_total); + crtc_set_h_display_end (&crtc, h_display_end); + crtc_set_h_blank_start (&crtc, h_blank_start); + crtc_set_h_blank_end (&crtc, h_blank_end); + crtc_set_h_sync_start (&crtc, h_sync_start); + crtc_set_h_sync_end (&crtc, h_sync_end); + crtc_set_screen_off (&crtc, h_screen_off); + + v_total = vactive + vblank - 2; + v_retrace_start = vactive + vfp - 1; + v_retrace_end = v_retrace_start + vblank - vbp - vfp; + v_display_end = vactive - 1; + v_blank_start = vactive - 1; + v_blank_end = v_blank_start + vblank /* - 1 */; + + crtc_set_v_total(&crtc, v_total); + crtc_set_v_retrace_start (&crtc, v_retrace_start); + crtc.v_retrace_end_0_3 = v_retrace_end; + crtc_set_v_display_end (&crtc, v_display_end); + crtc_set_v_blank_start (&crtc, v_blank_start); + crtc.v_blank_end_0_7 = v_blank_end; + +#if 0 + crtc.h_blank_start_0_7 = 0x6a; + crtc._h_blank_end = 0x9a; + crtc.h_sync_start_0_7 = 0x6b; + crtc._h_sync_end = 0x9a; + + crtc.v_retrace_start_0_7 = 0x7d; + crtc._v_retrace_end = 0x23; + crtc.v_blank_start_0_7 = 0x7d; + crtc.v_blank_end_0_7 = 0x84; + + crtc.crt_cpu_threshold_control_0 = 0xdf; /* SR8 */ + crtc.crt_cpu_threshold_control_1 = 0x00; /* SR9 */ + crtc.extended_clock_generator = 0x40; /* SR13 */ + + crtc.cursor_h_start_0_7 = 0x83; + crtc.cursor_v_start_0_7 = 0x6c; + + crtc.internal_vclk_0 = 0x68; + crtc.internal_vclk_1 = 0xc4; + crtc.misc_control_7 = 0x70; +#endif + + _sisSetCrtc (sisc, &crtc); + return TRUE; +} + +Bool +sisDPMS (ScreenPtr pScreen, int mode) +{ + KdScreenPriv(pScreen); + sisCardInfo(pScreenPriv); + union ddc_and_power_control_u _ddc_and_power_control_u; + + ddc_and_power_control = sisc->save.crtc.ddc_and_power_control; + + kbd_cursor_activate = 0; + video_memory_activate = 0; + vga_standby = 0; + vga_suspend = 0; + acpi_enable = 0; + switch (mode) { + case KD_DPMS_NORMAL: + break; + case KD_DPMS_STANDBY: + vga_standby = 1; + break; + case KD_DPMS_SUSPEND: + vga_suspend = 1; + break; + case KD_DPMS_POWERDOWN: + acpi_enable = 1; + break; + } + PutSrtc (sisc, 0x11, ddc_and_power_control); + return TRUE; +} + +void +sisDisable (ScreenPtr pScreen) +{ +} + +void +sisRestore (KdCardInfo *card) +{ + SisCardInfo *sisc = (SisCardInfo *) card->driver; + + memcpy (sisc->frameBuffer, sisc->save.text_save, SIS_TEXT_SAVE); + _sisSetCrtc (sisc, &sisc->save.crtc); + PutSrtc (sisc, 0xb, sisc->save.srb); + PutSrtc (sisc, 0x5, sisc->save.sr5); +} + +void +sisScreenFini (KdScreenInfo *screen) +{ + SisScreenInfo *siss = (SisScreenInfo *) screen->driver; + + xfree (siss); + screen->driver = 0; +} + +void +sisCardFini (KdCardInfo *card) +{ + SisCardInfo *sisc = (SisCardInfo *) card->driver; + + KdUnmapDevice (sisc->frameBuffer, sisc->memory); + KdUnmapDevice (sisc->registers, sizeof (SisRec)); +} + +KdCardFuncs sisFuncs = { + sisCardInit, + sisScreenInit, + 0, + sisPreserve, + sisEnable, + sisDPMS, + sisDisable, + sisRestore, + sisScreenFini, + sisCardFini, + sisCursorInit, + sisCursorEnable, + sisCursorDisable, + sisCursorFini, + 0, + sisDrawInit, + sisDrawEnable, + sisDrawSync, + sisDrawDisable, + sisDrawFini, + sisGetColors, + sisPutColors, +}; --- xorg-server-1.4.99.906.orig/hw/kdrive/sis530/sisio.c +++ xorg-server-1.4.99.906/hw/kdrive/sis530/sisio.c @@ -0,0 +1,30 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#ifdef linux +#define extern +#include +#undef extern +#endif --- xorg-server-1.4.99.906.orig/hw/kdrive/sis530/siscurs.c +++ xorg-server-1.4.99.906/hw/kdrive/sis530/siscurs.c @@ -0,0 +1,364 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "sis.h" +#include "cursorstr.h" + +#define SetupCursor(s) KdScreenPriv(s); \ + sisCardInfo(pScreenPriv); \ + sisScreenInfo(pScreenPriv); \ + SisPtr sis = sisc->sis; \ + SisCursor *pCurPriv = &siss->cursor + +static void +_sisMoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CARD8 xlow, xhigh, ylow, yhigh; + CARD8 xoff, yoff; + + x -= pCurPriv->xhot; + xoff = 0; + if (x < 0) + { + xoff = -x; + x = 0; + } + y -= pCurPriv->yhot; + yoff = 0; + if (y < 0) + { + yoff = -y; + y = 0; + } + xlow = (CARD8) x; + xhigh = (CARD8) (x >> 8); + ylow = (CARD8) y; + yhigh = (CARD8) (y >> 8); + + PutSrtc (sisc, 0x5, 0x86); + PutSrtc (sisc, 0x1c, xoff & 0x3f); + PutSrtc (sisc, 0x1f, yoff & 0x3f); + + PutSrtc (sisc, 0x1a, xlow); + PutSrtc (sisc, 0x1b, xhigh & 0xf); + + PutSrtc (sisc, 0x1d, ylow); + PutSrtc (sisc, 0x1e, yhigh & 0x7); +} + +static void +sisMoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor (pScreen); + + if (!pCurPriv->has_cursor) + return; + + if (!pScreenPriv->enabled) + return; + + LockSis(sisc); + _sisMoveCursor (pScreen, x, y); + UnlockSis(sisc); +} + +static void +_sisSetCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + /* set foreground */ + PutSrtc (sisc, 0x17, pCursor->foreRed >> 10); + PutSrtc (sisc, 0x18, pCursor->foreGreen >> 10); + PutSrtc (sisc, 0x19, pCursor->foreBlue >> 10); + + /* set background */ + PutSrtc (sisc, 0x14, pCursor->backRed >> 10); + PutSrtc (sisc, 0x15, pCursor->backGreen >> 10); + PutSrtc (sisc, 0x16, pCursor->backBlue >> 10); +} + +static void +sisLoadCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + CursorBitsPtr bits = pCursor->bits; + int w, h; + unsigned short *ram, r; + unsigned char *msk, *mskLine, *src, *srcLine; + unsigned short m, s; + + int i, j; + int cursor_address; + int src_stride, src_width; + + CARD8 sr6; + + /* + * Lock Sis so the cursor doesn't move while we're setting it + */ + LockSis(sisc); + + pCurPriv->pCursor = pCursor; + pCurPriv->xhot = pCursor->bits->xhot; + pCurPriv->yhot = pCursor->bits->yhot; + + /* + * Stick new image into cursor memory + */ + ram = (unsigned short *) siss->cursor_base; + mskLine = (unsigned char *) bits->mask; + srcLine = (unsigned char *) bits->source; + + h = bits->height; + if (h > SIS_CURSOR_HEIGHT) + h = SIS_CURSOR_HEIGHT; + + src_stride = BitmapBytePad(bits->width); /* bytes per line */ + src_width = (bits->width + 7) >> 3; + + for (i = 0; i < SIS_CURSOR_HEIGHT; i++) { + msk = mskLine; + src = srcLine; + mskLine += src_stride; + srcLine += src_stride; + for (j = 0; j < SIS_CURSOR_WIDTH / 8; j++) { + + unsigned short m, s; + + if (i < h && j < src_width) + { + m = *msk++; + s = *src++ & m; + m = ~m; + /* mask off right side */ + if (j == src_width - 1 && (bits->width & 7)) + { + m |= 0xff << (bits->width & 7); + } + } + else + { + m = 0xff; + s = 0x00; + } + + /* + * The SIS530 HW cursor format is: source(AND) bit, + * then a mask(XOR) bit, etc. + * byte swapping in sis530 is: + * abcd ==> cdab + */ + +#define bit(a,n) (((a) >> (n)) & 0x1) + + r = ((bit(m, 0) << 7) | (bit(s, 0) << 6) | + (bit(m, 1) << 5) | (bit(s, 1) << 4) | + (bit(m, 2) << 3) | (bit(s, 2) << 2) | + (bit(m, 3) << 1) | (bit(s, 3) << 0) | + (bit(m, 4) << 15) | (bit(s, 4) << 14) | + (bit(m, 5) << 13) | (bit(s, 5) << 12) | + (bit(m, 6) << 11) | (bit(s, 6) << 10) | + (bit(m, 7) << 9) | (bit(s, 7) << 8)); + + *ram++ = r; + } + } + + /* Set new color */ + _sisSetCursorColors (pScreen); + + /* Move to new position */ + _sisMoveCursor (pScreen, x, y); + + /* Enable cursor */ + sr6 = GetSrtc (sisc, 0x6); + sr6 |= 0x40; + PutSrtc (sisc, 0x6, sr6); + + UnlockSis(sisc); +} + +static void +sisUnloadCursor (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CARD8 sr6; + + LockSis (sisc); + + /* Disable cursor */ + sr6 = GetSrtc (sisc, 0x6); + sr6 &= ~0x40; + PutSrtc (sisc, 0x6, sr6); + PutSrtc (sisc, 0x1b, 0x00); + + UnlockSis (sisc); +} + +static Bool +sisRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + SetupCursor(pScreen); + + if (!pScreenPriv->enabled) + return TRUE; + + /* miRecolorCursor does this */ + if (pCurPriv->pCursor == pCursor) + { + if (pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + sisLoadCursor (pScreen, x, y); + } + } + return TRUE; +} + +static Bool +sisUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + return TRUE; +} + +static void +sisSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +{ + SetupCursor(pScreen); + + pCurPriv->pCursor = pCursor; + + if (!pScreenPriv->enabled) + return; + + if (pCursor) + sisLoadCursor (pScreen, x, y); + else + sisUnloadCursor (pScreen); +} + +miPointerSpriteFuncRec sisPointerSpriteFuncs = { + sisRealizeCursor, + sisUnrealizeCursor, + sisSetCursor, + sisMoveCursor, +}; + +static void +sisQueryBestSize (int class, + unsigned short *pwidth, unsigned short *pheight, + ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + switch (class) + { + case CursorShape: + if (*pwidth > pCurPriv->width) + *pwidth = pCurPriv->width; + if (*pheight > pCurPriv->height) + *pheight = pCurPriv->height; + if (*pwidth > pScreen->width) + *pwidth = pScreen->width; + if (*pheight > pScreen->height) + *pheight = pScreen->height; + break; + default: + fbQueryBestSize (class, pwidth, pheight, pScreen); + break; + } +} + +Bool +sisCursorInit (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!siss->cursor_base) + { + pCurPriv->has_cursor = FALSE; + return FALSE; + } + + pCurPriv->width = SIS_CURSOR_WIDTH; + pCurPriv->height= SIS_CURSOR_HEIGHT; + pScreen->QueryBestSize = sisQueryBestSize; + miPointerInitialize (pScreen, + &sisPointerSpriteFuncs, + &kdPointerScreenFuncs, + FALSE); + pCurPriv->has_cursor = TRUE; + pCurPriv->pCursor = NULL; + return TRUE; +} + +void +sisCursorEnable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + sisLoadCursor (pScreen, x, y); + } + else + sisUnloadCursor (pScreen); + } +} + +void +sisCursorDisable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!pScreenPriv->enabled) + return; + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + sisUnloadCursor (pScreen); + } + } +} + +void +sisCursorFini (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + pCurPriv->pCursor = NULL; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/sis530/siscmap.c +++ xorg-server-1.4.99.906/hw/kdrive/sis530/siscmap.c @@ -0,0 +1,64 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "sis.h" + +void +sisGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) +{ + KdScreenPriv(pScreen); + sisCardInfo(pScreenPriv); + + LockSis (sisc); + while (ndef--) + { + _sisOutb (pdefs->pixel, sisc->io_base+SIS_DAC_INDEX_READ); + pdefs->red = _sisInb (sisc->io_base+SIS_DAC_DATA) << 10; + pdefs->green = _sisInb (sisc->io_base+SIS_DAC_DATA) << 10; + pdefs->blue = _sisInb (sisc->io_base+SIS_DAC_DATA) << 10; + pdefs++; + } + UnlockSis (sisc); +} + +void +sisPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) +{ + KdScreenPriv(pScreen); + sisCardInfo(pScreenPriv); + + LockSis(sisc); + _sisWaitVRetrace (sisc); + while (ndef--) + { + _sisOutb (pdefs->pixel, sisc->io_base+SIS_DAC_INDEX_WRITE); + _sisOutb (pdefs->red >> 10, sisc->io_base+SIS_DAC_DATA); + _sisOutb (pdefs->green >> 10, sisc->io_base+SIS_DAC_DATA); + _sisOutb (pdefs->blue >> 10, sisc->io_base+SIS_DAC_DATA); + pdefs++; + } + UnlockSis(sisc); +} + --- xorg-server-1.4.99.906.orig/hw/kdrive/sis530/sisclock.c +++ xorg-server-1.4.99.906/hw/kdrive/sis530/sisclock.c @@ -0,0 +1,232 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "sis.h" +#include + +#define FREF 14318180 +#define MIN_VCO FREF +#define MAX_VCO 230000000 +#define MAX_PSN 0 /* no pre scaler for this chip */ +#define TOLERANCE 0.01 /* search smallest M and N in this tolerance */ +#define max_VLD 1 + +/* + * Compute clock values given target frequency + */ +void +sisGetClock (unsigned long clock, SisCrtc *crtc) +{ + unsigned char reg7, reg13, reg2a, reg2b; + int M, N, P, VLD; + + int bestM, bestN, bestP, bestPSN, bestVLD; + double bestError, abest = 42.0, bestFout; + + double Fvco, Fout; + double error, aerror; + + double target = (double) clock; + + int M_min = 2; + int M_max = 128; + + int low_N = 2; + int high_N = 32; + int PSN = 1; + + /* + * fd = fref*(Numerator/Denumerator)*(Divider/PostScaler) + * + * M = Numerator [1:128] + * N = DeNumerator [1:32] + * VLD = Divider (Vco Loop Divider) : divide by 1, 2 + * P = Post Scaler : divide by 1, 2, 3, 4 + * PSN = Pre Scaler (Reference Divisor Select) + * + * result in vclk[] + */ + + P = 1; + if (target < MAX_VCO / 2) + P = 2; + if (target < MAX_VCO / 3) + P = 3; + if (target < MAX_VCO / 4) + P = 4; + if (target < MAX_VCO / 6) + P = 6; + if (target < MAX_VCO / 8) + P = 8; + + Fvco = P * target; + + for (N = low_N; N <= high_N; N++) + { + double M_desired = Fvco / FREF * N; + + if (M_desired > M_max * max_VLD) + continue; + + if ( M_desired > M_max ) + { + M = (int)(M_desired / 2 + 0.5); + VLD = 2; + } + else + { + M = (int)(M_desired + 0.5); + VLD = 1; + } + + Fout = (double)FREF * (M * VLD)/(N * P); + error = (target - Fout) / target; + aerror = (error < 0) ? -error : error; + if (aerror < abest) + { + abest = aerror; + bestError = error; + bestM = M; + bestN = N; + bestP = P; + bestPSN = PSN; + bestVLD = VLD; + bestFout = Fout; + } + } + + crtc->vclk_numerator = bestM - 1; + crtc->vclk_divide_by_2 = bestVLD == 2; + + crtc->vclk_denominator = bestN - 1; + switch (bestP) { + case 1: + crtc->vclk_post_scale = SIS_VCLK_POST_SCALE_1; + crtc->vclk_post_scale_2 = 0; + break; + case 2: + crtc->vclk_post_scale = SIS_VCLK_POST_SCALE_2; + crtc->vclk_post_scale_2 = 0; + break; + case 3: + crtc->vclk_post_scale = SIS_VCLK_POST_SCALE_3; + crtc->vclk_post_scale_2 = 0; + break; + case 4: + crtc->vclk_post_scale = SIS_VCLK_POST_SCALE_4; + crtc->vclk_post_scale_2 = 0; + break; + case 6: + crtc->vclk_post_scale = SIS_VCLK_POST_SCALE_3; + crtc->vclk_post_scale_2 = 1; + break; + case 8: + crtc->vclk_post_scale = SIS_VCLK_POST_SCALE_4; + crtc->vclk_post_scale_2 = 1; + break; + } + + crtc->vclk_vco_gain = 1; + + /* + * Don't know how to set mclk for local frame buffer; for + * shared frame buffer, mclk is hardwired to bus speed (100MHz)? + */ +} + +sisCalcMclk (SisCrtc *crtc) +{ + int mclk, Numer, DeNumer; + double Divider, Scalar; + + Numer = crtc->mclk_numerator; + DeNumer = crtc->mclk_denominator; + Divider = crtc->mclk_divide_by_2 ? 2.0 : 1.0; + Scalar = 1.0; + if (crtc->mclk_post_scale_2) + { + switch (crtc->mclk_post_scale) { + case 2: + Scalar = 6.0; + break; + case 3: + Scalar = 8.0; + break; + } + } + else + { + switch (crtc->mclk_post_scale) { + case 0: + Scalar = 1.0; + break; + case 1: + Scalar = 2.0; + break; + case 2: + Scalar = 3.0; + break; + case 3: + Scalar = 4.0; + break; + } + } + + mclk = (int)(FREF*((double)(Numer+1)/(double)(DeNumer+1))*(Divider/Scalar)); + + return(mclk); +} + +#define UMA_FACTOR 60 +#define LFB_FACTOR 30 // Only if local frame buffer +#define SIS_SAYS_SO 0x1F // But how is the performance?? +#define CRT_ENG_THRESH 0x0F // But how is the performance?? +#define BUS_WIDTH 64 +#define DFP_BUS_WIDTH 32 // rumour has it for digital flat panel ?? +#define MEGAHZ (1<<20) + +void +sisEngThresh (SisCrtc *crtc, unsigned long vclk, int bpp) +{ + int threshlow, mclk; + + mclk = sisCalcMclk(crtc) / 1000000; + vclk = vclk / 1000000; + threshlow = ((((UMA_FACTOR*vclk*bpp)/ + (mclk*BUS_WIDTH))+1)/2)+4; + + crtc->crt_cpu_threshold_low_0_3 = threshlow; + crtc->crt_cpu_threshold_low_4 = threshlow >> 4; + + crtc->crt_cpu_threshold_high_0_3 = (SIS_SAYS_SO & 0xf); + crtc->crt_cpu_threshold_high_4 = 0; + + crtc->crt_engine_threshold_high_0_3 = CRT_ENG_THRESH; + crtc->crt_engine_threshold_high_4 = 1; + + crtc->ascii_attribute_threshold_0_2 = (SIS_SAYS_SO >> 4); + + crtc->crt_threshold_full_control = SIS_CRT_64_STAGE_THRESHOLD; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/sis530/sis.h +++ xorg-server-1.4.99.906/hw/kdrive/sis530/sis.h @@ -0,0 +1,1215 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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. + */ + +#ifndef _SIS_H_ +#define _SIS_H_ +#include "kdrive.h" +#include +#include +#include +#include +#include + +/* + * Linear Addressing 000 0000 - 0ff ffff (16m) + * Image data transfer 100 0000 - 100 7fff (32k) + * Empty 100 8000 - 100 81ff + * MMIO registers 100 8200 - 100 8480 + * + * We don't care about the image transfer or PCI regs, so + * this structure starts at the MMIO regs + */ + +typedef volatile CARD32 VOL32; +typedef volatile CARD16 VOL16; +typedef volatile CARD8 VOL8; + +#define SIS_MMIO_OFFSET 0x8200 + +typedef struct _sis530General { + VOL32 src_base; /* 8200 */ + VOL16 src_pitch; /* 8204 */ + VOL16 _pad0; /* 8206 */ + VOL16 src_y; /* 8208 */ + VOL16 src_x; /* 820a */ + VOL16 dst_y; /* 820c */ + VOL16 dst_x; /* 820e */ + VOL32 dst_base; /* 8210 */ + VOL16 dst_pitch; /* 8214 */ + VOL16 dst_height; /* 8216 */ + VOL16 rect_width; /* 8218 */ + VOL16 rect_height; /* 821a */ + VOL32 pattern_fg; /* 821c */ + VOL32 pattern_bg; /* 8220 */ + VOL32 src_fg; /* 8224 */ + VOL32 src_bg; /* 8228 */ + VOL8 mask[8]; /* 822c */ + VOL16 clip_left; /* 8234 */ + VOL16 clip_top; /* 8236 */ + VOL16 clip_right; /* 8238 */ + VOL16 clip_bottom; /* 823a */ + VOL32 command; /* 823c */ + VOL32 status; /* 8240 */ + VOL8 _pad1[0xbc]; /* 8244 */ + VOL8 pattern[256]; /* 8300 */ + /* 8400 */ +} SisGeneral; + +typedef struct _sis530Line { + VOL8 _pad0[8]; /* 8200 */ + VOL16 x0; /* 8208 */ + VOL16 y0; /* 820a */ + VOL16 x1; /* 820c */ + VOL16 y1; /* 820e */ + VOL32 dst_base; /* 8210 */ + VOL16 dst_pitch; /* 8214 */ + VOL16 dst_height; /* 8216 */ + VOL16 count; /* 8218 */ + VOL16 style_period; /* 821a */ + VOL32 fg; /* 821c */ + VOL32 bg; /* 8220 */ + VOL8 _pad1[8]; /* 8224 */ + VOL32 style0; /* 822c */ + VOL32 style1; /* 8228 */ + VOL16 clip_left; /* 8234 */ + VOL16 clip_top; /* 8236 */ + VOL16 clip_right; /* 8238 */ + VOL16 clip_bottom; /* 823a */ + VOL32 command; /* 823c */ + VOL32 status; /* 8240 */ + VOL8 _pad2[0xbc]; /* 8244 */ + struct { + VOL16 x; + VOL16 y; + } data[96]; /* 8300 */ + /* 8480 */ +} SisLine; + +typedef struct _sis530Transparent { + VOL32 src_base; /* 8200 */ + VOL16 src_pitch; /* 8204 */ + VOL16 _pad0; /* 8206 */ + VOL16 src_y; /* 8208 */ + VOL16 src_x; /* 820a */ + VOL16 dst_y; /* 820c */ + VOL16 dst_x; /* 820e */ + VOL32 dst_base; /* 8210 */ + VOL16 dst_pitch; /* 8214 */ + VOL16 dst_height; /* 8216 */ + VOL16 rect_width; /* 8218 */ + VOL16 rect_height; /* 821a */ + VOL32 dst_key_high; /* 821c */ + VOL32 dst_key_low; /* 8220 */ + VOL32 src_key_high; /* 8224 */ + VOL32 src_key_low; /* 8228 */ + VOL8 _pad1[8]; /* 822c */ + VOL16 clip_left; /* 8234 */ + VOL16 clip_top; /* 8236 */ + VOL16 clip_right; /* 8238 */ + VOL16 clip_bottom; /* 823a */ + VOL32 command; /* 823c */ + VOL32 status; /* 8240 */ + /* 8244 */ +} SisTransparent; + +typedef struct _sis530Multiple { + VOL8 _pad0[8]; /* 8200 */ + VOL16 count; /* 8208 */ + VOL16 y; /* 820a */ + VOL16 x0_start; /* 820c */ + VOL16 x0_end; /* 820e */ + VOL32 dst_base; /* 8210 */ + VOL16 dst_pitch; /* 8214 */ + VOL16 dst_height; /* 8216 */ + VOL8 _pad1[4]; /* 8218 */ + VOL32 fg; /* 821c */ + VOL32 bg; /* 8220 */ + VOL8 _pad2[8]; /* 8224 */ + VOL8 mask[8]; /* 822c */ + VOL16 clip_left; /* 8234 */ + VOL16 clip_top; /* 8236 */ + VOL16 clip_right; /* 8238 */ + VOL16 clip_bottom; /* 823a */ + VOL32 command; /* 823c */ + VOL32 status; /* 8240 */ + VOL16 x1_start; /* 8244 */ + VOL16 x1_end; /* 8246 */ + VOL8 _pad3[0xb8]; /* 8248 */ + VOL8 pattern[64]; /* 8300 */ + struct { + VOL16 x_start; + VOL16 y_end; + } data[80]; /* 8340 */ + /* 8480 */ +} SisMultiple; + +typedef struct _sis530Trapezoid { + VOL8 _pad0[8]; /* 8200 */ + VOL16 height; /* 8208 */ + VOL16 y; /* 820a */ + VOL16 left_x; /* 820c */ + VOL16 right_x; /* 820e */ + VOL32 dst_base; /* 8210 */ + VOL16 dst_pitch; /* 8214 */ + VOL16 dst_height; /* 8216 */ + VOL8 _pad1[4]; /* 8218 */ + VOL32 fg; /* 821c */ + VOL32 bg; /* 8220 */ + VOL8 _pad2[8]; /* 8224 */ + VOL8 mask[8]; /* 822c */ + VOL16 clip_left; /* 8234 */ + VOL16 clip_top; /* 8236 */ + VOL16 clip_right; /* 8238 */ + VOL16 clip_bottom; /* 823a */ + VOL32 command; /* 823c */ + VOL32 status; /* 8240 */ + VOL16 left_dx; /* 8244 */ + VOL16 left_dy; /* 8246 */ + VOL16 right_dx; /* 8248 */ + VOL16 right_dy; /* 824a */ + VOL32 left_error; /* 824c */ + VOL32 right_error; /* 8250 */ + /* 8254 */ +} SisTrapezoid; + +typedef struct _sisAccel { + VOL8 pad[0x80]; /* 8200 */ + VOL32 src_addr; /* 8280 */ + VOL32 dst_addr; /* 8284 */ + VOL32 pitch; /* 8288 */ + VOL32 dimension; /* 828c */ + VOL32 fg; /* 8290 */ + VOL32 bg; /* 8294 */ + + + VOL32 clip_ul; /* 82a0 */ + VOL32 clip_br; /* 82a4 */ + + VOL16 cmd; /* 82aa */ + + VOL8 pattern[256]; /* 82ac */ + +} SisAccel; + +typedef struct _sis530 { + union { + SisGeneral general; + SisLine line; + SisTransparent transparent; + SisMultiple multiple; + SisTrapezoid trapezoid; + SisAccel accel; + } u; +} SisRec, *SisPtr; + +typedef struct _sisCursor { + int width, height; + int xhot, yhot; + Bool has_cursor; + CursorPtr pCursor; +} SisCursor; + +#define SIS_CURSOR_WIDTH 64 +#define SIS_CURSOR_HEIGHT 64 + +typedef struct _sisClock { + CARD32 vclk_numerator; + BOOL vclk_divide_by_2; + CARD32 vclk_denominator; + CARD32 vclk_post_scale; + BOOL vclk_post_scale_2; + BOOL high_speed_dac; +} SisClockRec, *SisClockPtr; + +typedef struct _crtc { + + union { + struct { + CARD8 _io_address_select : 1; + CARD8 _display_ram_enable : 1; + CARD8 _clock_select : 2; + CARD8 : 1; + CARD8 _odd_even_page : 1; + CARD8 _h_sync_polarity : 1; + CARD8 _v_sync_polarity : 1; + } _misc_output_s; + CARD8 _misc_output; + } _misc_output_u; /* 3CC/3C2 */ + +#define misc_output _misc_output_u._misc_output +#define io_address_select _misc_output_u._misc_output_s._io_address_select +#define display_ram_enable _misc_output_u._misc_output_s._display_ram_enable +#define clock_select _misc_output_u._misc_output_s._clock_select +#define odd_even_page _misc_output_u._misc_output_s._odd_even_page +#define h_sync_polarity _misc_output_u._misc_output_s._h_sync_polarity +#define v_sync_polarity _misc_output_u._misc_output_s._v_sync_polarity + + CARD8 h_total_0_7; /* CR0 */ + CARD8 h_display_end_0_7; /* CR1 */ + CARD8 h_blank_start_0_7; /* CR2 */ + union { + struct { + CARD8 _h_blank_end_0_4 : 5; + CARD8 _display_skew : 2; + CARD8 : 1; + } _h_blank_end_s; + CARD8 __h_blank_end; /* CR3 */ + } _h_blank_end_u; +#define h_blank_end_0_4 _h_blank_end_u._h_blank_end_s._h_blank_end_0_4 +#define display_skew _h_blank_end_u._h_blank_end_s._display_skew +#define _h_blank_end _h_blank_end_u.__h_blank_end + + CARD8 h_sync_start_0_7; /* CR4 */ + + union { + struct { + CARD8 _h_sync_end_0_4 : 5; + CARD8 _horizontal_skew : 2; + CARD8 _h_blank_end_5 : 1; + } _h_sync_end_s; + CARD8 __h_sync_end; /* CR5 */ + } _h_sync_end_u; + +#define h_sync_end_0_4 _h_sync_end_u._h_sync_end_s._h_sync_end_0_4 +#define horizontal_skew _h_sync_end_u._h_sync_end_s._horizontal_skew +#define h_blank_end_5 _h_sync_end_u._h_sync_end_s._h_blank_end_5 +#define _h_sync_end _h_sync_end_u.__h_sync_end + + CARD8 v_total_0_7; /* CR6 */ + + union { + struct { + CARD8 _v_total_8 : 1; + CARD8 _v_display_end_8 : 1; + CARD8 _v_retrace_start_8 : 1; + CARD8 _v_blank_start_8 : 1; + CARD8 _line_compare_8 : 1; + CARD8 _v_total_9 : 1; + CARD8 _v_display_end_9 : 1; + CARD8 _v_retrace_start_9 : 1; + } _crtc_overflow_s; + CARD8 _crtc_overflow; /* CR7 */ + } _crtc_overflow_u; + +#define v_total_8 _crtc_overflow_u._crtc_overflow_s._v_total_8 +#define v_display_end_8 _crtc_overflow_u._crtc_overflow_s._v_display_end_8 +#define v_retrace_start_8 _crtc_overflow_u._crtc_overflow_s._v_retrace_start_8 +#define v_blank_start_8 _crtc_overflow_u._crtc_overflow_s._v_blank_start_8 +#define line_compare_8 _crtc_overflow_u._crtc_overflow_s._line_compare_8 +#define v_total_9 _crtc_overflow_u._crtc_overflow_s._v_total_9 +#define v_display_end_9 _crtc_overflow_u._crtc_overflow_s._v_display_end_9 +#define v_retrace_start_9 _crtc_overflow_u._crtc_overflow_s._v_retrace_start_9 +#define crtc_overflow _crtc_overflow_u._crtc_overflow + + CARD8 preset_row_scan; /* CR8 (unused) */ + + union { + struct { + CARD8 ___max_scan_line : 5; + CARD8 _v_blank_start_9 : 1; + CARD8 _line_compare_9 : 1; + CARD8 _double_scan : 1; + } _max_scan_line_s; + CARD8 __max_scan_line; /* CR9 */ + } _max_scan_line_u; + +#define max_scan_line _max_scan_line_u._max_scan_line_s.___max_scan_line +#define v_blank_start_9 _max_scan_line_u._max_scan_line_s._v_blank_start_9 +#define line_compare_9 _max_scan_line_u._max_scan_line_s._line_compare_9 +#define double_scan _max_scan_line_u._max_scan_line_s._double_scan +#define _max_scan_line _max_scan_line_u.__max_scan_line + + CARD8 cursor_start; /* CRA */ + CARD8 cursor_end; /* CRB */ + + CARD8 start_address_8_15; /* CRC */ + CARD8 start_address_0_7; /* CRD */ + + CARD8 text_cursor_15_8; /* CRE */ + CARD8 text_cursor_7_0; /* CRF */ + + CARD8 cursor_loc_high; + CARD8 cursor_loc_low; + + CARD8 v_retrace_start_0_7; /* CR10 */ + union { + struct { + CARD8 _v_retrace_end_0_3 : 4; + CARD8 _clear_v_retrace_int : 1; + CARD8 _disable_v_retrace_int : 1; + CARD8 _refresh_cycle_select : 1; + CARD8 _lock_crtc : 1; + } _v_retrace_end_s; + CARD8 __v_retrace_end; /* CR11 */ + } _v_retrace_end_u; + +#define v_retrace_end_0_3 _v_retrace_end_u._v_retrace_end_s._v_retrace_end_0_3 +#define clear_v_retrace_int _v_retrace_end_u._v_retrace_end_s._clear_v_retrace_int +#define disable_v_retrace_int _v_retrace_end_u._v_retrace_end_s._disable_v_retrace_int +#define refresh_cycle_select _v_retrace_end_u._v_retrace_end_s._refresh_cycle_select +#define lock_crtc _v_retrace_end_u._v_retrace_end_s._lock_crtc +#define _v_retrace_end _v_retrace_end_u.__v_retrace_end + + CARD8 v_display_end_0_7; /* CR12 */ + + CARD8 screen_off_0_7; /* CR13 */ + + union { + struct { + CARD8 ___underline_location : 5; + CARD8 _count_by_four : 1; + CARD8 _doubleword_mode : 1; + CARD8 : 1; + } _underline_location_s; + CARD8 __underline_location; /* CR14 */ + } _underline_location_u; + +#define underline_location _underline_location_u._underline_location_s.___underline_location +#define count_by_four _underline_location_u._underline_location_s._count_by_four +#define doubleword_mode _underline_location_u._underline_location_s._doubleword_mode +#define _underline_location _underline_location_u.__underline_location + + CARD8 v_blank_start_0_7; /* CR15 */ + CARD8 v_blank_end_0_7; /* CR16 */ + + union { + struct { + CARD8 _two_bk_cga : 1; + CARD8 _four_bk_cga : 1; + CARD8 _v_total_double : 1; + CARD8 _count_by_two : 1; + CARD8 : 1; + CARD8 _address_wrap : 1; + CARD8 _byte_mode : 1; + CARD8 _hardware_reset : 1; + } _crtc_mode_s; + CARD8 _crtc_mode; /* CR17 */ + } _crtc_mode_u; + +#define crtc_mode _crtc_mode_u._crtc_mode +#define two_bk_cga _crtc_mode_u._crtc_mode_s._two_bk_cga +#define four_bk_cga _crtc_mode_u._crtc_mode_s._four_bk_cga +#define v_total_double _crtc_mode_u._crtc_mode_s._v_total_double +#define count_by_two _crtc_mode_u._crtc_mode_s._count_by_two +#define address_wrap _crtc_mode_u._crtc_mode_s._address_wrap +#define byte_mode _crtc_mode_u._crtc_mode_s._byte_mode +#define hardware_reset _crtc_mode_u._crtc_mode_s._hardware_reset + + CARD8 line_compare_0_7; /* CR18 (unused) */ + + union { + struct { + CARD8 _graphics_mode_enable : 1; + CARD8 _attribute_byte_mda : 1; + CARD8 _line_graphics_enable : 1; + CARD8 _background_blink : 1; + CARD8 : 1; + CARD8 _pel_panning_compat : 1; + CARD8 _pixel_clock_double : 1; + CARD8 p4_p5_source_select : 1; + } _mode_control_s; + CARD8 _mode_control; + } _mode_control_u; /* AR10 */ + +#define mode_control _mode_control_u._mode_control +#define graphics_mode_enable _mode_control_u._mode_control_s._graphics_mode_enable +#define pixel_clock_double _mode_control_u._mode_control_s._pixel_clock_double + + CARD8 screen_border_color; /* AR11 */ + CARD8 enable_color_plane; /* AR12 */ + CARD8 horizontal_pixel_pan; /* AR13 */ + + union { + struct { + CARD8 _write_mode : 2; + CARD8 : 1; + CARD8 _read_mode : 1; + CARD8 _odd_even_addressing : 1; + CARD8 _shift_register_mode : 1; + CARD8 _color_mode_256 : 1; + CARD8 : 1; + } _mode_register_s; + CARD8 _mode_register; + } _mode_register_u; /* GR5 */ + +#define mode_register _mode_register_u._mode_register +#define color_mode_256 _mode_register_u._mode_register_s._color_mode_256 +#define odd_even_addressing _mode_register_u._mode_register_s._odd_even_addressing + + union { + struct { + CARD8 _graphics_enable : 1; + CARD8 _chain_odd_even : 1; + CARD8 _memory_address_select : 2; + CARD8 : 4; + } _misc_register_s; + CARD8 _misc_register; + } _misc_register_u; /* GR6 */ + +#define misc_register _misc_register_u._misc_register +#define graphics_enable _misc_register_u._misc_register_s._graphics_enable +#define chain_odd_even _misc_register_u._misc_register_s._chain_odd_even +#define memory_address_select _misc_register_u._misc_register_s._memory_address_select + + CARD8 color_dont_care; /* GR7 */ + + union { + struct { + CARD8 _dot_clock_8_9 : 1; + CARD8 : 1; + CARD8 _shifter_load_16 : 1; + CARD8 _dot_clock_divide_2 : 1; + CARD8 _shifter_load_32 : 1; + CARD8 _display_off : 1; + CARD8 : 2; + } _clock_mode_s; + CARD8 _clock_mode; + } _clock_mode_u; /* SR1 */ + +#define clock_mode _clock_mode_u._clock_mode +#define dot_clock_8_9 _clock_mode_u._clock_mode_s._dot_clock_8_9 +#define shifter_load_16 _clock_mode_u._clock_mode_s._shifter_load_16 +#define dot_clock_divide_2 _clock_mode_u._clock_mode_s._dot_clock_divide_2 +#define shifter_load_32 _clock_mode_u._clock_mode_s._shifter_load_32 +#define display_off _clock_mode_u._clock_mode_s._display_off + + CARD8 color_plane_w_enable; /* SR2 */ + + union { + struct { + CARD8 : 1; + CARD8 _extended_memory_size : 1; + CARD8 _odd_even_disable : 1; + CARD8 _chain_4_enable : 1; + CARD8 : 4; + } _memory_mode_s; + CARD8 _memory_mode; + } _memory_mode_u; /* SR4 */ + +#define memory_mode _memory_mode_u._memory_mode +#define extended_memory_sz _memory_mode_u._memory_mode_s._extended_memory_size +#define odd_even_disable _memory_mode_u._memory_mode_s._odd_even_disable +#define chain_4_enable _memory_mode_u._memory_mode_s._chain_4_enable + + union { + struct { + CARD8 _enhanced_text_mode : 1; + CARD8 _enhanced_graphics_mode : 1; + CARD8 _graphics_mode_32k : 1; + CARD8 _graphics_mode_64k : 1; + CARD8 _graphics_mode_true : 1; + CARD8 _graphics_mode_interlaced: 1; + CARD8 _graphics_mode_hw_cursor: 1; + CARD8 _graphics_mode_linear : 1; + } _graphics_mode_s; + CARD8 _graphics_mode; + } _graphics_mode_u; /* SR6 */ + +#define graphics_mode _graphics_mode_u._graphics_mode +#define enhanced_text_mode _graphics_mode_u._graphics_mode_s._enhanced_text_mode +#define enhanced_graphics_mode _graphics_mode_u._graphics_mode_s._enhanced_graphics_mode +#define graphics_mode_32k _graphics_mode_u._graphics_mode_s._graphics_mode_32k +#define graphics_mode_64k _graphics_mode_u._graphics_mode_s._graphics_mode_64k +#define graphics_mode_true _graphics_mode_u._graphics_mode_s._graphics_mode_true +#define graphics_mode_interlaced _graphics_mode_u._graphics_mode_s._graphics_mode_interlaced +#define graphics_mode_hw_cursor _graphics_mode_u._graphics_mode_s._graphics_mode_hw_cursor +#define graphics_mode_linear _graphics_mode_u._graphics_mode_s._graphics_mode_linear + + union { + struct { + CARD8 _external_dac_reference : 1; + CARD8 _high_speed_dac_0 : 1; + CARD8 _direct_color_24bit : 1; + CARD8 _multi_line_prefetch : 1; + CARD8 _extended_video_div_2 : 1; + CARD8 _ramdac_power_save : 1; + CARD8 : 1; + CARD8 _merge_video_fifo : 1; + } _misc_control_0_s; + CARD8 _misc_control_0; + } _misc_control_0_u; /* SR7 */ + +#define misc_control_0 _misc_control_0_u._misc_control_0 +#define external_dac_reference _misc_control_0_u._misc_control_0_s._external_dac_reference +#define high_speed_dac_0 _misc_control_0_u._misc_control_0_s._high_speed_dac_0 +#define direct_color_24bit _misc_control_0_u._misc_control_0_s._direct_color_24bit +#define multi_line_prefetch _misc_control_0_u._misc_control_0_s._multi_line_prefetch +#define extended_video_div_2 _misc_control_0_u._misc_control_0_s._extended_video_div_2 +#define ramdac_power_save _misc_control_0_u._misc_control_0_s._ramdac_power_save +#define merge_video_fifo _misc_control_0_u._misc_control_0_s._merge_video_fifo + + union { + struct { + CARD8 _crt_engine_threshold_high_0_3 : 4; + CARD8 _crt_cpu_threshold_low_0_3 : 4; + } _crt_cpu_threshold_control_0_s; + CARD8 _crt_cpu_threshold_control_0; + } _crt_cpu_threshold_control_0_u; /* SR8 */ + +#define crt_cpu_threshold_control_0 _crt_cpu_threshold_control_0_u._crt_cpu_threshold_control_0 +#define crt_engine_threshold_high_0_3 _crt_cpu_threshold_control_0_u._crt_cpu_threshold_control_0_s._crt_engine_threshold_high_0_3 +#define crt_cpu_threshold_low_0_3 _crt_cpu_threshold_control_0_u._crt_cpu_threshold_control_0_s._crt_cpu_threshold_low_0_3 + + union { + struct { + CARD8 _crt_cpu_threshold_high_0_3 : 4; + CARD8 _ascii_attribute_threshold_0_2 : 3; + CARD8 _true_color_32bpp : 1; + } _crt_cpu_threshold_control_1_s; + CARD8 _crt_cpu_threshold_control_1; + } _crt_cpu_threshold_control_1_u; /* SR9 */ + +#define crt_cpu_threshold_control_1 _crt_cpu_threshold_control_1_u._crt_cpu_threshold_control_1 +#define crt_cpu_threshold_high_0_3 _crt_cpu_threshold_control_1_u._crt_cpu_threshold_control_1_s._crt_cpu_threshold_high_0_3 +#define ascii_attribute_threshold_0_2 _crt_cpu_threshold_control_1_u._crt_cpu_threshold_control_1_s._ascii_attribute_threshold_0_2 +#define true_color_32bpp _crt_cpu_threshold_control_1_u._crt_cpu_threshold_control_1_s._true_color_32bpp + + union { + struct { + CARD8 _v_total_10 : 1; + CARD8 _v_display_end_10 : 1; + CARD8 _v_blank_start_10 : 1; + CARD8 _v_retrace_start_10 : 1; + CARD8 _screen_off_8_11 : 4; + } _extended_crt_overflow_s; + CARD8 _extended_crt_overflow; + } _extended_crt_overflow_u; /* SRA */ + +#define extended_crt_overflow _extended_crt_overflow_u._extended_crt_overflow +#define v_total_10 _extended_crt_overflow_u._extended_crt_overflow_s._v_total_10 +#define v_display_end_10 _extended_crt_overflow_u._extended_crt_overflow_s._v_display_end_10 +#define v_blank_start_10 _extended_crt_overflow_u._extended_crt_overflow_s._v_blank_start_10 +#define v_retrace_start_10 _extended_crt_overflow_u._extended_crt_overflow_s._v_retrace_start_10 +#define screen_off_8_11 _extended_crt_overflow_u._extended_crt_overflow_s._screen_off_8_11 + + union { + struct { + CARD8 _cpu_bitblt_enable : 1; /* enable CPU bitblt */ + CARD8 _packed_16_color_enable : 1; /* 2 pixels per byte? */ + CARD8 _io_gating : 1; /* when write buffer not empty */ + CARD8 _dual_segment_enable : 1; /* ? */ + CARD8 _true_color_modulation : 1; /* ? */ + CARD8 _memory_mapped_mode : 2; /* mmio enable */ + CARD8 _true_color_order : 1; /* 0: RGB 1: BGR */ + } _misc_control_1_s; + CARD8 _misc_control_1; /* SRB */ + } _misc_control_1_u; + +#define misc_control_1 _misc_control_1_u._misc_control_1 +#define cpu_bitblt_enable _misc_control_1_u._misc_control_1_s._cpu_bitblt_enable +#define memory_mapped_mode _misc_control_1_u._misc_control_1_s._memory_mapped_mode +#define true_color_modulation _misc_control_1_u._misc_control_1_s._true_color_modulation +#define true_color_order _misc_control_1_u._misc_control_1_s._true_color_order + + union { + struct { + CARD8 _sync_reset_enable : 1; + CARD8 _memory_configuration : 3; +#define SIS_MEMORY_CONFIG_1M_1BANK 0 +#define SIS_MEMORY_CONFIG_2M_2BANK 1 +#define SIS_MEMORY_CONFIG_4M_2BANK 2 +#define SIS_MEMORY_CONFIG_2M_1BANK 5 +#define SIS_MEMORY_CONFIG_4M_1BANK 6 +#define SIS_MEMORY_CONFIG_8M_2BANK 7 + CARD8 _test_mode_enable : 1; + CARD8 _read_ahead_enable : 1; + CARD8 _text_mode_16bit_enable : 1; + CARD8 _graphics_mode_32bit_enable : 1; + } _misc_control_2_s; + CARD8 _misc_control_2; + } _misc_control_2_u; /* SRC */ + +#define misc_control_2 _misc_control_2_u._misc_control_2 +#define sync_reset_enable _misc_control_2_u._misc_control_2_s._sync_reset_enable +#define memory_configuration _misc_control_2_u._misc_control_2_s._memory_configuration +#define test_mode_enable _misc_control_2_u._misc_control_2_s._test_mode_enable +#define read_ahead_enable _misc_control_2_u._misc_control_2_s._read_ahead_enable +#define text_mode_16bit_enable _misc_control_2_u._misc_control_2_s._text_mode_16bit_enable +#define graphics_mode_32bit_enable _misc_control_2_u._misc_control_2_s._graphics_mode_32bit_enable + + union ddc_and_power_control_u { + struct { + CARD8 _ddc_clk_programming : 1; + CARD8 _ddc_data_programming : 1; + CARD8 : 1; + CARD8 _acpi_enable : 1; + CARD8 _kbd_cursor_activate : 1; + CARD8 _video_memory_activate : 1; + CARD8 _vga_standby : 1; + CARD8 _vga_suspend : 1; + } _ddc_and_power_control_s; + CARD8 _ddc_and_power_control; + } _ddc_and_power_control_u; /* SR11 */ + +#define ddc_and_power_control _ddc_and_power_control_u._ddc_and_power_control +#define ddc_clk_programming _ddc_and_power_control_u._ddc_and_power_control_s._ddc_clk_programming +#define ddc_data_programming _ddc_and_power_control_u._ddc_and_power_control_s._ddc_data_programming +#define acpi_enable _ddc_and_power_control_u._ddc_and_power_control_s._acpi_enable +#define kbd_cursor_activate _ddc_and_power_control_u._ddc_and_power_control_s._kbd_cursor_activate +#define video_memory_activate _ddc_and_power_control_u._ddc_and_power_control_s._video_memory_activate +#define vga_standby _ddc_and_power_control_u._ddc_and_power_control_s._vga_standby +#define vga_suspend _ddc_and_power_control_u._ddc_and_power_control_s._vga_suspend + + union { + struct { + CARD8 _h_total_8 : 1; + CARD8 _h_display_end_8 : 1; + CARD8 _h_blank_start_8 : 1; + CARD8 _h_sync_start_8 : 1; + CARD8 _h_blank_end_6 : 1; + CARD8 _h_retrace_skew : 3; + } _extended_horizontal_overflow_s; + CARD8 _extended_horizontal_overflow; + } _extended_horizontal_overflow_u; /* SR12 */ +#define extended_horizontal_overflow _extended_horizontal_overflow_u._extended_horizontal_overflow +#define h_total_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_total_8 +#define h_display_end_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_display_end_8 +#define h_blank_start_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_blank_start_8 +#define h_sync_start_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_sync_start_8 +#define h_blank_end_6 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_blank_end_6 +#define h_retrace_skew _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_retrace_skew + + union { + struct { + CARD8 : 6; + CARD8 _vclk_post_scale_2 : 1; + CARD8 _mclk_post_scale_2 : 1; + } _extended_clock_generator_s; + CARD8 _extended_clock_generator; + } _extended_clock_generator_u; /* SR13 */ + +#define extended_clock_generator _extended_clock_generator_u._extended_clock_generator +#define vclk_post_scale_2 _extended_clock_generator_u._extended_clock_generator_s._vclk_post_scale_2 +#define mclk_post_scale_2 _extended_clock_generator_u._extended_clock_generator_s._mclk_post_scale_2 + + CARD8 cursor_0_red; /* SR14 */ + CARD8 cursor_0_green; /* SR15 */ + CARD8 cursor_0_blue; /* SR16 */ + + CARD8 cursor_1_red; /* SR17 */ + CARD8 cursor_1_green; /* SR18 */ + CARD8 cursor_1_blue; /* SR19 */ + + CARD8 cursor_h_start_0_7; /* SR1A */ + union { + struct { + CARD8 _cursor_h_start_8_11 : 4; + CARD8 : 3; + CARD8 _cursor_mmio_enable : 1; + } _cusor_h_start_1_s; + CARD8 _cursor_h_start_1; + } _cursor_h_start_1_u; /* SR1B */ + +#define cursor_h_start_1 _cursor_h_start_1_u._cursor_h_start_1 +#define cursor_h_start_8_11 _cursor_h_start_1_u._cursor_h_start_1_s._cursor_h_start_8_11 + + CARD8 cursor_h_preset_0_5; /* SR1C */ + + CARD8 cursor_v_start_0_7; /* SR1D */ + + union { + struct { + CARD8 _cursor_v_start_8_10 : 3; + CARD8 _cursor_side_pattern : 1; + CARD8 _cursor_pattern : 4; + } _cusor_v_start_1_s; + CARD8 _cursor_v_start_1; + } _cursor_v_start_1_u; /* SR1E */ + +#define cursor_v_start_1 _cursor_v_start_1_u._cursor_v_start_1 + + CARD8 cursor_v_preset_0_5; /* SR1F */ + + CARD8 linear_base_19_26; /* SR20 */ + + union { + struct { + CARD8 _linear_base_27_31 : 5; + CARD8 _linear_aperture : 3; +#define SIS_LINEAR_APERTURE_512K 0 +#define SIS_LINEAR_APERTURE_1M 1 +#define SIS_LINEAR_APERTURE_2M 2 +#define SIS_LINEAR_APERTURE_4M 3 +#define SIS_LINEAR_APERTURE_8M 4 + } _linear_base_1_s; + CARD8 _linear_base_1; + } _linear_base_1_u; /* SR21 */ + +#define linear_base_1 _linear_base_1_u._linear_base_1 +#define linear_base_27_31 _linear_base_1_u._linear_base_1_s._linear_base_27_31 +#define linear_aperture _linear_base_1_u._linear_base_1_s._linear_aperture + + union { + struct { + CARD8 _screen_start_addr_20 : 1; + CARD8 : 3; + CARD8 _continuous_mem_access : 1; + CARD8 : 1; + CARD8 _power_down_dac : 1; + CARD8 : 1; + } _graphics_engine_0_s; + CARD8 _graphics_engine_0; + } _graphics_engine_0_u; /* SR26 */ + +#define graphics_engine_0 _graphics_engine_0_u._graphics_engine_0 + + + union { + struct { + CARD8 _screen_start_addr_16_19: 4; + CARD8 _logical_screen_width : 2; +#define SIS_LOG_SCREEN_WIDTH_1024 0 +#define SIS_LOG_SCREEN_WIDTH_2048 1 +#define SIS_LOG_SCREEN_WIDTH_4096 2 + CARD8 _graphics_prog_enable : 1; + CARD8 _turbo_queue_enable : 1; + } _graphics_engine_1_s; + CARD8 _graphics_engine_1; + } _graphics_engine_1_u; /* SR27 */ + +#define graphics_engine_1 _graphics_engine_1_u._graphics_engine_1 +#define screen_start_addr_16_19 _graphics_engine_1_u._graphics_engine_1_s._screen_start_addr_16_19 +#define logical_screen_width _graphics_engine_1_u._graphics_engine_1_s._logical_screen_width +#define graphics_prog_enable _graphics_engine_1_u._graphics_engine_1_s._graphics_prog_enable +#define turbo_queue_enable _graphics_engine_1_u._graphics_engine_1_s._turbo_queue_enable + + + union { + struct { + CARD8 _mclk_numerator : 7; + CARD8 _mclk_divide_by_2 : 1; + } _internal_mclk_0_s; + CARD8 _internal_mclk_0; + } _internal_mclk_0_u; /* SR28 */ + +#define internal_mclk_0 _internal_mclk_0_u._internal_mclk_0 +#define mclk_numerator _internal_mclk_0_u._internal_mclk_0_s._mclk_numerator +#define mclk_divide_by_2 _internal_mclk_0_u._internal_mclk_0_s._mclk_divide_by_2 + + union { + struct { + CARD8 _mclk_denominator : 5; + CARD8 _mclk_post_scale : 2; +#define SIS_MCLK_POST_SCALE_1 0 +#define SIS_MCLK_POST_SCALE_2 1 +#define SIS_MCLK_POST_SCALE_3 2 +#define SIS_MCLK_POST_SCALE_4 3 + CARD8 _mclk_vco_gain : 1; + } _internal_mclk_1_s; + CARD8 _internal_mclk_1; + } _internal_mclk_1_u; /* SR29 */ + +#define internal_mclk_1 _internal_mclk_1_u._internal_mclk_1 +#define mclk_denominator _internal_mclk_1_u._internal_mclk_1_s._mclk_denominator +#define mclk_post_scale _internal_mclk_1_u._internal_mclk_1_s._mclk_post_scale +#define mclk_vco_gain _internal_mclk_1_u._internal_mclk_1_s._mclk_vco_gain + + union { + struct { + CARD8 _vclk_numerator : 7; + CARD8 _vclk_divide_by_2 : 1; + } _internal_vclk_0_s; + CARD8 _internal_vclk_0; + } _internal_vclk_0_u; /* SR2A */ + +#define internal_vclk_0 _internal_vclk_0_u._internal_vclk_0 +#define vclk_numerator _internal_vclk_0_u._internal_vclk_0_s._vclk_numerator +#define vclk_divide_by_2 _internal_vclk_0_u._internal_vclk_0_s._vclk_divide_by_2 + + union { + struct { + CARD8 _vclk_denominator : 5; + CARD8 _vclk_post_scale : 2; +#define SIS_VCLK_POST_SCALE_1 0 +#define SIS_VCLK_POST_SCALE_2 1 +#define SIS_VCLK_POST_SCALE_3 2 +#define SIS_VCLK_POST_SCALE_4 3 + CARD8 _vclk_vco_gain : 1; + } _internal_vclk_1_s; + CARD8 _internal_vclk_1; + } _internal_vclk_1_u; /* SR2B */ + +#define internal_vclk_1 _internal_vclk_1_u._internal_vclk_1 +#define vclk_denominator _internal_vclk_1_u._internal_vclk_1_s._vclk_denominator +#define vclk_post_scale _internal_vclk_1_u._internal_vclk_1_s._vclk_post_scale +#define vclk_vco_gain _internal_vclk_1_u._internal_vclk_1_s._vclk_vco_gain + + union { + struct { + CARD8 _extended_clock_select : 2; +#define SIS_CLOCK_SELECT_INTERNAL 0 +#define SIS_CLOCK_SELECT_25MHZ 1 +#define SIS_CLOCK_SELECT_28MHZ 2 + CARD8 _disable_line_compare : 1; + CARD8 _disable_pci_read_t_o : 1; + CARD8 _cursor_start_addr_18_21: 4; + } _misc_control_7_s; + CARD8 _misc_control_7; + } _misc_control_7_u; /* SR38 */ + +#define misc_control_7 _misc_control_7_u._misc_control_7 +#define extended_clock_select _misc_control_7_u._misc_control_7_s._extended_clock_select +#define disable_line_compare _misc_control_7_u._misc_control_7_s._disable_line_compare +#define disable_pci_read_t_o _misc_control_7_u._misc_control_7_s._disable_pci_read_t_o +#define cursor_start_addr_18_21 _misc_control_7_u._misc_control_7_s._cursor_start_addr_18_21 + + union { + struct { + CARD8 _high_speed_dclk : 1; + CARD8 _sgram_block_write : 1; + CARD8 _cursor_start_addr_22 : 1; + CARD8 _dram_texture_read : 1; + CARD8 _sgram_16mb : 1; + CARD8 _agp_signal_delay : 2; + CARD8 _dclk_off : 1; + } _misc_control_11_s; + CARD8 _misc_control_11; + } _misc_control_11_u; /* SR3E */ + +#define misc_control_11 _misc_control_11_u._misc_control_11 +#define high_speed_dclk _misc_control_11_u._misc_control_11_s._high_speed_dclk +#define sgram_block_write _misc_control_11_u._misc_control_11_s.__sgram_block_write +#define cursor_start_addr_22 _misc_control_11_u._misc_control_11_s._cursor_start_addr_22 +#define dram_texture_read _misc_control_11_u._misc_control_11_s._dram_texture_read +#define sgram_16mb _misc_control_11_u._misc_control_11_s._sgram_16mb +#define agp_signal_delay _misc_control_11_u._misc_control_11_s._agp_signal_delay +#define dclk_off _misc_control_11_u._misc_control_11_s._dclk_off + + union { + struct { + CARD8 : 1; + CARD8 _flat_panel_low_enable : 1; + CARD8 _crt_cpu_threshold_low_4: 1; + CARD8 _crt_engine_threshold_high_4: 1; + CARD8 _crt_cpu_threshold_high_4 : 1; + CARD8 _crt_threshold_full_control : 2; +#define SIS_CRT_32_STAGE_THRESHOLD 0 +#define SIS_CRT_64_STAGE_THRESHOLD 1 +#define SIS_CRT_63_STAGE_THRESHOLD 2 +#define SIS_CRT_256_STAGE_THRESHOLD 3 + CARD8 _high_speed_dac_1 : 1; + } _misc_control_12_s; + CARD8 _misc_control_12; + } _misc_control_12_u; /* SR3F */ +#define misc_control_12 _misc_control_12_u._misc_control_12 +#define flat_panel_low_enable _misc_control_12_u._misc_control_12_s._flat_panel_low_enable +#define crt_cpu_threshold_low_4 _misc_control_12_u._misc_control_12_s._crt_cpu_threshold_low_4 +#define crt_engine_threshold_high_4 _misc_control_12_u._misc_control_12_s._crt_engine_threshold_high_4 +#define crt_cpu_threshold_high_4 _misc_control_12_u._misc_control_12_s._crt_cpu_threshold_high_4 +#define crt_threshold_full_control _misc_control_12_u._misc_control_12_s._crt_threshold_full_control +#define high_speed_dac_1 _misc_control_12_u._misc_control_12_s._high_speed_dac_1 + + /* computed values */ + CARD16 ge_screen_pitch; + CARD8 bits_per_pixel; + CARD8 depth; + CARD8 double_pixel_mode; + CARD16 pixel_width; +} SisCrtc; + +#define crtc_v_total(crtc) ((crtc)->v_total_0_7 | \ + ((crtc)->v_total_8 << 8) | \ + ((crtc)->v_total_9 << 9) | \ + ((crtc)->v_total_10 << 10)) + +#define crtc_set_v_total(crtc,v) { \ + ((crtc))->v_total_0_7 = (v); \ + ((crtc))->v_total_8 = (v) >> 8; \ + ((crtc))->v_total_9 = (v) >> 9; \ + ((crtc))->v_total_10 = (v) >> 10; \ +} + +#define crtc_v_display_end(crtc) ((crtc)->v_display_end_0_7 | \ + ((crtc)->v_display_end_8 << 8) | \ + ((crtc)->v_display_end_9 << 9) | \ + ((crtc)->v_display_end_10 << 10)) + +#define crtc_set_v_display_end(crtc,v) {\ + ((crtc))->v_display_end_0_7 = (v); \ + ((crtc))->v_display_end_8 = (v) >> 8; \ + ((crtc))->v_display_end_9 = (v) >> 9; \ + ((crtc))->v_display_end_10 = (v) >> 10; \ +} + +#define crtc_v_retrace_start(crtc) ((crtc)->v_retrace_start_0_7 | \ + ((crtc)->v_retrace_start_8 << 8) | \ + ((crtc)->v_retrace_start_9 << 9) | \ + ((crtc)->v_retrace_start_10 << 10)) + +#define crtc_set_v_retrace_start(crtc,v) {\ + ((crtc))->v_retrace_start_0_7 = (v); \ + ((crtc))->v_retrace_start_8 = (v) >> 8; \ + ((crtc))->v_retrace_start_9 = (v) >> 9; \ + ((crtc))->v_retrace_start_10 = (v) >> 10; \ +} + +#define crtc_v_blank_start(crtc) ((crtc)->v_blank_start_0_7 | \ + ((crtc)->v_blank_start_8 << 8) | \ + ((crtc)->v_blank_start_9 << 9) | \ + ((crtc)->v_blank_start_10 << 10)) + +#define crtc_set_v_blank_start(crtc,v) {\ + ((crtc))->v_blank_start_0_7 = (v); \ + ((crtc))->v_blank_start_8 = (v) >> 8; \ + ((crtc))->v_blank_start_9 = (v) >> 9; \ + ((crtc))->v_blank_start_10 = (v) >> 10; \ +} + +#define crtc_h_total(crtc) ((crtc)->h_total_0_7 | \ + ((crtc)->h_total_8 << 8)) + +#define crtc_set_h_total(crtc,v) {\ + ((crtc))->h_total_0_7 = (v); \ + ((crtc))->h_total_8 = (v) >> 8; \ +} + +#define crtc_h_display_end(crtc) ((crtc)->h_display_end_0_7 | \ + ((crtc)->h_display_end_8 << 8)) + +#define crtc_set_h_display_end(crtc,v) {\ + ((crtc))->h_display_end_0_7 = (v); \ + ((crtc))->h_display_end_8 = (v) >> 8; \ +} + +#define crtc_h_blank_start(crtc) ((crtc)->h_blank_start_0_7 | \ + ((crtc)->h_blank_start_8 << 8)) + +#define crtc_set_h_blank_start(crtc,v) {\ + ((crtc))->h_blank_start_0_7 = (v); \ + ((crtc))->h_blank_start_8 = (v) >> 8; \ +} + +#define crtc_h_blank_end(crtc) ((crtc)->h_blank_end_0_4 | \ + ((crtc)->h_blank_end_5 << 5)) + +#define crtc_set_h_blank_end(crtc,v) {\ + ((crtc))->h_blank_end_0_4 = (v); \ + ((crtc))->h_blank_end_5 = (v) >> 5; \ +} + +#define crtc_h_sync_start(crtc) ((crtc)->h_sync_start_0_7 | \ + ((crtc)->h_sync_start_8 << 8)) + +#define crtc_set_h_sync_start(crtc,v) {\ + ((crtc))->h_sync_start_0_7 = (v); \ + ((crtc))->h_sync_start_8 = (v) >> 8; \ +} + +#define crtc_h_sync_end(crtc) ((crtc)->h_sync_end_0_4) + +#define crtc_set_h_sync_end(crtc,v) {\ + ((crtc))->h_sync_end_0_4 = (v); \ +} + +#define crtc_screen_off(crtc) ((crtc)->screen_off_0_7 | \ + ((crtc)->screen_off_8_11 << 8)) + +#define crtc_set_screen_off(crtc,v) {\ + ((crtc))->screen_off_0_7 = (v); \ + ((crtc))->screen_off_8_11 = (v) >> 8; \ +} + +#define crtc_ge_screen_width(crtc) ((crtc)->ge_screen_width_0_1 | \ + ((crtc)->ge_screen_width_2 << 2)) + +#define crtc_set_ge_screen_width(crtc,v) { \ + (crtc)->ge_screen_width_0_1 = (v); \ + (crtc)->ge_screen_width_2 = (v) >> 2; \ +} + +#define crtc_h_start_fifo_fetch(crtc) ((crtc)->h_start_fifo_fetch_0_7 | \ + ((crtc)->h_start_fifo_fetch_8 << 8)) + +#define crtc_set_h_start_fifo_fetch(crtc,v) {\ + (crtc)->h_start_fifo_fetch_0_7 = (v); \ + (crtc)->h_start_fifo_fetch_8 = (v) >> 8; \ +} + +#define crtc_start_address(crtc) ((crtc)->start_address_0_7 | \ + ((crtc)->start_address_8_15 << 8) | \ + ((crtc)->start_address_16_19 << 16)) + +#define crtc_set_start_address(crtc,v) {\ + (crtc)->start_address_0_7 = (v); \ + (crtc)->start_address_8_15 = (v) >> 8; \ + (crtc)->start_address_16_19 = (v) >> 16; \ +} + +#define crtc_line_compare(crtc) ((crtc)->line_compare_0_7 | \ + ((crtc)->line_compare_8 << 8) | \ + ((crtc)->line_compare_9 << 9) | \ + ((crtc)->line_compare_10 << 10)) + +#define crtc_set_line_compare(crtc,v) { \ + ((crtc))->line_compare_0_7 = (v); \ + ((crtc))->line_compare_8 = (v) >> 8; \ + ((crtc))->line_compare_9 = (v) >> 9; \ + ((crtc))->line_compare_10 = (v) >> 10; \ +} + +#define crtc_set_cursor_start_addr(crtc,v) { \ + (crtc)->cursor_start_addr_18_21 = (v) >> 18; \ + (crtc)->cursor_start_addr_22 = (v) >> 22; \ +} + +#define _sisOutb(v,r) outb(v,r) +#define _sisInb(r) inb(r) + +#define SIS_DAC_INDEX_READ 0x47 +#define SIS_DAC_INDEX_WRITE 0x48 +#define SIS_DAC_DATA 0x49 + +#define GetCrtc(sisc,i) _sisReadIndexRegister ((sisc)->io_base+0x54,i) +#define PutCrtc(sisc,i,v) _sisWriteIndexRegister ((sisc)->io_base+0x54,i,v) + +#define GetSrtc(sisc,i) _sisReadIndexRegister ((sisc)->io_base+0x44,i) +#define PutSrtc(sisc,i,v) _sisWriteIndexRegister ((sisc)->io_base+0x44,i,v) + +#define GetArtc(sisc,i) _sisReadArtc ((sisc)->io_base+0x40,i) +#define PutArtc(sisc,i,v) _sisWriteArtc ((sisc)->io_base+0x40,i,v) + +#define GetGrtc(sisc,i) _sisReadIndexRegister ((sisc)->io_base+0x4e,i) +#define PutGrtc(sisc,i,v) _sisWriteIndexRegister ((sisc)->io_base+0x4e,i,v) + +#define _sisWaitVRetrace(sisc) + +#define LockSis(sisc) +#define UnlockSis(sisc) + +typedef struct _sisTiming { + /* label */ + int horizontal; + int vertical; + int rate; + /* horizontal timing */ + int hfp; /* front porch */ + int hbp; /* back porch */ + int hblank; /* blanking */ + /* vertical timing */ + int vfp; /* front porch */ + int vbp; /* back porch */ + int vblank; /* blanking */ +} SisTiming; + +#define SIS_TEXT_SAVE (64*1024) + +typedef struct _sisSave { + CARD8 srb; + CARD8 sr5; + SisCrtc crtc; + CARD8 text_save[SIS_TEXT_SAVE]; +} SisSave; + +typedef struct _sisCardInfo { + SisPtr sis; + int memory; + CARD8 *frameBuffer; + CARD8 *registers; + VOL32 *cpu_bitblt; + CARD32 io_base; + SisSave save; +} SisCardInfo; + +typedef struct _sisScreenInfo { + CARD8 *cursor_base; + CARD32 cursor_off; + CARD8 *expand; + CARD32 expand_off; + int expand_len; + SisCursor cursor; +} SisScreenInfo; + +#define getSisCardInfo(kd) ((SisCardInfo *) ((kd)->card->driver)) +#define sisCardInfo(kd) SisCardInfo *sisc = getSisCardInfo(kd) + +#define getSisScreenInfo(kd) ((SisScreenInfo *) ((kd)->screen->driver)) +#define sisScreenInfo(kd) SisScreenInfo *siss = getSisScreenInfo(kd) + +Bool sisCardInit (KdCardInfo *); +Bool sisScreenInit (KdScreenInfo *); +Bool sisEnable (ScreenPtr pScreen); +void sisDisable (ScreenPtr pScreen); +void sisFini (ScreenPtr pScreen); + +Bool sisCursorInit (ScreenPtr pScreen); +void sisCursorEnable (ScreenPtr pScreen); +void sisCursorDisable (ScreenPtr pScreen); +void sisCursorFini (ScreenPtr pScreen); +void sisRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs); + +Bool sisDrawInit (ScreenPtr pScreen); +void sisDrawEnable (ScreenPtr pScreen); +void sisDrawSync (ScreenPtr pScreen); +void sisDrawDisable (ScreenPtr pScreen); +void sisDrawFini (ScreenPtr pScreen); + +void sisGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); +void sisPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); + +void SISInitCard (KdCardAttr *attr); + +CARD8 _sisReadIndexRegister (CARD32 base, CARD8 index); +void _sisWriteIndexRegister (CARD32 base, CARD8 index, CARD8 value); +CARD8 _sisReadArtc (CARD32 base, CARD8 index); +void _sisWriteArtc (CARD32 base, CARD8 index, CARD8 value); + +extern KdCardFuncs sisFuncs; + +/* + * sisclock.c + */ +void +sisGetClock (unsigned long clock, SisCrtc *crtc); + +void +sisEngThresh (SisCrtc *crtc, unsigned long vclk, int bpp); + +/* + * siscurs.c + */ + +Bool +sisCursorInit (ScreenPtr pScreen); + +void +sisCursorEnable (ScreenPtr pScreen); + +void +sisCursorDisable (ScreenPtr pScreen); + +void +sisCursorFini (ScreenPtr pScreen); + +/* sisdraw.c */ +Bool +sisDrawInit (ScreenPtr pScreen); + +void +sisDrawEnable (ScreenPtr pScreen); + +void +sisDrawDisable (ScreenPtr pScreen); + +void +sisDrawFini (ScreenPtr pScreen); + +#endif /* _SIS_H_ */ --- xorg-server-1.4.99.906.orig/hw/kdrive/sis530/sisdraw.h +++ xorg-server-1.4.99.906/hw/kdrive/sis530/sisdraw.h @@ -0,0 +1,180 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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. + */ + +#ifndef _SISDRAW_H_ +#define _SISDRAW_H_ + +#define SetupSis(s) KdScreenPriv(s); \ + sisCardInfo(pScreenPriv); \ + SisPtr sis = sisc->sis + +#define SIS_CMD_BITBLT (0) +#define SIS_CMD_COLOR_EXPAND (1) +#define SIS_CMD_ENH_COLOR_EXPAND (2) +#define SIS_CMD_MULTI_SCANLINE (3) +#define SIS_CMD_LINE (4) +#define SIS_CMD_TRAPEZOID (5) +#define SIS_CMD_TRANSPARENT_BITBLT (6) + +#define SIS_CMD_SRC_SCREEN (0 << 4) +#define SIS_CMD_SRC_CPU (1 << 4) + +#define SIS_CMD_PAT_FG (0 << 6) +#define SIS_CMD_PAT_PATTERN (1 << 6) +#define SIS_CMD_PAT_MONO (2 << 6) + +/* 8->15 rop */ + +#define SIS_CMD_DEC_X (0 << 16) +#define SIS_CMD_INC_X (1 << 16) + +#define SIS_CMD_DEC_Y (0 << 17) +#define SIS_CMD_INC_Y (1 << 17) + +#define SIS_CMD_RECT_CLIP_DISABLE (0 << 18) +#define SIS_CMD_RECT_CLIP_ENABLE (1 << 18) + +#define SIS_CMD_OPAQUE (0 << 20) +#define SIS_CMD_TRANSPARENT (1 << 20) + +#define SIS_CMD_RECT_CLIP_MERGE (0 << 26) +#define SIS_CMD_RECT_CLIP_DONT_MERGE (1 << 26) + +#define SIS_STAT_2D_IDLE (1 << 31) +#define SIS_STAT_3D_IDLE (1 << 30) +#define SIS_STAT_EMPTY (1 << 29) +#define SIS_STAT_CPU_BITBLT (0xf << 24) +#define SIS_STAT_ENH_COLOR_EXPAND (1 << 23) +#define SIS_STAT_AVAIL (0x1fff) + +extern CARD8 sisPatRop[16]; +extern CARD8 sisBltRop[16]; + +#define _sisSetSolidRect(sis,pix,alu,cmd) {\ + (sis)->u.general.pattern_fg = (pix); \ + (cmd) = (SIS_CMD_BITBLT | \ + SIS_CMD_SRC_SCREEN | \ + SIS_CMD_PAT_FG | \ + (sisPatRop[alu] << 8) | \ + SIS_CMD_INC_X | \ + SIS_CMD_INC_Y | \ + SIS_CMD_RECT_CLIP_DISABLE | \ + SIS_CMD_OPAQUE | \ + SIS_CMD_RECT_CLIP_DONT_MERGE); \ +} + +#define _sisClip(sis,x1,y1,x2,y2) { \ + (sis)->u.general.clip_left = (x1); \ + (sis)->u.general.clip_top = (y1); \ + (sis)->u.general.clip_right = (x2); \ + (sis)->u.general.clip_bottom = (y2); \ +} + +#define _sisRect(sis,x,y,w,h,cmd) { \ + (sis)->u.general.dst_x = (x); \ + (sis)->u.general.dst_y = (y); \ + (sis)->u.general.rect_width = (w); \ + (sis)->u.general.rect_height = (h); \ + (sis)->u.general.command = (cmd); \ +} + +#define _sisSetTransparentPlaneBlt(sis, alu, fg, cmd) { \ + (sis)->u.general.src_fg = (fg); \ + (cmd) = (SIS_CMD_ENH_COLOR_EXPAND | \ + SIS_CMD_SRC_CPU | \ + SIS_CMD_PAT_FG | \ + (sisBltRop[alu] << 8) | \ + SIS_CMD_INC_X | \ + SIS_CMD_INC_Y | \ + SIS_CMD_RECT_CLIP_DISABLE | \ + SIS_CMD_TRANSPARENT | \ + SIS_CMD_RECT_CLIP_DONT_MERGE); \ +} + +#define _sisSetOpaquePlaneBlt(sis, alu, fg, bg, cmd) { \ + (sis)->u.general.src_fg = (fg); \ + (sis)->u.general.src_bg = (bg); \ + (cmd) = (SIS_CMD_ENH_COLOR_EXPAND | \ + SIS_CMD_SRC_CPU | \ + SIS_CMD_PAT_FG | \ + (sisBltRop[alu] << 8) | \ + SIS_CMD_INC_X | \ + SIS_CMD_INC_Y | \ + SIS_CMD_RECT_CLIP_DISABLE | \ + SIS_CMD_OPAQUE | \ + SIS_CMD_RECT_CLIP_DONT_MERGE); \ +} + +#define _sisPlaneBlt(sis,x,y,w,h,cmd) _sisSolidRect(sis,x,y,w,h,cmd) + +#define _sisSetBlt(sis,alu,cmd) { \ + (sis)->u.general.src_base = (sis)->u.general.dst_base; \ + (sis)->u.general.src_pitch = (sis)->u.general.dst_pitch; \ + (cmd) = (SIS_CMD_RECT_CLIP_DONT_MERGE |\ + (sisBltRop[alu] << 8) |\ + SIS_CMD_PAT_FG |\ + SIS_CMD_SRC_SCREEN |\ + SIS_CMD_BITBLT); \ +} + +#define _sisBlt(sis,sx,sy,dx,dy,w,h,cmd) { \ + (sis)->u.general.src_x = (sx); \ + (sis)->u.general.src_y = (sy); \ + (sis)->u.general.dst_x = (dx); \ + (sis)->u.general.dst_y = (dy); \ + (sis)->u.general.rect_width = (w); \ + (sis)->u.general.rect_height = (h); \ + (sis)->u.general.command = (cmd); \ +} + +#define SIS_IE (SIS_STAT_2D_IDLE|SIS_STAT_EMPTY) + +#define _sisWaitIdleEmpty(sis) \ + while (((sis)->u.general.status & SIS_IE) != SIS_IE) + +/* + * Ok, so the Sis530 is broken -- it expects bitmaps to come MSB bit order, + * but it's willing to take them in LSB byte order. These macros + * flip bits around without flipping bytes. Instead of using a table + * and burning memory bandwidth, do them in place with the CPU. + */ + +/* The MIPS compiler automatically places these constants in registers */ +#define SisInvertBits32(v) { \ + v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ + v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ + v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ +} + +#define SisInvertBits16(v) { \ + v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \ + v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \ + v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \ +} + +#define SisInvertBits8(v) { \ + v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \ + v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \ + v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \ +} + +#endif --- xorg-server-1.4.99.906.orig/hw/kdrive/pcmcia/pcmciastub.c +++ xorg-server-1.4.99.906/hw/kdrive/pcmcia/pcmciastub.c @@ -0,0 +1,63 @@ +/* + * Copyright 2001 by Alan Hourihane, Sychdyn, North Wales, UK. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE 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. + * + * Authors: Alan Hourihane, + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "pcmcia.h" + +void +InitCard (char *name) +{ + KdCardAttr attr; + + KdCardInfoAdd (&pcmciaFuncs, &attr, 0); +} + +void +InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) +{ + KdInitOutput (pScreenInfo, argc, argv); +} + +void +InitInput (int argc, char **argv) +{ + KdOsAddInputDrivers (); + KdInitInput (); +} + +extern pcmciaDisplayModeRec pcmciaDefaultModes[]; + +void +ddxUseMsg (void) +{ + KdUseMsg(); +} + +int +ddxProcessArgument (int argc, char **argv, int i) +{ + return KdProcessArgument (argc, argv, i); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/pcmcia/modes.h +++ xorg-server-1.4.99.906/hw/kdrive/pcmcia/modes.h @@ -0,0 +1,65 @@ +/* + * Copyright 2001 by Alan Hourihane, Sychdyn, North Wales, UK. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE 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. + * + * Authors: Alan Hourihane, + */ + +#define V_NHSYNC 0x01 +#define V_NVSYNC 0x02 +#define V_PHSYNC 0x04 +#define V_PVSYNC 0x08 +#define V_INTERLACE 0x10 + +pcmciaDisplayModeRec pcmciaDefaultModes [] = { +/* 640x400 @ 70Hz (VGA) hsync: 37.9kHz */ + {640, 400, 70 ,31500, 640,672,736,832,0, 400,401,404,445,0, V_NHSYNC | V_PVSYNC}, +/* 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz */ + {640, 480, 60 ,25200, 640,656,752,800,0, 480,490,492,525,0, V_NHSYNC | V_NVSYNC}, +/* 640x480 @ 72Hz (VESA) hsync: 37.9kHz */ + {640, 480, 72 ,31500, 640,664,704,832,0, 480,489,491,520,0, V_NHSYNC | V_NVSYNC}, +/* 640x480 @ 75Hz (VESA) hsync: 37.5kHz */ + {640, 480, 75 ,31500, 640,656,720,840,0, 480,481,484,500,0, V_NHSYNC | V_NVSYNC}, +/* 640x480 @ 85Hz (VESA) hsync: 43.3kHz */ + {640, 480, 85 ,36000, 640,696,752,832,0, 480,481,484,509,0, V_NHSYNC | V_NVSYNC}, +/* 800x600 @ 56Hz (VESA) hsync: 35.2kHz */ + {800, 600, 56 ,36000, 800,824,896,1024,0, 600,601,603,625,0, V_PHSYNC | V_PVSYNC}, +/* 800x600 @ 60Hz (VESA) hsync: 37.9kHz */ + {800, 600, 60 ,40000, 800,840,968,1056,0, 600,601,605,628,0, V_PHSYNC | V_PVSYNC}, +/* 800x600 @ 72Hz (VESA) hsync: 48.1kHz */ + {800, 600, 72 ,50000, 800,856,976,1040,0, 600,637,643,666,0, V_PHSYNC | V_PVSYNC}, +/* 800x600 @ 75Hz (VESA) hsync: 46.9kHz */ + {800, 600, 75 ,49500, 800,816,896,1056,0, 600,601,604,625,0, V_PHSYNC | V_PVSYNC}, +/* 800x600 @ 85Hz (VESA) hsync: 53.7kHz */ + {800, 600, 85 ,56300, 800,832,896,1048,0, 600,601,604,631,0, V_PHSYNC | V_PVSYNC}, +/* 1024x768i @ 43Hz (industry standard) hsync: 35.5kHz */ + {1024, 768, 43 ,44900, 1024,1032,1208,1264,0, 768,768,776,817,0, V_PHSYNC | V_PVSYNC | V_INTERLACE}, +/* 1024x768 @ 60Hz (VESA) hsync: 48.4kHz */ + {1024, 768, 60 ,65000, 1024,1048,1184,1344,0, 768,771,777,806,0, V_NHSYNC | V_NVSYNC}, +/* 1024x768 @ 70Hz (VESA) hsync: 56.5kHz */ + {1024, 768, 70 ,75000, 1024,1048,1184,1328,0, 768,771,777,806,0, V_NHSYNC | V_NVSYNC}, +/* 1024x768 @ 75Hz (VESA) hsync: 60.0kHz */ + {1024, 768, 75 ,78800, 1024,1040,1136,1312,0, 768,769,772,800,0, V_PHSYNC | V_PVSYNC}, +/* 1024x768 @ 85Hz (VESA) hsync: 68.7kHz */ + {1024, 768, 85 ,94500, 1024,1072,1168,1376,0, 768,769,772,808,0, V_PHSYNC | V_PVSYNC}, +/* 1152x864 @ 75Hz (VESA) hsync: 67.5kHz */ + {1152, 864, 75 ,108000, 1152,1216,1344,1600,0, 864,865,868,900,0, V_PHSYNC | V_PVSYNC}, + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} +}; --- xorg-server-1.4.99.906.orig/hw/kdrive/pcmcia/pcmciarotate.c +++ xorg-server-1.4.99.906/hw/kdrive/pcmcia/pcmciarotate.c @@ -0,0 +1,333 @@ +/* + * Copyright © 2001 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include +#include "scrnintstr.h" +#include "windowstr.h" +#include "font.h" +#include "dixfontstr.h" +#include "fontstruct.h" +#include "mi.h" +#include "regionstr.h" +#include "globals.h" +#include "gcstruct.h" +#include "shadow.h" +#include "fb.h" + +/* + * These indicate which way the source (shadow) is scanned when + * walking the screen in a particular direction + */ + +#define LEFT_TO_RIGHT 1 +#define RIGHT_TO_LEFT -1 +#define TOP_TO_BOTTOM 2 +#define BOTTOM_TO_TOP -2 + +typedef CARD16 PcBits; +typedef INT32 PcStride; + +#define PC_SHIFT 4 +#define PC_UNIT (1 << PC_SHIFT) +#define PC_HALFUNIT (1 << (PC_SHIFT-1)) +#define PC_MASK (PC_UNIT - 1) +#define PC_ALLONES ((PcBits) -1) + +#define PcScrRight(x,b) FbScrRight(x,b) +#define PcScrLeft(x,b) FbScrLeft(x,b) +#define PcBitsMask(x,w) (PcScrRight(PC_ALLONES,(x) & PC_MASK) & \ + PcScrLeft(PC_ALLONES,(PC_UNIT - ((x) + (w))) & PC_MASK)) + +#define pcGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \ + PixmapPtr _pPix; \ + if ((pDrawable)->type != DRAWABLE_PIXMAP) \ + _pPix = fbGetWindowPixmap(pDrawable); \ + else \ + _pPix = (PixmapPtr) (pDrawable); \ + (pointer) = (PcBits *) _pPix->devPrivate.ptr; \ + (stride) = ((int) _pPix->devKind) / sizeof (PcBits); \ + (bpp) = _pPix->drawable.bitsPerPixel; \ + (xoff) = 0; \ + (yoff) = 0; \ +} + +void +pcmciaUpdateRotatePacked (ScreenPtr pScreen, + shadowBufPtr pBuf) +{ + RegionPtr damage = &pBuf->damage; + PixmapPtr pShadow = pBuf->pPixmap; + int nbox = REGION_NUM_RECTS (damage); + BoxPtr pbox = REGION_RECTS (damage); + PcBits *shaBits; + PcStride shaStride; + int shaBpp; + int shaXoff, shaYoff; + int box_x1, box_x2, box_y1, box_y2; + int sha_x1, sha_y1; + int scr_x1, scr_x2, scr_y1, scr_y2, scr_w, scr_h; + int scr_x, scr_y; + int w; + int pixelsPerBits; + int pixelsMask; + PcStride shaStepOverY, shaStepDownY, shaStepOverX, shaStepDownX; + PcBits *shaLine, *sha; + int shaHeight = pShadow->drawable.height; + int shaWidth = pShadow->drawable.width; + PcBits shaMask; + int shaFirstShift, shaShift; + int o_x_dir; + int o_y_dir; + int x_dir; + int y_dir; + + pcGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff, shaYoff); + pixelsPerBits = (sizeof (PcBits) * 8) / shaBpp; + pixelsMask = ~(pixelsPerBits - 1); + shaMask = PcBitsMask (PC_UNIT-shaBpp, shaBpp); + /* + * Compute rotation related constants to walk the shadow + */ + o_x_dir = LEFT_TO_RIGHT; + o_y_dir = TOP_TO_BOTTOM; + if (pBuf->randr & SHADOW_REFLECT_X) + o_x_dir = -o_x_dir; + if (pBuf->randr & SHADOW_REFLECT_Y) + o_y_dir = -o_y_dir; + switch (pBuf->randr & (SHADOW_ROTATE_ALL)) { + case SHADOW_ROTATE_0: /* upper left shadow -> upper left screen */ + default: + x_dir = o_x_dir; + y_dir = o_y_dir; + break; + case SHADOW_ROTATE_90: /* upper right shadow -> upper left screen */ + x_dir = o_y_dir; + y_dir = -o_x_dir; + break; + case SHADOW_ROTATE_180: /* lower right shadow -> upper left screen */ + x_dir = -o_x_dir; + y_dir = -o_y_dir; + break; + case SHADOW_ROTATE_270: /* lower left shadow -> upper left screen */ + x_dir = -o_y_dir; + y_dir = o_x_dir; + break; + } + switch (x_dir) { + case LEFT_TO_RIGHT: + shaStepOverX = shaBpp; + shaStepOverY = 0; + break; + case TOP_TO_BOTTOM: + shaStepOverX = 0; + shaStepOverY = shaStride; + break; + case RIGHT_TO_LEFT: + shaStepOverX = -shaBpp; + shaStepOverY = 0; + break; + case BOTTOM_TO_TOP: + shaStepOverX = 0; + shaStepOverY = -shaStride; + break; + } + switch (y_dir) { + case TOP_TO_BOTTOM: + shaStepDownX = 0; + shaStepDownY = shaStride; + break; + case RIGHT_TO_LEFT: + shaStepDownX = -shaBpp; + shaStepDownY = 0; + break; + case BOTTOM_TO_TOP: + shaStepDownX = 0; + shaStepDownY = -shaStride; + break; + case LEFT_TO_RIGHT: + shaStepDownX = shaBpp; + shaStepDownY = 0; + break; + } + + while (nbox--) + { + box_x1 = pbox->x1; + box_y1 = pbox->y1; + box_x2 = pbox->x2; + box_y2 = pbox->y2; + pbox++; + + /* + * Compute screen and shadow locations for this box + */ + switch (x_dir) { + case LEFT_TO_RIGHT: + scr_x1 = box_x1 & pixelsMask; + scr_x2 = (box_x2 + pixelsPerBits - 1) & pixelsMask; + + sha_x1 = scr_x1; + break; + case TOP_TO_BOTTOM: + scr_x1 = box_y1 & pixelsMask; + scr_x2 = (box_y2 + pixelsPerBits - 1) & pixelsMask; + + sha_y1 = scr_x1; + break; + case RIGHT_TO_LEFT: + scr_x1 = (shaWidth - box_x2) & pixelsMask; + scr_x2 = (shaWidth - box_x1 + pixelsPerBits - 1) & pixelsMask; + + sha_x1 = (shaWidth - scr_x1 - 1); + break; + case BOTTOM_TO_TOP: + scr_x1 = (shaHeight - box_y2) & pixelsMask; + scr_x2 = (shaHeight - box_y1 + pixelsPerBits - 1) & pixelsMask; + + sha_y1 = (shaHeight - scr_x1 - 1); + break; + } + switch (y_dir) { + case TOP_TO_BOTTOM: + scr_y1 = box_y1; + scr_y2 = box_y2; + + sha_y1 = scr_y1; + break; + case RIGHT_TO_LEFT: + scr_y1 = (shaWidth - box_x2); + scr_y2 = (shaWidth - box_x1); + + sha_x1 = box_x2 - 1; + break; + case BOTTOM_TO_TOP: + scr_y1 = shaHeight - box_y2; + scr_y2 = shaHeight - box_y1; + + sha_y1 = box_y2 - 1; + break; + case LEFT_TO_RIGHT: + scr_y1 = box_x1; + scr_y2 = box_x2; + + sha_x1 = box_x1; + break; + } + scr_w = ((scr_x2 - scr_x1) * shaBpp) >> PC_SHIFT; + scr_h = scr_y2 - scr_y1; + scr_y = scr_y1; + + /* shift amount for first pixel on screen */ + shaFirstShift = PC_UNIT - ((sha_x1 * shaBpp) & PC_MASK) - shaBpp; + + /* pointer to shadow data first placed on screen */ + shaLine = (shaBits + + sha_y1 * shaStride + + ((sha_x1 * shaBpp) >> PC_SHIFT)); + + /* + * Copy the bits, always write across the physical frame buffer + * to take advantage of write combining. + */ + while (scr_h--) + { + int p; + PcBits bits; + PcBits *win; + int i; + CARD32 winSize; + + sha = shaLine; + shaShift = shaFirstShift; + w = scr_w; + scr_x = scr_x1 * shaBpp >> PC_SHIFT; + + while (w) + { + /* + * Map some of this line + */ + win = (PcBits *) (*pBuf->window) (pScreen, + scr_y, + scr_x << 1, + SHADOW_WINDOW_WRITE, + &winSize, + pBuf->closure); + i = (winSize >> 1); + if (i > w) + i = w; + w -= i; + scr_x += i; + /* + * Copy the portion of the line mapped + */ + while (i--) + { + bits = 0; + p = pixelsPerBits; + /* + * Build one word of output from multiple inputs + * + * Note that for 90/270 rotations, this will walk + * down the shadow hitting each scanline once. + * This is probably not very efficient. + */ + while (p--) + { + bits = PcScrLeft(bits, shaBpp); + bits |= PcScrRight (*sha, shaShift) & shaMask; + + shaShift -= shaStepOverX; + if (shaShift >= PC_UNIT) + { + shaShift -= PC_UNIT; + sha--; + } + else if (shaShift < 0) + { + shaShift += PC_UNIT; + sha++; + } + sha += shaStepOverY; + } + *win++ = bits; + } + } + scr_y++; + shaFirstShift -= shaStepDownX; + if (shaFirstShift >= PC_UNIT) + { + shaFirstShift -= PC_UNIT; + shaLine--; + } + else if (shaFirstShift < 0) + { + shaFirstShift += PC_UNIT; + shaLine++; + } + shaLine += shaStepDownY; + } + } +} --- xorg-server-1.4.99.906.orig/hw/kdrive/pcmcia/pcmcia.c +++ xorg-server-1.4.99.906/hw/kdrive/pcmcia/pcmcia.c @@ -0,0 +1,1199 @@ +/* + * Copyright 2001 by Alan Hourihane, Sychdyn, North Wales, UK. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE 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. + * + * Authors: Alan Hourihane, + * + * A driver for the following PCMCIA cards... + * Hewlett Packards HP VGA Out (Model F1252A) + * Colorgraphics Voyager VGA + * + * Tested running under a Compaq IPAQ Pocket PC running Linux + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "pcmcia.h" +#define extern +#include +#undef extern + +#define CLOCK 14318 /* KHz */ +#define CLK_N(a,b) (a & 0xff) +#define CLK_M(a,b) ((b) & 0x3f) +#define CLK_K(a,b) (((b) >> 6) & 3) +#define CLK_FREQ(a,b) (((CLK_N(a,b) + 8) * CLOCK) / ((CLK_M(a,b)+2) << CLK_K(a,b))) + +extern void +tridentUpdatePacked (ScreenPtr pScreen, + shadowBufPtr pBuf); +extern void +cirrusUpdatePacked (ScreenPtr pScreen, + shadowBufPtr pBuf); + +static Bool +tridentSetCLK(int clock, CARD8 *a, CARD8 *b); + +static Bool +CirrusFindClock(int freq, int *num_out, int *den_out); + +Bool +pcmciaCardInit (KdCardInfo *card) +{ + pcmciaCardInfo *pcmciac; + CARD8 r9; + + pcmciac = (pcmciaCardInfo *) xalloc (sizeof (pcmciaCardInfo)); + if (!pcmciac) + return FALSE; + + pcmciac->cop_base = (CARD8 *) KdMapDevice (PCMCIA_COP_BASE(card), + PCMCIA_COP_SIZE(card)); + + r9 = pcmciaReadIndex (pcmciac, 0x3c4, 0x09); + /* + * Crude detection.... + * The trident chip has a read only register at 0x09, which returns 0x4. + * If it's not that, we assume the cirrus chip. + * BREAKAGE.! If we have an anonymous PCMCIA card inserted, we could + * potentially smash something here. FIXME ! + */ + if (r9 == 0x04) { + ErrorF("PCMCIA: Found HP VGA card\n"); + pcmciac->HP = TRUE; /* Select HP VGA Out Card */ + } else { + ErrorF("PCMCIA: Found Voyager VGA card\n"); + pcmciac->HP = FALSE; /* Select Voyager VGA Card */ + } + + if (pcmciac->HP) { + /* needed by the accelerator - later */ + pcmciac->cop = (Cop *) (pcmciac->cop_base + TRIDENT_COP_OFF(card)); + } + + /* + * Map frame buffer + */ + if (pcmciac->HP) + pcmciac->fb = KdMapDevice (0x2ce00000, 0x80000); + else + pcmciac->fb = KdMapDevice (0x2c0a0000, 0x10000); /*64K bank switched*/ + + if (!pcmciac->fb) + return FALSE; + + pcmciac->window = 0; + + card->driver = pcmciac; + + return TRUE; +} + +Bool +pcmciaModeSupported (KdScreenInfo *screen, + const KdMonitorTiming *t) +{ + KdCardInfo *card = screen->card; + pcmciaCardInfo *pcmciac = (pcmciaCardInfo *) card->driver; + + if (pcmciac->HP) + { + CARD8 a, b; + if (!tridentSetCLK (t->clock, &a, &b)) + return FALSE; + } + else + { + int a, b; + if (!CirrusFindClock (t->clock, &a, &b)) + return FALSE; + } + + /* width must be a multiple of 16 */ + if (t->horizontal & 0xf) + return FALSE; + return TRUE; +} + +Bool +pcmciaModeUsable (KdScreenInfo *screen) +{ + KdCardInfo *card = screen->card; + pcmciaCardInfo *pcmciac = (pcmciaCardInfo *) card->driver; + int screen_size; + int pixel_width; + int byte_width; + int fb; + + if (screen->fb[0].depth == 8) + screen->fb[0].bitsPerPixel = 8; + else if (screen->fb[0].depth == 15 || screen->fb[0].depth == 16) + screen->fb[0].bitsPerPixel = 16; + else + return FALSE; + + screen_size = 0; + screen->fb[0].pixelStride = screen->width; + screen->fb[0].byteStride = screen->width * (screen->fb[0].bitsPerPixel >>3); + screen->fb[0].frameBuffer = pcmciac->fb; + screen_size = screen->fb[0].byteStride * screen->height; + + return screen_size <= pcmciac->memory; +} + +Bool +pcmciaScreenInit (KdScreenInfo *screen) +{ + pcmciaCardInfo *pcmciac = screen->card->driver; + pcmciaScreenInfo *pcmcias; + int screen_size, memory; + int i; + const KdMonitorTiming *t; + + pcmcias = (pcmciaScreenInfo *) xalloc (sizeof (pcmciaScreenInfo)); + if (!pcmcias) + return FALSE; + memset (pcmcias, '\0', sizeof (pcmciaScreenInfo)); + + /* if (!pcmciac->cop) */ + screen->dumb = TRUE; + + if (screen->fb[0].depth < 8) + screen->fb[0].depth = 8; + + /* default to 16bpp */ + if (!screen->fb[0].depth) + screen->fb[0].depth = 16; + + /* default to 60Hz refresh */ + if (!screen->width || !screen->height) + { + screen->width = 640; + screen->height = 400; + screen->rate = 60; + } + + pcmciac->memory = 512 * 1024; + if (pcmciac->HP && !screen->softCursor && screen->fb[0].depth == 8) + { + /* ack, bail on the HW cursor for everything -- no ARGB falback */ + pcmcias->cursor_base = 0; +#if 0 + /* Let's do hw cursor for the HP card, only in 8bit mode though */ + pcmcias->cursor_base = pcmcias->screen + pcmciac->memory - 4096; + pcmciac->memory -= 4096; +#endif + } + + pcmcias->screen = pcmciac->fb; + screen->driver = pcmcias; + + t = KdFindMode (screen, pcmciaModeSupported); + + screen->rate = t->rate; + screen->width = t->horizontal; + screen->height = t->vertical; + + pcmcias->randr = screen->randr; + + if (!KdTuneMode (screen, pcmciaModeUsable, pcmciaModeSupported)) + { + xfree (pcmcias); + return FALSE; + } + + switch (screen->fb[0].depth) { + case 4: + screen->fb[0].visuals = ((1 << StaticGray) | + (1 << GrayScale) | + (1 << StaticColor)); + screen->fb[0].blueMask = 0x00; + screen->fb[0].greenMask = 0x00; + screen->fb[0].redMask = 0x00; + break; + case 8: + screen->fb[0].visuals = ((1 << StaticGray) | + (1 << GrayScale) | + (1 << StaticColor) | + (1 << PseudoColor) | + (1 << TrueColor) | + (1 << DirectColor)); + screen->fb[0].blueMask = 0x00; + screen->fb[0].greenMask = 0x00; + screen->fb[0].redMask = 0x00; + break; + case 15: + screen->fb[0].visuals = (1 << TrueColor); + screen->fb[0].blueMask = 0x001f; + screen->fb[0].greenMask = 0x03e0; + screen->fb[0].redMask = 0x7c00; + break; + case 16: + screen->fb[0].visuals = (1 << TrueColor); + screen->fb[0].blueMask = 0x001f; + screen->fb[0].greenMask = 0x07e0; + screen->fb[0].redMask = 0xf800; + break; + } + + return TRUE; +} + +void * +tridentWindowLinear (ScreenPtr pScreen, + CARD32 row, + CARD32 offset, + int mode, + CARD32 *size, + void *closure) +{ + KdScreenPriv(pScreen); + pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; + + if (!pScreenPriv->enabled) + return 0; + + *size = pScreenPriv->screen->fb[0].byteStride; + return (CARD8 *) pcmciac->fb + row * pScreenPriv->screen->fb[0].byteStride + offset; +} + +void * +cirrusWindowWindowed (ScreenPtr pScreen, + CARD32 row, + CARD32 offset, + int mode, + CARD32 *size, + void *closure) +{ + KdScreenPriv(pScreen); + pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; + int bank, boffset; + + if (!pScreenPriv->enabled) + return 0; + + bank = (row * pScreenPriv->screen->fb[0].byteStride) / 0x1000; + pcmciaWriteIndex(pcmciac, 0x3ce, 0x0B, 0x0c); + pcmciaWriteIndex(pcmciac, 0x3ce, 0x09, bank); + pcmciaWriteIndex(pcmciac, 0x3ce, 0x0A, bank); + *size = pScreenPriv->screen->fb[0].byteStride; + return (CARD8 *) pcmciac->fb + (row * pScreenPriv->screen->fb[0].byteStride) - (bank * 0x1000) + offset; +} + +LayerPtr +pcmciaLayerCreate (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; + pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) pScreenPriv->screen->driver; + ShadowUpdateProc update; + ShadowWindowProc window; + PixmapPtr pPixmap; + int kind; + + if (pcmciac->HP) { + window = tridentWindowLinear; + if (pcmcias->randr == RR_Rotate_0) + update = tridentUpdatePacked; + else + update = pcmciaUpdateRotatePacked; + } else { + window = cirrusWindowWindowed; + if (pcmcias->randr == RR_Rotate_0) + update = cirrusUpdatePacked; + else + update = pcmciaUpdateRotatePacked; + } + + if (!update) + abort (); + + kind = LAYER_SHADOW; + pPixmap = 0; + + return LayerCreate (pScreen, kind, screen->fb[0].depth, + pPixmap, update, window, pcmcias->randr, 0); +} + +void +pcmciaConfigureScreen (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + FbdevPriv *priv = pScreenPriv->card->driver; + pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) screen->driver; + KdMouseMatrix m; + + KdComputeMouseMatrix (&m, pcmcias->randr, + screen->width, screen->height); + + if (m.matrix[0][0]) + { + pScreen->width = screen->width; + pScreen->height = screen->height; + pScreen->mmWidth = screen->width_mm; + pScreen->mmHeight = screen->height_mm; + } + else + { + pScreen->width = screen->height; + pScreen->height = screen->width; + pScreen->mmWidth = screen->height_mm; + pScreen->mmHeight = screen->width_mm; + } + KdSetMouseMatrix (&m); +} + +#ifdef RANDR + +Bool +pcmciaRandRSupported (ScreenPtr pScreen, + const KdMonitorTiming *t) +{ + KdScreenPriv(pScreen); + pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; + KdScreenInfo *screen = pScreenPriv->screen; + int screen_size; + int byteStride; + + /* Make sure the clock is supported */ + if (!pcmciaModeSupported (screen, t)) + return FALSE; + /* Check for sufficient memory */ + byteStride = screen->width * (screen->fb[0].bitsPerPixel >>3); + screen_size = byteStride * screen->height; + + return screen_size <= pcmciac->memory; +} + +Bool +pcmciaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) +{ + KdScreenPriv(pScreen); + pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) pScreenPriv->screen->driver; + + *rotations = (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270| + RR_Reflect_X|RR_Reflect_Y); + + return KdRandRGetInfo (pScreen, pcmcias->randr, pcmciaRandRSupported); +} + +int +pcmciaLayerAdd (WindowPtr pWin, pointer value) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + LayerPtr pLayer = (LayerPtr) value; + + if (!LayerWindowAdd (pScreen, pLayer, pWin)) + return WT_STOPWALKING; + + return WT_WALKCHILDREN; +} + +int +pcmciaLayerRemove (WindowPtr pWin, pointer value) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + LayerPtr pLayer = (LayerPtr) value; + + LayerWindowRemove (pScreen, pLayer, pWin); + + return WT_WALKCHILDREN; +} + +pcmciaRandRSetConfig (ScreenPtr pScreen, + Rotation randr, + int rate, + RRScreenSizePtr pSize) +{ + KdScreenPriv(pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + FbdevPriv *priv = pScreenPriv->card->driver; + pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) pScreenPriv->screen->driver; + Bool wasEnabled = pScreenPriv->enabled; + int newwidth, newheight; + LayerPtr pNewLayer; + int kind; + int oldrandr = pcmcias->randr; + PixmapPtr pPixmap; + const KdMonitorTiming *t; + + randr = KdAddRotation (screen->randr, randr); + + t = KdRandRGetTiming (pScreen, pcmciaRandRSupported, rate, pSize); + + if (wasEnabled) + KdDisableScreen (pScreen); + + screen->rate = t->rate; + screen->width = t->horizontal; + screen->height = t->vertical; + + pcmcias->randr = randr; + pcmciaConfigureScreen (pScreen); + + pNewLayer = pcmciaLayerCreate (pScreen); + + if (!pNewLayer) + { + pcmcias->randr = oldrandr; + pcmciaConfigureScreen (pScreen); + if (wasEnabled) + KdEnableScreen (pScreen); + return FALSE; + } + + if (WalkTree (pScreen, pcmciaLayerAdd, (pointer) pNewLayer) == WT_STOPWALKING) + { + WalkTree (pScreen, pcmciaLayerRemove, (pointer) pNewLayer); + LayerDestroy (pScreen, pNewLayer); + pcmcias->randr = oldrandr; + pcmciaConfigureScreen (pScreen); + if (wasEnabled) + KdEnableScreen (pScreen); + return FALSE; + } + WalkTree (pScreen, pcmciaLayerRemove, (pointer) pcmcias->pLayer); + LayerDestroy (pScreen, pcmcias->pLayer); + pcmcias->pLayer = pNewLayer; + if (wasEnabled) + KdEnableScreen (pScreen); + return TRUE; +} + +Bool +pcmciaRandRInit (ScreenPtr pScreen) +{ + rrScrPrivPtr pScrPriv; + + if (!RRScreenInit (pScreen)) + return FALSE; + + pScrPriv = rrGetScrPriv(pScreen); + pScrPriv->rrGetInfo = pcmciaRandRGetInfo; + pScrPriv->rrSetConfig = pcmciaRandRSetConfig; + return TRUE; +} +#endif + +Bool +pcmciaInitScreen (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + FbdevPriv *priv = pScreenPriv->card->driver; + pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) pScreenPriv->screen->driver; + + if (!LayerStartInit (pScreen)) + return FALSE; + if (!LayerFinishInit (pScreen)) + return FALSE; + + pcmciaConfigureScreen (pScreen); + + pcmcias->pLayer = pcmciaLayerCreate (pScreen); + if (!pcmcias->pLayer) + return FALSE; +#ifdef RANDR + if (!pcmciaRandRInit (pScreen)) + return FALSE; +#endif + return TRUE; +} + +CARD8 +pcmciaReadIndex (pcmciaCardInfo *pcmciac, CARD16 port, CARD8 index) +{ + CARD8 value; + + pcmciac->cop_base[port] = index; + value = pcmciac->cop_base[port+1]; + return value; +} + +void +pcmciaWriteIndex (pcmciaCardInfo *pcmciac, CARD16 port, CARD8 index, CARD8 value) +{ + pcmciac->cop_base[port] = index; + pcmciac->cop_base[port+1] = value; +} + +CARD8 +pcmciaReadReg (pcmciaCardInfo *pcmciac, CARD16 port) +{ + CARD8 value; + + value = pcmciac->cop_base[port]; + + return value; +} + +void +pcmciaWriteReg (pcmciaCardInfo *pcmciac, CARD16 port, CARD8 value) +{ + pcmciac->cop_base[port] = value; +} + + +void +pcmciaPause () +{ + struct timeval tv; + + tv.tv_sec = 0; + tv.tv_usec = 50 * 1000; + select (1, 0, 0, 0, &tv); +} + +void +pcmciaPreserve (KdCardInfo *card) +{ +} + +/* CLOCK_FACTOR is double the osc freq in kHz (osc = 14.31818 MHz) */ +#define CLOCK_FACTOR 28636 + +/* stability constraints for internal VCO -- MAX_VCO also determines the maximum Video pixel clock */ +#define MIN_VCO CLOCK_FACTOR +#define MAX_VCO 111000 + +/* clock in kHz is (numer * CLOCK_FACTOR / (denom & 0x3E)) >> (denom & 1) */ +#define VCOVAL(n, d) \ + ((((n) & 0x7F) * CLOCK_FACTOR / ((d) & 0x3E)) ) + +#define CLOCKVAL(n, d) \ + (VCOVAL(n, d) >> ((d) & 1)) + +static Bool +CirrusFindClock(int freq, int *num_out, int *den_out) +{ + int n; + int num = 0, den = 0; + int mindiff; + + /* + * If max_clock is greater than the MAX_VCO default, ignore + * MAX_VCO. On the other hand, if MAX_VCO is higher than max_clock, + * make use of the higher MAX_VCO value. + */ + + mindiff = freq; + for (n = 0x10; n < 0x7f; n++) { + int d; + for (d = 0x14; d < 0x3f; d++) { + int c, diff; + /* Avoid combinations that can be unstable. */ + if ((VCOVAL(n, d) < MIN_VCO) || (VCOVAL(n, d) > MAX_VCO)) + continue; + c = CLOCKVAL(n, d); + diff = abs(c - freq); + if (diff < mindiff) { + mindiff = diff; + num = n; + den = d; + } + } + } + if (n == 0x80) + return FALSE; + + *num_out = num; + *den_out = den; + + return TRUE; +} + + +static Bool +tridentSetCLK(int clock, CARD8 *a, CARD8 *b) +{ + int powerup[4] = { 1,2,4,8 }; + int clock_diff = 750; + int freq, ffreq; + int m, n, k; + int p, q, r, s; + int startn, endn; + int endm, endk; + + p = q = r = s = 0; + + startn = 0; + endn = 121; + endm = 31; + endk = 1; + + freq = clock; + + for (k=0;k<=endk;k++) + for (n=startn;n<=endn;n++) + for (m=1;m<=endm;m++) + { + ffreq = ( ( ((n + 8) * CLOCK) / ((m + 2) * powerup[k]) )); + if ((ffreq > freq - clock_diff) && (ffreq < freq + clock_diff)) + { + clock_diff = (freq > ffreq) ? freq - ffreq : ffreq - freq; + p = n; q = m; r = k; s = ffreq; + } + } + +#if 0 + ErrorF ("ffreq %d clock %d\n", s, clock); +#endif + if (s == 0) + return FALSE; + + /* N is first 7bits, first M bit is 8th bit */ + *a = ((1 & q) << 7) | p; + /* first 4bits are rest of M, 1bit for K value */ + *b = (((q & 0xFE) >> 1) | (r << 4)); + return TRUE; +} + +Bool +pcmciaEnable (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; + pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) screen->driver; + int i,j; + unsigned char Sequencer[6]; + unsigned char CRTC[31]; + unsigned char Graphics[9]; + unsigned char Attribute[21]; + unsigned char MiscOutReg; + const KdMonitorTiming *t; + int hactive, hblank, hfp, hbp; + int vactive, vblank, vfp, vbp; + + int h_active; + int h_total; + int h_display_end; + int h_sync_start; + int h_sync_end; + int h_skew = 0; + + int v_active; + int v_total; + int v_sync_start; + int v_sync_end; + int v_skew = 0; + + t = KdFindMode (screen, pcmciaModeSupported); + + hactive = t->horizontal; + hfp = t->hfp; + hbp = t->hbp; + hblank = t->hblank; + + h_active = hactive; + h_sync_start = hactive + hfp; + h_sync_end = hactive + hblank - hbp; + h_total = hactive + hblank; + + vactive = t->vertical; + vfp = t->vfp; + vbp = t->vbp; + vblank = t->vblank; + + v_active = vactive; + v_sync_start = vactive + vfp; + v_sync_end = vactive + vblank - vbp; + v_total = vactive + vblank; + + /* + * compute correct Hsync & Vsync polarity + */ + + MiscOutReg = 0x23; + if (t->hpol == KdSyncNegative) + MiscOutReg |= 0x40; + if (t->vpol == KdSyncNegative) + MiscOutReg |= 0x80; + + /* + * Time Sequencer + */ + if (pScreenPriv->screen->fb[0].depth == 4) + Sequencer[0] = 0x02; + else + Sequencer[0] = 0x00; + Sequencer[1] = 0x01; + Sequencer[2] = 0x0F; + Sequencer[3] = 0x00; /* Font select */ + if (pScreenPriv->screen->fb[0].depth < 8) + Sequencer[4] = 0x06; /* Misc */ + else + Sequencer[4] = 0x0E; /* Misc */ + Sequencer[5] = 0x00; + + /* + * CRTC Controller + */ + CRTC[0] = ((h_total) >> 3) - 5; + CRTC[1] = (hactive >> 3) - 1; + CRTC[2] = ((min(h_sync_start,h_active)) >> 3) - 1; + CRTC[3] = ((((min(h_sync_end,h_total)) >> 3) - 1) & 0x1F) | 0x80; + i = (((h_skew << 2) + 0x10) & ~0x1F); + if (i < 0x80) + CRTC[3] |= i; + CRTC[4] = (h_sync_start >> 3); + CRTC[5] = (((((min(h_sync_end,h_total)) >> 3) - 1) & 0x20) << 2) + | (((h_sync_end >> 3)) & 0x1F); + + CRTC[6] = (v_total - 2) & 0xFF; + CRTC[7] = (((v_total - 2) & 0x100) >> 8) + | (((v_active - 1) & 0x100) >> 7) + | ((v_sync_start & 0x100) >> 6) + | ((((min(v_sync_start,v_active)) - 1) & 0x100) >> 5) + | 0x10 + | (((v_total - 2) & 0x200) >> 4) + | (((v_active - 1) & 0x200) >> 3) + | ((v_sync_start & 0x200) >> 2); + CRTC[8] = 0x00; + CRTC[9] = ((((min(v_sync_start,v_active))-1) & 0x200) >> 4) | 0x40; + CRTC[10] = 0x00; + CRTC[11] = 0x00; + CRTC[12] = 0x00; + CRTC[13] = 0x00; + CRTC[14] = 0x00; + CRTC[15] = 0x00; + CRTC[16] = v_sync_start & 0xFF; + CRTC[17] = (v_sync_end & 0x0F) | 0x20; + CRTC[18] = (v_active - 1) & 0xFF; + if (pScreenPriv->screen->fb[0].depth == 4) + CRTC[19] = pScreenPriv->screen->fb[0].pixelStride >> 4; + else + if (pScreenPriv->screen->fb[0].depth == 8) + CRTC[19] = pScreenPriv->screen->fb[0].pixelStride >> 3; + else + if (pScreenPriv->screen->fb[0].depth == 16 || + pScreenPriv->screen->fb[0].depth == 15) + CRTC[19] = pScreenPriv->screen->fb[0].pixelStride >> 2; + CRTC[20] = 0x00; + CRTC[21] = ((min(v_sync_end,v_active)) - 1) & 0xFF; + CRTC[22] = ((min(v_sync_end,v_active)) - 1) & 0xFF; + if (pScreenPriv->screen->fb[0].depth < 8) + CRTC[23] = 0xE3; + else + CRTC[23] = 0xC3; + CRTC[24] = 0xFF; + CRTC[25] = 0x00; + CRTC[26] = 0x00; +#if 0 + if (!pcmciac->HP) + if (mode.Flags & V_INTERLACE) CRTC[26] |= 0x01; +#endif + if (pcmciac->HP) + CRTC[27] = 0x00; + else + CRTC[27] = 0x22; + CRTC[28] = 0x00; + CRTC[29] = 0x00; + CRTC[30] = 0x80; +#if 0 + if (pcmciac->HP) + if (mode.Flags & V_INTERLACE) CRTC[30] |= 0x04; +#endif + +{ + int nExtBits = 0; + CARD32 ExtBits; + CARD32 ExtBitMask = ((1 << nExtBits) - 1) << 6; + + CRTC[3] = (CRTC[3] & ~0x1F) + | ((((min(h_sync_end,h_total)) >> 3) - 1) & 0x1F); + CRTC[5] = (CRTC[5] & ~0x80) + | (((((min(h_sync_end,h_total)) >> 3) - 1) & 0x20) << 2); + ExtBits = (((min(h_sync_end,h_total)) >> 3) - 1) & ExtBitMask; + + /* First the horizontal case */ + if ((((min(h_sync_end,h_total)) >> 3) == (h_total >> 3))) + { + int i = (CRTC[3] & 0x1F) + | ((CRTC[5] & 0x80) >> 2) + | ExtBits; + if ((i-- > ((((min(h_sync_start,h_active)) >> 3) - 1) + & (0x3F | ExtBitMask))) + && ((min(h_sync_end,h_total)) == h_total)) + i = 0; + CRTC[3] = (CRTC[3] & ~0x1F) | (i & 0x1F); + CRTC[5] = (CRTC[5] & ~0x80) | ((i << 2) & 0x80); + ExtBits = i & ExtBitMask; + } +} +{ + CARD32 ExtBits; + CARD32 ExtBitMask = 0; + /* If width is not known nBits should be 0. In this + * case BitMask is set to 0 so we can check for it. */ + CARD32 BitMask = 0; + int VBlankStart = ((min(v_sync_start,v_active)) - 1) & 0xFF; + CRTC[22] = ((min(v_sync_end,v_total)) - 1) & 0xFF; + ExtBits = ((min(v_sync_end,v_total)) - 1) & ExtBitMask; + + if ((min(v_sync_end,v_total)) == v_total) + /* Null top overscan */ + { + int i = CRTC[22] | ExtBits; + if (((BitMask && ((i & BitMask) > (VBlankStart & BitMask))) + || ((i > VBlankStart) && /* 8-bit case */ + ((i & 0x7F) > (VBlankStart & 0x7F)))) && /* 7-bit case */ + !(CRTC[9] & 0x9F)) /* 1 scanline/row */ + i = 0; + else + i = (i - 1); + CRTC[22] = i & 0xFF; + ExtBits = i & 0xFF00; + } +} + + /* + * Graphics Display Controller + */ + Graphics[0] = 0x00; + Graphics[1] = 0x00; + Graphics[2] = 0x00; + Graphics[3] = 0x00; + Graphics[4] = 0x00; + if (pScreenPriv->screen->fb[0].depth == 4) + Graphics[5] = 0x02; + else + Graphics[5] = 0x40; + Graphics[6] = 0x05; /* only map 64k VGA memory !!!! */ + Graphics[7] = 0x0F; + Graphics[8] = 0xFF; + + Attribute[0] = 0x00; /* standard colormap translation */ + Attribute[1] = 0x01; + Attribute[2] = 0x02; + Attribute[3] = 0x03; + Attribute[4] = 0x04; + Attribute[5] = 0x05; + Attribute[6] = 0x06; + Attribute[7] = 0x07; + Attribute[8] = 0x08; + Attribute[9] = 0x09; + Attribute[10] = 0x0A; + Attribute[11] = 0x0B; + Attribute[12] = 0x0C; + Attribute[13] = 0x0D; + Attribute[14] = 0x0E; + Attribute[15] = 0x0F; + if (pScreenPriv->screen->fb[0].depth == 4) + Attribute[16] = 0x81; + else + Attribute[16] = 0x41; + if (pScreenPriv->screen->fb[0].bitsPerPixel == 16) + Attribute[17] = 0x00; + else + Attribute[17] = 0xFF; + Attribute[18] = 0x0F; + Attribute[19] = 0x00; + Attribute[20] = 0x00; + + /* Wake up the card */ + if (pcmciac->HP) { + pcmciaWriteReg(pcmciac, 0x3c3, 0x1); + pcmciaWriteReg(pcmciac, 0x46e8, 0x10); + } else { + pcmciaWriteReg(pcmciac, 0x105, 0x1); + pcmciaWriteReg(pcmciac, 0x46e8, 0x1f); + pcmciaWriteReg(pcmciac, 0x102, 0x1); + pcmciaWriteReg(pcmciac, 0x46e8, 0xf); + pcmciaWriteReg(pcmciac, 0x3c3, 0x1); + } + + if (pcmciac->HP) { + /* unlock */ + pcmciaWriteIndex(pcmciac, 0x3c4, 0x11, 0x92); + j = pcmciaReadIndex(pcmciac, 0x3c4, 0xb); + pcmciaWriteIndex(pcmciac, 0x3c4, 0xe, 0xc2); + + /* switch on dac */ + pcmciaWriteIndex(pcmciac, 0x3d4, 0x29, 0x24); + /* switch on the accelerator */ + pcmciaWriteIndex(pcmciac, 0x3d4, 0x36, 0x80); + + /* bump up memory clk */ + pcmciaWriteReg(pcmciac, 0x43c6, 0x65); + pcmciaWriteReg(pcmciac, 0x43c7, 0x00); + } else { + /* unlock */ + pcmciaWriteIndex(pcmciac, 0x3c4, 0x06, 0x12); + pcmciaWriteReg(pcmciac, 0x3c2, MiscOutReg); + } + + /* synchronous reset */ + pcmciaWriteIndex(pcmciac, 0x3c4, 0, 0); + + pcmciaWriteReg(pcmciac, 0x3da, 0x10); + + for (i=0;i<6;i++) + pcmciaWriteIndex(pcmciac, 0x3c4, i, Sequencer[i]); + + if (pcmciac->HP) { + /* Stick chip into color mode */ + pcmciaWriteIndex(pcmciac, 0x3ce, 0x2f, 0x06); + /* Switch on Linear addressing */ + pcmciaWriteIndex(pcmciac, 0x3d4, 0x21, 0x2e); + } else { + /* Stick chip into 8bit access mode - ugh! */ + pcmciaWriteIndex(pcmciac, 0x3c4, 0x0F, 0x20); /* 0x26 ? */ + /* reset mclk */ + pcmciaWriteIndex(pcmciac, 0x3c4, 0x1F, 0); + } + + pcmciaWriteIndex(pcmciac, 0x3c4, 0, 0x3); + + for (i=0;i<31;i++) + pcmciaWriteIndex(pcmciac, 0x3d4, i, CRTC[i]); + + for (i=0;i<9;i++) + pcmciaWriteIndex(pcmciac, 0x3ce, i, Graphics[i]); + + j = pcmciaReadReg(pcmciac, 0x3da); + + for (i=0;i<21;i++) { + pcmciaWriteReg(pcmciac, 0x3c0, i); + pcmciaWriteReg(pcmciac, 0x3c0, Attribute[i]); + } + + j = pcmciaReadReg(pcmciac, 0x3da); + pcmciaWriteReg(pcmciac, 0x3c0, 0x20); + + j = pcmciaReadReg(pcmciac, 0x3c8); + j = pcmciaReadReg(pcmciac, 0x3c6); + j = pcmciaReadReg(pcmciac, 0x3c6); + j = pcmciaReadReg(pcmciac, 0x3c6); + j = pcmciaReadReg(pcmciac, 0x3c6); + switch (pScreenPriv->screen->fb[0].depth) { + /* This is here for completeness, when/if we ever do 4bpp */ + case 4: + pcmciaWriteReg(pcmciac, 0x3c6, 0x0); + if (pcmciac->HP) { + pcmciaWriteIndex(pcmciac, 0x3ce, 0x0f, 0x90); + pcmciaWriteIndex(pcmciac, 0x3d4, 0x38, 0x00); + } else + pcmciaWriteIndex(pcmciac, 0x3c4, 0x07, 0x00); + break; + case 8: + pcmciaWriteReg(pcmciac, 0x3c6, 0x0); + if (pcmciac->HP) { + pcmciaWriteIndex(pcmciac, 0x3ce, 0x0f, 0x92); + pcmciaWriteIndex(pcmciac, 0x3d4, 0x38, 0x00); + } else + pcmciaWriteIndex(pcmciac, 0x3c4, 0x07, 0x01); + break; + case 15: + if (pcmciac->HP) { + pcmciaWriteReg(pcmciac, 0x3c6, 0x10); + pcmciaWriteIndex(pcmciac, 0x3ce, 0x0f, 0x9a); + pcmciaWriteIndex(pcmciac, 0x3d4, 0x38, 0x04); + } else { + pcmciaWriteReg(pcmciac, 0x3c6, 0xC0); + pcmciaWriteIndex(pcmciac, 0x3c4, 0x07, 0x03); + } + break; + case 16: + if (pcmciac->HP) { + pcmciaWriteReg(pcmciac, 0x3c6, 0x30); + pcmciaWriteIndex(pcmciac, 0x3ce, 0x0f, 0x9a); + pcmciaWriteIndex(pcmciac, 0x3d4, 0x38, 0x04); + } else { + pcmciaWriteReg(pcmciac, 0x3c6, 0xC1); + pcmciaWriteIndex(pcmciac, 0x3c4, 0x07, 0x03); + } + break; + } + j = pcmciaReadReg(pcmciac, 0x3c8); + + pcmciaWriteReg(pcmciac, 0x3c6, 0xff); + + for (i=0;i<256;i++) { + pcmciaWriteReg(pcmciac, 0x3c8, i); + pcmciaWriteReg(pcmciac, 0x3c9, i); + pcmciaWriteReg(pcmciac, 0x3c9, i); + pcmciaWriteReg(pcmciac, 0x3c9, i); + } + + /* Set the Clock */ + if (pcmciac->HP) { + CARD8 a,b; + int clock = t->clock; + if (pScreenPriv->screen->fb[0].bitsPerPixel == 16) + clock *= 2; + tridentSetCLK(clock, &a, &b); + pcmciaWriteReg(pcmciac, 0x43c8, a); + pcmciaWriteReg(pcmciac, 0x43c9, b); + } else { + int num, den; + unsigned char tmp; + int clock = t->clock; + if (pScreenPriv->screen->fb[0].bitsPerPixel == 16) + clock *= 2; + + CirrusFindClock(clock, &num, &den); + + tmp = pcmciaReadIndex(pcmciac, 0x3c4, 0x0d); + pcmciaWriteIndex(pcmciac, 0x3c4, 0x0d, (tmp & 0x80) | num); + tmp = pcmciaReadIndex(pcmciac, 0x3c4, 0x1d); + pcmciaWriteIndex(pcmciac, 0x3c4, 0x1d, (tmp & 0xc0) | den); + } + pcmciaWriteReg(pcmciac, 0x3c2, MiscOutReg | 0x08); + +#if 1 + for (i=1;i<0x3f;i++) + ErrorF("0x3c4:%02x: 0x%x\n",i,pcmciaReadIndex(pcmciac, 0x3c4, i)); + + ErrorF("\n"); + + for (i=0;i<0x3f;i++) + ErrorF("0x3ce:%02x: 0x%x\n",i,pcmciaReadIndex(pcmciac, 0x3ce, i)); + + ErrorF("\n"); + + for (i=0;i<0x3f;i++) + ErrorF("0x3d4:%02x: 0x%x\n",i,pcmciaReadIndex(pcmciac, 0x3d4, i)); +#endif + + return TRUE; +} + +void +pcmciaDisable (ScreenPtr pScreen) +{ +} + +const CARD8 tridentDPMSModes[4] = { + 0x00, /* KD_DPMS_NORMAL */ + 0x01, /* KD_DPMS_STANDBY */ + 0x02, /* KD_DPMS_SUSPEND */ + 0x03, /* KD_DPMS_POWERDOWN */ +}; + +Bool +pcmciaDPMS (ScreenPtr pScreen, int mode) +{ + KdScreenPriv(pScreen); + pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; + + if (pcmciac->HP) { + pcmciaWriteIndex (pcmciac, 0x3ce, 0x23, tridentDPMSModes[mode]); + pcmciaPause (); + } else { + /* Voyager */ + } + + return TRUE; +} + +void +pcmciaRestore (KdCardInfo *card) +{ +} + +void +pcmciaScreenFini (KdScreenInfo *screen) +{ + pcmciaScreenInfo *pcmcias = (pcmciaScreenInfo *) screen->driver; + + xfree (pcmcias); + screen->driver = 0; +} + +void +pcmciaCardFini (KdCardInfo *card) +{ + pcmciaCardInfo *pcmciac = card->driver; + + if (pcmciac->cop_base) + KdUnmapDevice ((void *) pcmciac->cop_base, PCMCIA_COP_SIZE(card)); +} + +void +pcmciaGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) +{ + KdScreenPriv(pScreen); + pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; + + while (ndef--) + { + pcmciaWriteReg (pcmciac, 0x3C7, pdefs->pixel); + pdefs->red = pcmciaReadReg (pcmciac, 0x3C9) << 10; + pdefs->green = pcmciaReadReg (pcmciac, 0x3C9) << 10; + pdefs->blue = pcmciaReadReg (pcmciac, 0x3C9) << 10; + pdefs++; + } +} + +void +pcmciaPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) +{ + KdScreenPriv(pScreen); + pcmciaCardInfo *pcmciac = pScreenPriv->card->driver; + + while (ndef--) + { + pcmciaWriteReg (pcmciac, 0x3C8, pdefs->pixel); + pcmciaWriteReg (pcmciac, 0x3C9, pdefs->red >> 10); + pcmciaWriteReg (pcmciac, 0x3C9, pdefs->green >> 10); + pcmciaWriteReg (pcmciac, 0x3C9, pdefs->blue >> 10); + pdefs++; + } +} + + +KdCardFuncs pcmciaFuncs = { + pcmciaCardInit, /* cardinit */ + pcmciaScreenInit, /* scrinit */ + pcmciaInitScreen, /* initScreen */ + pcmciaPreserve, /* preserve */ + pcmciaEnable, /* enable */ + pcmciaDPMS, /* dpms */ + pcmciaDisable, /* disable */ + pcmciaRestore, /* restore */ + pcmciaScreenFini, /* scrfini */ + pcmciaCardFini, /* cardfini */ + + pcmciaCursorInit, /* initCursor */ + pcmciaCursorEnable, /* enableCursor */ + pcmciaCursorDisable, /* disableCursor */ + pcmciaCursorFini, /* finiCursor */ + pcmciaRecolorCursor, /* recolorCursor */ + +#if 0 /* not yet */ + pcmciaDrawInit, /* initAccel */ + pcmciaDrawEnable, /* enableAccel */ + pcmciaDrawSync, /* syncAccel */ + pcmciaDrawDisable, /* disableAccel */ + pcmciaDrawFini, /* finiAccel */ +#else + 0, + 0, + 0, + 0, + 0, +#endif + + pcmciaGetColors, /* getColors */ + pcmciaPutColors, /* putColors */ +}; --- xorg-server-1.4.99.906.orig/hw/kdrive/pcmcia/pcmciashadow.c +++ xorg-server-1.4.99.906/hw/kdrive/pcmcia/pcmciashadow.c @@ -0,0 +1,199 @@ +/* + * Copyright 2001 by Alan Hourihane, Sychdyn, North Wales, UK. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE 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. + * + * Authors: Alan Hourihane, + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include "scrnintstr.h" +#include "windowstr.h" +#include "font.h" +#include "dixfontstr.h" +#include "fontstruct.h" +#include "mi.h" +#include "regionstr.h" +#include "globals.h" +#include "gcstruct.h" +#include "shadow.h" +#include "fb.h" + +void +tridentUpdatePacked (ScreenPtr pScreen, + shadowBufPtr pBuf) +{ + RegionPtr damage = &pBuf->damage; + PixmapPtr pShadow = pBuf->pPixmap; + shadowScrPriv(pScreen); + int nbox = REGION_NUM_RECTS (damage); + BoxPtr pbox = REGION_RECTS (damage); + FbBits *shaBase, *shaLine, *sha; + FbStride shaStride; + int scrBase, scrLine, scr; + int shaBpp; + int shaXoff, shaYoff; /* XXX assumed to be zero */ + int x, y, w, h, width; + int i; + FbBits *winBase, *win; + CARD32 winSize; + + fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); + while (nbox--) + { + x = pbox->x1 * shaBpp; + y = pbox->y1; + w = (pbox->x2 - pbox->x1) * shaBpp; + h = pbox->y2 - pbox->y1; + + scrLine = (x >> FB_SHIFT); + shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); + + x &= FB_MASK; + w = (w + x + FB_MASK) >> FB_SHIFT; + + while (h--) + { + winSize = 0; + scrBase = 0; + width = w; + scr = scrLine; + sha = shaLine; + while (width) { + /* how much remains in this window */ + i = scrBase + winSize - scr; + if (i <= 0 || scr < scrBase) + { + winBase = (FbBits *) (*pBuf->window) (pScreen, + y, + scr * sizeof (FbBits), + SHADOW_WINDOW_WRITE, + &winSize, + pBuf->closure); + if(!winBase) + return; + scrBase = scr; + winSize /= sizeof (FbBits); + i = winSize; + } + win = winBase + (scr - scrBase); + if (i > width) + i = width; + width -= i; + scr += i; + { + CARD16 *sha16 = (CARD16*)sha; + CARD16 *win16 = (CARD16*)win; + while (i--) + { + *win16++ = *sha16++; + *win16++ = *sha16++; + } + } + } + shaLine += shaStride; + y++; + } + pbox++; + } +} + +void +cirrusUpdatePacked (ScreenPtr pScreen, + shadowBufPtr pBuf) +{ + RegionPtr damage = &pBuf->damage; + PixmapPtr pShadow = pBuf->pPixmap; + shadowScrPriv(pScreen); + int nbox = REGION_NUM_RECTS (damage); + BoxPtr pbox = REGION_RECTS (damage); + FbBits *shaBase, *shaLine, *sha; + FbStride shaStride; + int scrBase, scrLine, scr; + int shaBpp; + int shaXoff, shaYoff; /* XXX assumed to be zero */ + int x, y, w, h, width; + int i; + FbBits *winBase, *win; + CARD32 winSize; + + fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); + while (nbox--) + { + x = pbox->x1 * shaBpp; + y = pbox->y1; + w = (pbox->x2 - pbox->x1) * shaBpp; + h = pbox->y2 - pbox->y1; + + scrLine = (x >> FB_SHIFT); + shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); + + x &= FB_MASK; + w = (w + x + FB_MASK) >> FB_SHIFT; + + while (h--) + { + winSize = 0; + scrBase = 0; + width = w; + scr = scrLine; + sha = shaLine; + while (width) { + /* how much remains in this window */ + i = scrBase + winSize - scr; + if (i <= 0 || scr < scrBase) + { + winBase = (FbBits *) (*pBuf->window) (pScreen, + y, + scr * sizeof (FbBits), + SHADOW_WINDOW_WRITE, + &winSize, + pBuf->closure); + if(!winBase) + return; + scrBase = scr; + winSize /= sizeof (FbBits); + i = winSize; + } + win = winBase + (scr - scrBase); + if (i > width) + i = width; + width -= i; + scr += i; + { + CARD8 *sha8 = (CARD8*)sha; + CARD8 *win8 = (CARD8*)win; + while (i--) + { + *win8++ = *sha8++; + *win8++ = *sha8++; + *win8++ = *sha8++; + *win8++ = *sha8++; + } + } + } + shaLine += shaStride; + y++; + } + pbox++; + } +} --- xorg-server-1.4.99.906.orig/hw/kdrive/pcmcia/pcmciacurs.c +++ xorg-server-1.4.99.906/hw/kdrive/pcmcia/pcmciacurs.c @@ -0,0 +1,451 @@ +/* + * Copyright 2001 by Alan Hourihane, Sychdyn, North Wales, UK. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE 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. + * + * Authors: Alan Hourihane, + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "pcmcia.h" +#include "cursorstr.h" + +#define SetupCursor(s) KdScreenPriv(s); \ + pcmciaCardInfo(pScreenPriv); \ + pcmciaScreenInfo(pScreenPriv); \ + pcmciaCursor *pCurPriv = &pcmcias->cursor + +static void +_pcmciaMoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CARD8 xlow, xhigh, ylow, yhigh; + CARD8 xoff, yoff; + + x -= pCurPriv->xhot; + xoff = 0; + if (x < 0) + { + xoff = -x; + x = 0; + } + y -= pCurPriv->yhot; + yoff = 0; + if (y < 0) + { + yoff = -y; + y = 0; + } + + /* This is the recommended order to move the cursor */ + if (pcmciac->HP) { + xlow = (CARD8) x; + xhigh = (CARD8) (x >> 8); + ylow = (CARD8) y; + yhigh = (CARD8) (y >> 8); + pcmciaWriteIndex (pcmciac, 0x3d4, 0x40, xlow); + pcmciaWriteIndex (pcmciac, 0x3d4, 0x41, xhigh); + pcmciaWriteIndex (pcmciac, 0x3d4, 0x42, ylow); + pcmciaWriteIndex (pcmciac, 0x3d4, 0x43, yhigh); + pcmciaWriteIndex (pcmciac, 0x3d4, 0x46, xoff); + pcmciaWriteIndex (pcmciac, 0x3d4, 0x47, yoff); + } else { + x >>= 3; + y >>= 3; + xlow = (CARD8) x; + xhigh = (CARD8) (x >> 8); + ylow = (CARD8) y; + yhigh = (CARD8) (y >> 8); + /* Don't be alarmed, yes the upper 3bits of the index are correct */ + pcmciaWriteIndex (pcmciac, 0x3c4, 0x10 | xhigh << 5, xlow); + pcmciaWriteIndex (pcmciac, 0x3c4, 0x11 | yhigh << 5, ylow); + } +} + +static void +pcmciaMoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor (pScreen); + + if (!pCurPriv->has_cursor) + return; + + if (!pScreenPriv->enabled) + return; + + _pcmciaMoveCursor (pScreen, x, y); +} + +static void +pcmciaAllocCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + + KdAllocateCursorPixels (pScreen, 0, pCursor, + &pCurPriv->source, &pCurPriv->mask); + switch (pScreenPriv->screen->fb[0].bitsPerPixel) { + case 4: + pCurPriv->source |= pCurPriv->source << 4; + pCurPriv->mask |= pCurPriv->mask << 4; + case 8: + pCurPriv->source |= pCurPriv->source << 8; + pCurPriv->mask |= pCurPriv->mask << 8; + case 16: + pCurPriv->source |= pCurPriv->source << 16; + pCurPriv->mask |= pCurPriv->mask << 16; + } +} + +static void +pcmciaSetCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + CARD32 fg, bg; + + fg = pCurPriv->source; + bg = pCurPriv->mask; + + if (pcmciac->HP) { + /* + * This trident chip uses the palette for it's cursor colors - ouch! + * We enforce it to always stay the black/white colors as we don't + * want it to muck with the overscan color. Tough. Use softCursor + * if you want to change cursor colors. + */ + pcmciaWriteReg (pcmciac, 0x3c8, 0xff); /* DAC 0 */ + pcmciaWriteReg (pcmciac, 0x3c9, 0x00); + pcmciaWriteReg (pcmciac, 0x3c9, 0x00); + pcmciaWriteReg (pcmciac, 0x3c9, 0x00); + pcmciaWriteReg (pcmciac, 0x3c8, 0x00); /* DAC 255 */ + pcmciaWriteReg (pcmciac, 0x3c9, 0x3f); + pcmciaWriteReg (pcmciac, 0x3c9, 0x3f); + pcmciaWriteReg (pcmciac, 0x3c9, 0x3f); + } else { + CARD8 temp; + temp = pcmciaReadIndex(pcmciac, 0x3c4, 0x12); + pcmciaWriteIndex (pcmciac, 0x3c4, 0x12, (temp & 0xFE) | 0x02); + + pcmciaWriteReg (pcmciac, 0x3c8, 0x00); /* DAC 256 */ + pcmciaWriteReg (pcmciac, 0x3c9, fg); + pcmciaWriteReg (pcmciac, 0x3c9, fg >> 8); + pcmciaWriteReg (pcmciac, 0x3c9, fg >> 16); + pcmciaWriteReg (pcmciac, 0x3c8, 0x00); /* DAC 257 */ + pcmciaWriteReg (pcmciac, 0x3c9, bg); + pcmciaWriteReg (pcmciac, 0x3c9, bg >> 8); + pcmciaWriteReg (pcmciac, 0x3c9, bg >> 16); + + pcmciaWriteIndex (pcmciac, 0x3c4, 0x12, temp); + } +} + +void +pcmciaRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + xColorItem sourceColor, maskColor; + + if (!pCurPriv->has_cursor || !pCursor) + return; + + if (!pScreenPriv->enabled) + return; + + if (pdef) + { + while (ndef) + { + if (pdef->pixel == pCurPriv->source || + pdef->pixel == pCurPriv->mask) + break; + ndef--; + } + if (!ndef) + return; + } + pcmciaAllocCursorColors (pScreen); + pcmciaSetCursorColors (pScreen); +} + +#define InvertBits32(v) { \ + v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ + v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ + v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ +} + +static void +pcmciaLoadCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + CursorBitsPtr bits = pCursor->bits; + int w, h; + CARD8 *ram; + CARD32 *msk, *mskLine, *src, *srcLine; + int i, j; + int cursor_address; + int lwsrc; + unsigned char ramdac_control_; + CARD32 offset; + + /* + * Allocate new colors + */ + pcmciaAllocCursorColors (pScreen); + + pCurPriv->pCursor = pCursor; + pCurPriv->xhot = pCursor->bits->xhot; + pCurPriv->yhot = pCursor->bits->yhot; + + /* + * Stick new image into cursor memory + */ + if (pcmciac->HP) { + ram = (CARD8 *) pcmcias->cursor_base; + } else { + /* The last bank */ + ram = (CARD8 *) pcmciac->fb; + pcmciaWriteIndex (pcmciac, 0x3ce, 0x09, 0x7f); + pcmciaWriteIndex (pcmciac, 0x3ce, 0x0A, 0x7f); + } + + mskLine = (CARD32 *) bits->mask; + srcLine = (CARD32 *) bits->source; + + h = bits->height; + if (h > PCMCIA_CURSOR_HEIGHT) + h = PCMCIA_CURSOR_HEIGHT; + + lwsrc = BitmapBytePad(bits->width) / 4; + + for (i = 0; i < PCMCIA_CURSOR_HEIGHT; i++) { + msk = mskLine; + src = srcLine; + mskLine += lwsrc; + srcLine += lwsrc; + for (j = 0; j < PCMCIA_CURSOR_WIDTH / 32; j++) { + + CARD32 m, s; + + if (i < h && j < lwsrc) + { + m = *msk++; + s = *src++; + InvertBits32(m); + InvertBits32(s); + } + else + { + m = 0; + s = 0; + } + + /* Do 8bit access */ + *ram++ = (m & 0xff); + *ram++ = (m & 0xff00) >> 8; + *ram++ = (m & 0xff0000) >> 16; + *ram++ = (m & 0xff000000) >> 24; + *ram++ = (s & 0xff); + *ram++ = (s & 0xff00) >> 8; + *ram++ = (s & 0xff0000) >> 16; + *ram++ = (s & 0xff000000) >> 24; + } + } + + /* Set address for cursor bits */ + if (pcmciac->HP) { + offset = pcmcias->cursor_base - (CARD8 *) pcmcias->screen; + offset >>= 10; + pcmciaWriteIndex (pcmciac, 0x3d4, 0x44, (CARD8) (offset & 0xff)); + pcmciaWriteIndex (pcmciac, 0x3d4, 0x45, (CARD8) (offset >> 8)); + } else { + pcmciaWriteIndex (pcmciac, 0x3c4, 0x13, 15); /* ?? */ + } + + /* Set new color */ + pcmciaSetCursorColors (pScreen); + + /* Enable the cursor */ + if (pcmciac->HP) + pcmciaWriteIndex (pcmciac, 0x3d4, 0x50, 0xc1); + else + pcmciaWriteIndex (pcmciac, 0x3c4, 0x12, 0x05); + + /* Move to new position */ + pcmciaMoveCursor (pScreen, x, y); +} + +static void +pcmciaUnloadCursor (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + /* Disable cursor */ + if (pcmciac->HP) + pcmciaWriteIndex (pcmciac, 0x3d4, 0x50, 0); + else + pcmciaWriteIndex (pcmciac, 0x3c4, 0x12, 0); +} + +static Bool +pcmciaRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + SetupCursor(pScreen); + + if (!pScreenPriv->enabled) + return TRUE; + + /* miRecolorCursor does this */ + if (pCurPriv->pCursor == pCursor) + { + if (pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + pcmciaLoadCursor (pScreen, x, y); + } + } + return TRUE; +} + +static Bool +pcmciaUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + return TRUE; +} + +static void +pcmciaSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +{ + SetupCursor(pScreen); + + pCurPriv->pCursor = pCursor; + + if (!pScreenPriv->enabled) + return; + + if (pCursor) + pcmciaLoadCursor (pScreen, x, y); + else + pcmciaUnloadCursor (pScreen); +} + +miPointerSpriteFuncRec pcmciaPointerSpriteFuncs = { + pcmciaRealizeCursor, + pcmciaUnrealizeCursor, + pcmciaSetCursor, + pcmciaMoveCursor, +}; + +static void +pcmciaQueryBestSize (int class, + unsigned short *pwidth, unsigned short *pheight, + ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + switch (class) + { + case CursorShape: + if (*pwidth > pCurPriv->width) + *pwidth = pCurPriv->width; + if (*pheight > pCurPriv->height) + *pheight = pCurPriv->height; + if (*pwidth > pScreen->width) + *pwidth = pScreen->width; + if (*pheight > pScreen->height) + *pheight = pScreen->height; + break; + default: + fbQueryBestSize (class, pwidth, pheight, pScreen); + break; + } +} + +Bool +pcmciaCursorInit (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!pcmcias->cursor_base) + { + pCurPriv->has_cursor = FALSE; + return FALSE; + } + + pCurPriv->width = PCMCIA_CURSOR_WIDTH; + pCurPriv->height= PCMCIA_CURSOR_HEIGHT; + pScreen->QueryBestSize = pcmciaQueryBestSize; + miPointerInitialize (pScreen, + &pcmciaPointerSpriteFuncs, + &kdPointerScreenFuncs, + FALSE); + pCurPriv->has_cursor = TRUE; + pCurPriv->pCursor = NULL; + return TRUE; +} + +void +pcmciaCursorEnable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + pcmciaLoadCursor (pScreen, x, y); + } + else + pcmciaUnloadCursor (pScreen); + } +} + +void +pcmciaCursorDisable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!pScreenPriv->enabled) + return; + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + pcmciaUnloadCursor (pScreen); + } + } +} + +void +pcmciaCursorFini (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + pCurPriv->pCursor = NULL; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/pcmcia/pcmcia.h +++ xorg-server-1.4.99.906/hw/kdrive/pcmcia/pcmcia.h @@ -0,0 +1,267 @@ +/* + * Copyright 2001 by Alan Hourihane, Sychdyn, North Wales, UK. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE 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. + * + * Authors: Alan Hourihane, + */ + +#ifndef _PCMCIA_H_ +#define _PCMCIA_H_ + +#include + +/* + * offset from ioport beginning + */ + +#define PCMCIA_COP_BASE(c) 0x20000000 +#define PCMCIA_COP_SIZE(c) 0x10000 +#define TRIDENT_COP_OFF(c) 0x2100 + +typedef volatile CARD8 VOL8; +typedef volatile CARD16 VOL16; +typedef volatile CARD32 VOL32; + +typedef struct _cop { + VOL32 src_start_xy; /* 0x00 */ + VOL32 src_end_xy; /* 0x04 */ + VOL32 dst_start_xy; /* 0x08 */ + VOL32 dst_end_xy; /* 0x0c */ + VOL32 alpha; /* 0x10 */ + CARD8 pad14[0xc]; /* 0x14 */ + VOL32 multi; /* 0x20 */ + +#define COP_MULTI_CLIP_TOP_LEFT 0x10000000 +#define COP_MULTI_DEPTH 0x40000000 +#define COP_MULTI_COLOR_KEY 0x70000000 +#define COP_MULTI_STYLE 0x50000000 +#define COP_MULTI_PATTERN 0x80000000 +#define COP_MULTI_ROP 0x90000000 +#define COP_MULTI_STRIDE 0x60000000 +#define COP_MULTI_Z 0xa0000000 +#define COP_MULTI_ALPHA 0xb0000000 +#define COP_MULTI_TEXTURE 0xd0000000 +#define COP_MULTI_TEXTURE_BOUND 0xe0000000 +#define COP_MULTI_TEXTURE_ADVANCED 0x20000000 +#define COP_MULTI_MASK 0xf0000000 + +#define COP_DEPTH_8 0x00000000 +#define COP_DEPTH_16 0x00000001 +#define COP_DEPTH_24_32 0x00000002 +#define COP_DEPTH_15 0x00000005 +#define COP_DEPTH_DITHER_DISABLE 0x00000008 + + +#define COP_ALPHA_SRC_BLEND_0 0x00000000 +#define COP_ALPHA_SRC_BLEND_1 0x00000001 +#define COP_ALPHA_SRC_BLEND_SRC_C 0x00000002 +#define COP_ALPHA_SRC_BLEND_1_SRC_C 0x00000003 +#define COP_ALPHA_SRC_BLEND_SRC_A 0x00000004 +#define COP_ALPHA_SRC_BLEND_1_SRC_A 0x00000005 +#define COP_ALPHA_SRC_BLEND_DST_A 0x00000006 +#define COP_ALPHA_SRC_BLEND_1_DST_A 0x00000007 +#define COP_ALPHA_SRC_BLEND_DST_C 0x00000008 +#define COP_ALPHA_SRC_BLEND_1_DST_C 0x00000009 +#define COP_ALPHA_SRC_BLEND_SAT 0x0000000A +#define COP_ALPHA_SRC_BLEND_BG 0x0000000B + +#define COP_ALPHA_DST_BLEND_0 0x00000000 +#define COP_ALPHA_DST_BLEND_1 0x00000010 +#define COP_ALPHA_DST_BLEND_SRC_C 0x00000020 +#define COP_ALPHA_DST_BLEND_1_SRC_C 0x00000030 +#define COP_ALPHA_DST_BLEND_SRC_A 0x00000040 +#define COP_ALPHA_DST_BLEND_1_SRC_A 0x00000050 +#define COP_ALPHA_DST_BLEND_DST_A 0x00000060 +#define COP_ALPHA_DST_BLEND_1_DST_A 0x00000070 +#define COP_ALPHA_DST_BLEND_DST_C 0x00000080 +#define COP_ALPHA_DST_BLEND_1_DST_C 0x00000090 +#define COP_ALPHA_DST_BLEND_OTHER 0x000000A0 + +#define COP_ALPHA_RESULT_ALPHA 0x00100000 +#define COP_ALPHA_DEST_ALPHA 0x00200000 +#define COP_ALPHA_SOURCE_ALPHA 0x00400000 +#define COP_ALPHA_WRITE_ENABLE 0x00800000 +#define COP_ALPHA_TEST_ENABLE 0x01000000 +#define COP_ALPHA_BLEND_ENABLE 0x02000000 +#define COP_ALPHA_DEST_VALUE 0x04000000 +#define COP_ALPHA_SOURCE_VALUE 0x08000000 + + VOL32 command; /* 0x24 */ +#define COP_OP_NULL 0x00000000 +#define COP_OP_LINE 0x20000000 +#define COP_OP_BLT 0x80000000 +#define COP_OP_TEXT 0x90000000 +#define COP_OP_POLY 0xb0000000 +#define COP_OP_POLY2 0xe0000000 +#define COP_SCL_EXPAND 0x00800000 +#define COP_SCL_OPAQUE 0x00400000 +#define COP_SCL_REVERSE 0x00200000 +#define COP_SCL_MONO_OFF 0x001c0000 +#define COP_LIT_TEXTURE 0x00004000 +#define COP_BILINEAR 0x00002000 +#define COP_OP_ZBUF 0x00000800 +#define COP_OP_ROP 0x00000400 +#define COP_OP_FG 0x00000200 +#define COP_OP_FB 0x00000080 +#define COP_X_REVERSE 0x00000004 +#define COP_CLIP 0x00000001 + VOL32 texture_format; /* 0x28 */ + CARD8 pad2c[0x4]; /* 0x2c */ + + VOL32 clip_bottom_right; /* 0x30 */ + VOL32 dataIII; /* 0x34 */ + VOL32 dataIV; /* 0x38 */ + CARD8 pad3c[0x8]; /* 0x3c */ + + VOL32 fg; /* 0x44 */ + VOL32 bg; /* 0x48 */ + CARD8 pad4c[0x4]; /* 0x4c */ + + VOL32 pattern_fg; /* 0x50 */ + VOL32 pattern_bg; /* 0x54 */ + CARD8 pad58[0xc]; /* 0x58 */ + + VOL32 status; /* 0x64 */ +#define COP_STATUS_BE_BUSY 0x80000000 +#define COP_STATUS_DPE_BUSY 0x20000000 +#define COP_STATUS_MI_BUSY 0x10000000 +#define COP_STATUS_FIFO_BUSY 0x08000000 +#define COP_STATUS_WB_BUSY 0x00800000 +#define COP_STATUS_Z_FAILED 0x00400000 +#define COP_STATUS_EFFECTIVE 0x00200000 +#define COP_STATUS_LEFT_VIEW 0x00080000 + + CARD8 pad68[0x4]; /* 0x68 */ + + VOL32 src_offset; /* 0x6c */ + VOL32 z_offset; /* 0x70 */ + CARD8 pad74[0x4]; /* 0x74 */ + + VOL32 display_offset; /* 0x78 */ + VOL32 dst_offset; /* 0x7c */ + CARD8 pad80[0x34]; /* 0x80 */ + + VOL32 semaphore; /* 0xb4 */ +} Cop; + +#define TRI_XY(x,y) ((y) << 16 | (x)) + +typedef struct _pcmciaCardInfo { + CARD8 *fb; + Bool HP; + CARD32 memory; + CARD8 *cop_base; + Cop *cop; + CARD32 *window; + CARD32 cop_depth; + CARD32 cop_stride; +} pcmciaCardInfo; + +#define getpcmciaCardInfo(kd) ((pcmciaCardInfo *) ((kd)->card->driver)) +#define pcmciaCardInfo(kd) pcmciaCardInfo *pcmciac = getpcmciaCardInfo(kd) + +typedef struct _pcmciaCursor { + int width, height; + int xhot, yhot; + Bool has_cursor; + CursorPtr pCursor; + Pixel source, mask; +} pcmciaCursor; + +#define PCMCIA_CURSOR_WIDTH 64 +#define PCMCIA_CURSOR_HEIGHT 64 + +typedef struct _pcmciaScreenInfo { + CARD8 *cursor_base; + CARD8 *screen; + CARD8 *off_screen; + int off_screen_size; + int randr; + LayerPtr pLayer; + pcmciaCursor cursor; +} pcmciaScreenInfo; + +#define getpcmciaScreenInfo(kd) ((pcmciaScreenInfo *) ((kd)->screen->driver)) +#define pcmciaScreenInfo(kd) pcmciaScreenInfo *pcmcias = getpcmciaScreenInfo(kd) + +Bool +pcmciaDrawInit (ScreenPtr pScreen); + +void +pcmciaDrawEnable (ScreenPtr pScreen); + +void +pcmciaDrawSync (ScreenPtr pScreen); + +void +pcmciaDrawDisable (ScreenPtr pScreen); + +void +pcmciaDrawFini (ScreenPtr pScreen); + +CARD8 +pcmciaReadIndex (pcmciaCardInfo *pcmciac, CARD16 port, CARD8 index); + +void +pcmciaWriteIndex (pcmciaCardInfo *pcmciac, CARD16 port, CARD8 index, CARD8 value); + +void +pcmciaWriteReg (pcmciaCardInfo *pcmciac, CARD16 port, CARD8 value); + +Bool +pcmciaCursorInit (ScreenPtr pScreen); + +void +pcmciaCursorEnable (ScreenPtr pScreen); + +void +pcmciaCursorDisable (ScreenPtr pScreen); + +void +pcmciaCursorFini (ScreenPtr pScreen); + +void +pcmciaRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef); + +void +pcmciaUpdateRotatePacked (ScreenPtr pScreen, + shadowBufPtr pBuf); + +typedef struct _pcmciaDisplayModeRec { + int Width; + int Height; + int Refresh; + int Clock; /* pixel clock freq */ + int HDisplay; /* horizontal timing */ + int HSyncStart; + int HSyncEnd; + int HTotal; + int HSkew; + int VDisplay; /* vertical timing */ + int VSyncStart; + int VSyncEnd; + int VTotal; + int VScan; + int Flags; +} pcmciaDisplayModeRec, *pcmciaDisplayModePtr; + +extern KdCardFuncs pcmciaFuncs; + +#endif /* _PCMCIA_H_ */ --- xorg-server-1.4.99.906.orig/hw/kdrive/smi/smivideo.c +++ xorg-server-1.4.99.906/hw/kdrive/smi/smivideo.c @@ -0,0 +1,1015 @@ +/* + * Copyright © 2001 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "mach64.h" + +#include "Xv.h" +#include "../../xfree86/common/fourcc.h" + +#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) + +static Atom xvBrightness, xvSaturation, xvColorKey; + +#define IMAGE_MAX_WIDTH 720 +#define IMAGE_MAX_HEIGHT 576 + +static void +mach64StopVideo(KdScreenInfo *screen, pointer data, Bool exit) +{ + ScreenPtr pScreen = screen->pScreen; + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; + Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; + Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; + Reg *reg = mach64c->reg; + MediaReg *media = mach64c->media_reg; + + REGION_EMPTY(screen->pScreen, &pPortPriv->clip); + + if (!media) + return; + + if(pPortPriv->videoOn) + { + mach64WaitIdle (reg); + /* wait for buffer to be displayed */ + while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf) + ; + /* wait for buffer to be finished */ + while (((media->TRIG_CNTL >> 6) & 1) != 0) + ; + mach64WaitAvail (reg, 1); + media->OVERLAY_SCALE_CNTL = 0; + pPortPriv->videoOn = FALSE; + mach64WaitIdle (reg); + } +} + +static int +mach64SetPortAttribute(KdScreenInfo *screen, + Atom attribute, + int value, + pointer data) +{ + ScreenPtr pScreen = screen->pScreen; + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; + Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; + Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; + MediaReg *media = mach64c->media_reg; + + if(attribute == xvBrightness) + { + if(value < -1000) + value = -1000; + if (value > 1000) + value = 1000; + pPortPriv->brightness = value; + } + else if(attribute == xvSaturation) + { + if (value < -1000) + value = -1000; + if (value > 1000) + value = 1000; + pPortPriv->saturation = value; + } + else if(attribute == xvColorKey) + { + if (pPortPriv->colorKey != value) + { + pPortPriv->colorKey = value; + REGION_EMPTY(screen->pScreen, &pPortPriv->clip); + } + } + else + return BadMatch; + + return Success; +} + +static int +mach64GetPortAttribute(KdScreenInfo *screen, + Atom attribute, + int *value, + pointer data) +{ + Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data; + + if(attribute == xvBrightness) + *value = pPortPriv->brightness; + else if(attribute == xvSaturation) + *value = pPortPriv->saturation; + else if(attribute == xvColorKey) + *value = pPortPriv->colorKey; + else + return BadMatch; + + return Success; +} + +static void +mach64QueryBestSize(KdScreenInfo *screen, + Bool motion, + short vid_w, + short vid_h, + short drw_w, + short drw_h, + unsigned int *p_w, + unsigned int *p_h, + pointer data) +{ + *p_w = drw_w; + *p_h = drw_h; +} + + +static void +mach64CopyPackedData(KdScreenInfo *screen, + unsigned char *buf, + int randr, + int srcPitch, + int dstPitch, + int srcW, + int srcH, + int top, + int left, + int h, + int w) +{ + ScreenPtr pScreen = screen->pScreen; + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; + Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; + Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; + CARD8 *src, *dst; + int srcDown, srcRight, srcNext; + int p; + + switch (randr & RR_Rotate_All) { + case RR_Rotate_0: + src = buf; + srcDown = srcPitch; + srcRight = 2; + break; + case RR_Rotate_90: + src = buf + (srcH - 1) * 2; + srcDown = -2; + srcRight = srcPitch; + break; + case RR_Rotate_180: + src = buf + srcPitch * (srcH - 1) + (srcW - 1) * 2; + srcDown = -srcPitch; + srcRight = -2; + break; + case RR_Rotate_270: + src = buf + srcPitch * (srcW - 1); + srcDown = 2; + srcRight = -srcPitch; + break; + } + + src = src + top*srcDown + left*srcRight; + + if (pPortPriv->currentBuf == 0) + dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset; + else + dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset; + + w >>= 1; + srcRight >>= 1; + srcNext = srcRight >> 1; + while(h--) + { + CARD16 *s = (CARD16 *) src; + CARD32 *d = (CARD32 *) dst; + p = w; + while (p--) + { + *d++ = s[0] | (s[srcNext] << 16); + s += srcRight; + } + src += srcPitch; + dst += dstPitch; + } +} + +static void +mach64CopyPlanarData(KdScreenInfo *screen, + unsigned char *buf, + int randr, + int srcPitch, + int srcPitch2, + int dstPitch, /* of chroma */ + int srcW, + int srcH, + int height, + int top, + int left, + int h, + int w, + int id) +{ + ScreenPtr pScreen = screen->pScreen; + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; + Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; + Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; + int i, j; + CARD8 *src1, *src2, *src3, *dst1; + int srcDown, srcDown2, srcRight, srcRight2, srcNext; + + /* compute source data pointers */ + src1 = buf; + src2 = src1 + height * srcPitch; + src3 = src2 + (height >> 1) * srcPitch2; + switch (randr & RR_Rotate_All) { + case RR_Rotate_0: + srcDown = srcPitch; + srcDown2 = srcPitch2; + srcRight = 2; + srcRight2 = 1; + srcNext = 1; + break; + case RR_Rotate_90: + src1 = src1 + srcH - 1; + src2 = src2 + (srcH >> 1) - 1; + src3 = src3 + (srcH >> 1) - 1; + srcDown = -1; + srcDown2 = -1; + srcRight = srcPitch * 2; + srcRight2 = srcPitch2; + srcNext = srcPitch; + break; + case RR_Rotate_180: + src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1); + src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1); + src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1); + srcDown = -srcPitch; + srcDown2 = -srcPitch2; + srcRight = -2; + srcRight2 = -1; + srcNext = -1; + break; + case RR_Rotate_270: + src1 = src1 + srcPitch * (srcW - 1); + src2 = src2 + srcPitch2 * ((srcW >> 1) - 1); + src3 = src3 + srcPitch2 * ((srcW >> 1) - 1); + srcDown = 1; + srcDown2 = 1; + srcRight = -srcPitch * 2; + srcRight2 = -srcPitch2; + srcNext = -srcPitch; + break; + } + + /* adjust for origin */ + src1 += top * srcDown + left * srcNext; + src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2; + src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2; + + if (id == FOURCC_I420) + { + CARD8 *srct = src2; + src2 = src3; + src3 = srct; + } + + if (pPortPriv->currentBuf == 0) + dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset; + else + dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset; + + w >>= 1; + for (j = 0; j < h; j++) + { + CARD32 *dst = (CARD32 *) dst1; + CARD8 *s1l = src1; + CARD8 *s1r = src1 + srcNext; + CARD8 *s2 = src2; + CARD8 *s3 = src3; + + for (i = 0; i < w; i++) + { + *dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24); + s1l += srcRight; + s1r += srcRight; + s2 += srcRight2; + s3 += srcRight2; + } + src1 += srcDown; + dst1 += dstPitch; + if (j & 1) + { + src2 += srcDown2; + src3 += srcDown2; + } + } +} + +static void +mach64PaintRegion (ScreenPtr pScreen, RegionPtr pRgn, Pixel fg) +{ + WindowPtr pRoot = WindowTable[pScreen->myNum]; + GCPtr pGC; + CARD32 val[2]; + xRectangle *rects, *r; + BoxPtr pBox = REGION_RECTS (pRgn); + int nBox = REGION_NUM_RECTS (pRgn); + + rects = xalloc (nBox * sizeof (xRectangle)); + if (!rects) + goto bail0; + r = rects; + while (nBox--) + { + r->x = pBox->x1; + r->y = pBox->y1; + r->width = pBox->x2 - pBox->x1; + r->height = pBox->y2 - pBox->y1; + r++; + pBox++; + } + + pGC = GetScratchGC (pRoot->drawable.depth, pScreen); + if (!pGC) + goto bail1; + + val[0] = fg; + val[1] = IncludeInferiors; + ChangeGC (pGC, GCForeground|GCSubwindowMode, val); + + ValidateGC (&pRoot->drawable, pGC); + + (*pGC->ops->PolyFillRect) (&pRoot->drawable, pGC, + REGION_NUM_RECTS (pRgn), rects); + + FreeScratchGC (pGC); +bail1: + xfree (rects); +bail0: + ; +} + +/* Mach64ClipVideo - + + Takes the dst box in standard X BoxRec form (top and left + edges inclusive, bottom and right exclusive). The new dst + box is returned. The source boundaries are given (x1, y1 + inclusive, x2, y2 exclusive) and returned are the new source + boundaries in 16.16 fixed point. +*/ + +static void +Mach64ClipVideo(BoxPtr dst, + INT32 *x1, + INT32 *x2, + INT32 *y1, + INT32 *y2, + BoxPtr extents, /* extents of the clip region */ + INT32 width, + INT32 height) +{ + INT32 vscale, hscale, delta; + int diff; + + hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); + vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); + + *x1 <<= 16; *x2 <<= 16; + *y1 <<= 16; *y2 <<= 16; + + diff = extents->x1 - dst->x1; + if(diff > 0) { + dst->x1 = extents->x1; + *x1 += diff * hscale; + } + diff = dst->x2 - extents->x2; + if(diff > 0) { + dst->x2 = extents->x2; + *x2 -= diff * hscale; + } + diff = extents->y1 - dst->y1; + if(diff > 0) { + dst->y1 = extents->y1; + *y1 += diff * vscale; + } + diff = dst->y2 - extents->y2; + if(diff > 0) { + dst->y2 = extents->y2; + *y2 -= diff * vscale; + } + + if(*x1 < 0) { + diff = (- *x1 + hscale - 1)/ hscale; + dst->x1 += diff; + *x1 += diff * hscale; + } + delta = *x2 - (width << 16); + if(delta > 0) { + diff = (delta + hscale - 1)/ hscale; + dst->x2 -= diff; + *x2 -= diff * hscale; + } + if(*y1 < 0) { + diff = (- *y1 + vscale - 1)/ vscale; + dst->y1 += diff; + *y1 += diff * vscale; + } + delta = *y2 - (height << 16); + if(delta > 0) { + diff = (delta + vscale - 1)/ vscale; + dst->y2 -= diff; + *y2 -= diff * vscale; + } +} + +static void +mach64DisplayVideo(KdScreenInfo *screen, + int id, + int dstPitch, /* of chroma for 4:2:0 */ + int x1, + int y1, + int x2, + int y2, + int dst_x1, + int dst_y1, + int dst_x2, + int dst_y2, + short src_w, + short src_h, + short drw_w, + short drw_h) +{ + ScreenPtr pScreen = screen->pScreen; + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; + Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; + Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; + Reg *reg = mach64c->reg; + MediaReg *media = mach64c->media_reg; + int xscaleInt, xscaleFract, yscaleInt, yscaleFract; + int xscaleIntUV = 0, xscaleFractUV = 0; + int yscaleIntUV = 0, yscaleFractUV = 0; + int randr = mach64s->vesa.randr; + int HORZ_INC, VERT_INC; + CARD32 SCALER_IN; + CARD32 OVERLAY_SCALE_CNTL; + int tmp; + int left; + int bright; + int sat; + + if (id == FOURCC_UYVY) + SCALER_IN = SCALER_IN_YVYU422; + else + SCALER_IN = SCALER_IN_VYUY422; + + mach64WaitAvail (reg, 4); + + media->VIDEO_FORMAT = SCALER_IN | VIDEO_IN_VYUY422; + + /* color key */ + media->OVERLAY_GRAPHICS_KEY_MSK = (1 << screen->fb[0].depth) - 1; + media->OVERLAY_GRAPHICS_KEY_CLR = pPortPriv->colorKey; + /* set key control to obey only graphics color key */ + media->OVERLAY_KEY_CNTL = 0x50; + + mach64WaitAvail (reg, 9); + media->CAPTURE_DEBUG = 0; + /* no exclusive video region */ + media->OVERLAY_EXCLUSIVE_HORZ = 0; + media->OVERLAY_EXCLUSIVE_VERT = 0; + /* scaling coefficients */ + media->SCALER_H_COEFF0 = 0x00002000; + media->SCALER_H_COEFF1 = 0x0D06200D; + media->SCALER_H_COEFF2 = 0x0D0A1C0D; + media->SCALER_H_COEFF3 = 0x0C0E1A0C; + media->SCALER_H_COEFF4 = 0x0C14140C; + media->SCALER_TEST = 0; + + mach64WaitAvail (reg, 2); + media->OVERLAY_SCALE_CNTL = (SCALE_PIX_EXPAND | + SCALE_GAMMA_BRIGHT | + SCALE_BANDWIDTH | + SCALE_OVERLAY_EN | + SCALE_EN); + + bright = (pPortPriv->brightness * 64 / 1000); + if (bright < -0x40) + bright = -0x40; + if (bright > 0x3f) + bright = 0x3f; + bright = bright & 0x7f; + sat = ((pPortPriv->saturation * 31 + 31000) / 2000); + if (sat > 0x1f) + sat = 0x1f; + if (sat < 0) + sat = 0; + + media->SCALER_COLOUR_CNTL = ((bright << 0) | /* BRIGHTNESS */ + (sat << 8) | /* SATURATION_U */ + (sat << 16) | /* SATURATION_V */ + (0 << 21) | /* SCALER_VERT_ADJ_UV */ + (0 << 28)); /* SCALER_HORZ_ADJ_UV */ + + VERT_INC = (src_h << 12) / drw_h; + HORZ_INC = (src_w << 12) / drw_w; + + mach64WaitAvail (reg, 13); + + /* lock registers to prevent non-atomic update */ + media->OVERLAY_Y_X_START = 0x80000000 | MACH64_YX (dst_x1, dst_y1); + /* ending screen coordinate */ + media->OVERLAY_Y_X_END = 0x80000000 | MACH64_YX (dst_x2, dst_y2); + + media->OVERLAY_SCALE_INC = MACH64_YX(HORZ_INC, VERT_INC); + + media->SCALER_BUF0_OFFSET = pPortPriv->YBuf0Offset; + media->SCALER_BUF1_OFFSET = pPortPriv->YBuf1Offset; + + media->SCALER_BUF0_OFFSET_U = pPortPriv->YBuf0Offset; + media->SCALER_BUF1_OFFSET_U = pPortPriv->YBuf1Offset; + + media->SCALER_BUF0_OFFSET_V = pPortPriv->YBuf0Offset; + media->SCALER_BUF1_OFFSET_V = pPortPriv->YBuf1Offset; + + media->SCALER_BUF_PITCH = dstPitch >> 1; + media->SCALER_HEIGHT_WIDTH = MACH64_YX(src_w - (x1 >> 16), src_h - (y1 >> 16)); + + media->CAPTURE_CONFIG = pPortPriv->currentBuf << 28; + + /* set XY location and unlock */ + media->OVERLAY_Y_X_START = MACH64_YX (dst_x1, dst_y1); +} + +static int +mach64PutImage(KdScreenInfo *screen, + short src_x, + short src_y, + short drw_x, + short drw_y, + short src_w, + short src_h, + short drw_w, + short drw_h, + int id, + unsigned char *buf, + short width, + short height, + Bool sync, + RegionPtr clipBoxes, + pointer data) +{ + KdCardInfo *card = screen->card; + Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; + Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; + Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data; + Reg *reg = mach64c->reg; + MediaReg *media = mach64c->media_reg; + INT32 x1, x2, y1, y2; + int randr = mach64s->vesa.randr; + int srcPitch, srcPitch2, dstPitch; + int top, left, npixels, nlines, size; + BoxRec dstBox; + int dst_width = width, dst_height = height; + int rot_x1, rot_y1, rot_x2, rot_y2; + int dst_x1, dst_y1, dst_x2, dst_y2; + int rot_src_w, rot_src_h, rot_drw_w, rot_drw_h; + + /* Clip */ + x1 = src_x; + x2 = src_x + src_w; + y1 = src_y; + y2 = src_y + src_h; + + dstBox.x1 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; + + Mach64ClipVideo(&dstBox, &x1, &x2, &y1, &y2, + REGION_EXTENTS(pScreen, clipBoxes), width, height); + + if((x1 >= x2) || (y1 >= y2)) + return Success; + + if (!media) + return BadAlloc; + + if (randr & (RR_Rotate_0|RR_Rotate_180)) + { + dst_width = width; + dst_height = height; + rot_src_w = src_w; + rot_src_h = src_h; + rot_drw_w = drw_w; + rot_drw_h = drw_h; + } + else + { + dst_width = height; + dst_height = width; + rot_src_w = src_h; + rot_src_h = src_w; + rot_drw_w = drw_h; + rot_drw_h = drw_w; + } + + switch (randr & RR_Rotate_All) { + case RR_Rotate_0: + dst_x1 = dstBox.x1; + dst_y1 = dstBox.y1; + dst_x2 = dstBox.x2; + dst_y2 = dstBox.y2; + rot_x1 = x1; + rot_y1 = y1; + rot_x2 = x2; + rot_y2 = y2; + break; + case RR_Rotate_90: + dst_x1 = dstBox.y1; + dst_y1 = screen->height - dstBox.x2; + dst_x2 = dstBox.y2; + dst_y2 = screen->height - dstBox.x1; + + rot_x1 = y1; + rot_y1 = (src_w << 16) - x2; + rot_x2 = y2; + rot_y2 = (src_w << 16) - x1; + break; + case RR_Rotate_180: + dst_x1 = screen->width - dstBox.x2; + dst_y1 = screen->height - dstBox.y2; + dst_x2 = screen->width - dstBox.x1; + dst_y2 = screen->height - dstBox.y1; + rot_x1 = (src_w << 16) - x2; + rot_y1 = (src_h << 16) - y2; + rot_x2 = (src_w << 16) - x1; + rot_y2 = (src_h << 16) - y1; + break; + case RR_Rotate_270: + dst_x1 = screen->width - dstBox.y2; + dst_y1 = dstBox.x1; + dst_x2 = screen->width - dstBox.y1; + dst_y2 = dstBox.x2; + rot_x1 = (src_h << 16) - y2; + rot_y1 = x1; + rot_x2 = (src_h << 16) - y1; + rot_y2 = x2; + break; + } + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + dstPitch = ((dst_width << 1) + 15) & ~15; + srcPitch = (width + 3) & ~3; + srcPitch2 = ((width >> 1) + 3) & ~3; + size = dstPitch * (int) dst_height; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + dstPitch = ((dst_width << 1) + 15) & ~15; + srcPitch = (width << 1); + size = dstPitch * (int) dst_height; + break; + } + + pPortPriv->offset = mach64s->off_screen - (CARD8 *) mach64s->vesa.fb; + /* fixup pointers */ + + pPortPriv->YBuf0Offset = pPortPriv->offset; + pPortPriv->YBuf1Offset = pPortPriv->offset + size; + +#if 0 + mach64WaitIdle (reg); + + if (pPortPriv->videoOn) + { + /* wait for buffer to be displayed */ + while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf) + ; + } +#endif + /* + * Use the other buffer + */ + pPortPriv->currentBuf = 1 - pPortPriv->currentBuf; + + /* copy data */ + top = rot_y1 >> 16; + left = (rot_x1 >> 16) & ~1; + npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + top &= ~1; + nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top; + mach64CopyPlanarData(screen, buf, randr, + srcPitch, srcPitch2, dstPitch, + rot_src_w, rot_src_h, height, + top, left, nlines, npixels, id); + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + nlines = ((rot_y2 + 0xffff) >> 16) - top; + mach64CopyPackedData(screen, buf, randr, + srcPitch, dstPitch, + rot_src_w, rot_src_h, + top, left, nlines, + npixels); + break; + } + + mach64DisplayVideo(screen, id, dstPitch, + rot_x1, rot_y1, rot_x2, rot_y2, + dst_x1, dst_y1, + dst_x2, dst_y2, + rot_src_w, rot_src_h, rot_drw_w, rot_drw_h); + + /* update cliplist */ + if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes)) + { + REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes); + mach64PaintRegion (screen->pScreen, &pPortPriv->clip, pPortPriv->colorKey); + } + + pPortPriv->videoOn = TRUE; + + return Success; +} + +static int +mach64QueryImageAttributes(KdScreenInfo *screen, + int id, + unsigned short *w, + unsigned short *h, + int *pitches, + int *offsets) +{ + int size, tmp; + + if(*w > IMAGE_MAX_WIDTH) + *w = IMAGE_MAX_WIDTH; + if(*h > IMAGE_MAX_HEIGHT) + *h = IMAGE_MAX_HEIGHT; + + *w = (*w + 1) & ~1; + if(offsets) offsets[0] = 0; + + switch(id) { + case FOURCC_YV12: + case FOURCC_I420: + *h = (*h + 1) & ~1; + size = (*w + 3) & ~3; + if(pitches) + pitches[0] = size; + size *= *h; + if(offsets) + offsets[1] = size; + tmp = ((*w >> 1) + 3) & ~3; + if(pitches) + pitches[1] = pitches[2] = tmp; + tmp *= (*h >> 1); + size += tmp; + if(offsets) + offsets[2] = size; + size += tmp; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + size = *w << 1; + if(pitches) + pitches[0] = size; + size *= *h; + break; + } + + return size; +} + + +/* client libraries expect an encoding */ +static KdVideoEncodingRec DummyEncoding[1] = +{ + { + 0, + "XV_IMAGE", + IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, + {1, 1} + } +}; + +#define NUM_FORMATS 3 + +static KdVideoFormatRec Formats[NUM_FORMATS] = +{ + {15, TrueColor}, {16, TrueColor}, {24, TrueColor} +}; + +#define NUM_ATTRIBUTES 3 + +static KdAttributeRec Attributes[NUM_ATTRIBUTES] = +{ + {XvSettable | XvGettable, 0, ~0, "XV_COLORKEY"}, + {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"}, + {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"} +}; + +#define NUM_IMAGES 4 + +static KdImageRec Images[NUM_IMAGES] = +{ + XVIMAGE_YUY2, + XVIMAGE_YV12, + XVIMAGE_I420, + XVIMAGE_UYVY +}; + +static void mach64ResetVideo(KdScreenInfo *screen) +{ + ScreenPtr pScreen = screen->pScreen; + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; + Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; + Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr; + MediaReg *media = mach64c->media_reg; + + /* + * Default to maximum image size in YV12 + */ + +} + +static int +mach64ReputImage (KdScreenInfo *screen, + short drw_x, + short drw_y, + RegionPtr clipBoxes, + pointer data) +{ + ScreenPtr pScreen = screen->pScreen; + Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data; + BoxPtr pOldExtents = REGION_EXTENTS (pScreen, &pPortPriv->clip); + BoxPtr pNewExtents = REGION_EXTENTS (pScreen, clipBoxes); + + if (pOldExtents->x1 == pNewExtents->x1 && + pOldExtents->x2 == pNewExtents->x2 && + pOldExtents->y1 == pNewExtents->y1 && + pOldExtents->y2 == pNewExtents->y2) + { + /* update cliplist */ + if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes)) + { + REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes); + mach64PaintRegion (screen->pScreen, &pPortPriv->clip, pPortPriv->colorKey); + } + return Success; + } + return BadMatch; +} + +static KdVideoAdaptorPtr +mach64SetupImageVideo(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + mach64CardInfo(pScreenPriv); + mach64ScreenInfo(pScreenPriv); + KdScreenInfo *screen = pScreenPriv->screen; + KdCardInfo *card = pScreenPriv->card; + KdVideoAdaptorPtr adapt; + Mach64PortPrivPtr pPortPriv; + + if(!(adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) + + sizeof(Mach64PortPrivRec) + + sizeof(DevUnion)))) + return NULL; + + adapt->type = XvWindowMask | XvInputMask | XvImageMask; + adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + adapt->name = "Mach64 Video Overlay"; + adapt->nEncodings = 1; + adapt->pEncodings = DummyEncoding; + adapt->nFormats = NUM_FORMATS; + adapt->pFormats = Formats; + adapt->nPorts = 1; + adapt->pPortPrivates = (DevUnion*)(&adapt[1]); + + pPortPriv = (Mach64PortPrivPtr)(&adapt->pPortPrivates[1]); + + adapt->pPortPrivates[0].ptr = (pointer)(pPortPriv); + adapt->pAttributes = Attributes; + adapt->nImages = NUM_IMAGES; + adapt->nAttributes = NUM_ATTRIBUTES; + adapt->pImages = Images; + adapt->PutVideo = NULL; + adapt->PutStill = NULL; + adapt->GetVideo = NULL; + adapt->GetStill = NULL; + adapt->StopVideo = mach64StopVideo; + adapt->SetPortAttribute = mach64SetPortAttribute; + adapt->GetPortAttribute = mach64GetPortAttribute; + adapt->QueryBestSize = mach64QueryBestSize; + adapt->PutImage = mach64PutImage; + adapt->ReputImage = mach64ReputImage; + adapt->QueryImageAttributes = mach64QueryImageAttributes; + + pPortPriv->colorKey = mach64s->colorKey; + pPortPriv->videoOn = FALSE; + pPortPriv->brightness = 0; + pPortPriv->saturation = 0; + pPortPriv->currentBuf = 0; + + /* gotta uninit this someplace */ + REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0); + + mach64s->pAdaptor = adapt; + + xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); + xvSaturation = MAKE_ATOM("XV_SATURATION"); + xvColorKey = MAKE_ATOM("XV_COLORKEY"); + + mach64ResetVideo(screen); + + return adapt; +} + +Bool mach64InitVideo(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL; + KdVideoAdaptorPtr newAdaptor = NULL; + int num_adaptors; + KdCardInfo *card = pScreenPriv->card; + Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver; + Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver; + + if (!mach64c->media_reg) + return FALSE; + + newAdaptor = mach64SetupImageVideo(pScreen); + + num_adaptors = KdXVListGenericAdaptors(screen, &adaptors); + + if(newAdaptor) + { + if(!num_adaptors) + { + num_adaptors = 1; + adaptors = &newAdaptor; + } + else + { + newAdaptors = xalloc((num_adaptors + 1) * + sizeof(KdVideoAdaptorPtr*)); + if(newAdaptors) + { + memcpy(newAdaptors, adaptors, + num_adaptors * sizeof(KdVideoAdaptorPtr)); + newAdaptors[num_adaptors] = newAdaptor; + adaptors = newAdaptors; + num_adaptors++; + } + } + } + + if(num_adaptors) + KdXVScreenInit(pScreen, adaptors, num_adaptors); + + if(newAdaptors) + xfree(newAdaptors); + return TRUE; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/trio/s3.h +++ xorg-server-1.4.99.906/hw/kdrive/trio/s3.h @@ -0,0 +1,1200 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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. + */ + +#ifndef _S3_H_ +#define _S3_H_ + +#include "kdrive.h" + +#define PLATFORM 300 + +#define DRAW_DEBUG(a) + +#define DEBUG_S3INIT (DEBUG_ACCEL) +#define DEBUG_CRTC (DEBUG_ACCEL+1) +#define DEBUG_PATTERN (DEBUG_ACCEL+2) +#define DEBUG_RECT (DEBUG_ACCEL+3) +#define DEBUG_PAINT_WINDOW (DEBUG_ACCEL+4) +#define DEBUG_SET (DEBUG_ACCEL+5) +#define DEBUG_RENDER (DEBUG_ACCEL+6) +#define DEBUG_REGISTERS (DEBUG_ACCEL+7) +#define DEBUG_ARCS (DEBUG_ACCEL+8) +#define DEBUG_TEXT (DEBUG_ACCEL+9) +#define DEBUG_POLYGON (DEBUG_ACCEL+10) +#define DEBUG_CLIP (DEBUG_ACCEL+11) + +/* VESA Approved Register Definitions */ + +/* + * Linear Addressing 000 0000 - 0ff ffff (16m) + * Image data transfer 100 0000 - 100 7fff (32k) + * PCI config 100 8000 - 100 8043 + * Packed enhanced regs 100 8100 - 100 814a + * Streams regs 100 8180 - 100 81ff + * Current Y pos 100 82e8 + * CRT VGA 3b? regs 100 83b0 - 100 83bf + * CRT VGA 3c? regs 100 83c0 - 100 83cf + * CRT VGA 3d? regs 100 83d0 - 100 83df + * Subsystem status (42e8h) 100 8504 + * Advanced function (42e8h) 100 850c + * Enhanced regs 100 86e8 - 100 eeea + * Local peripheral bus 100 ff00 - 100 ff5c + * + * We don't care about the image transfer or PCI regs, so + * this structure starts at the packed enhanced regs + */ + +typedef volatile CARD32 VOL32; +typedef volatile CARD16 VOL16; +typedef volatile CARD8 VOL8; + +typedef volatile struct _s3 { + VOL32 alt_curxy; /* 8100 */ + VOL32 _pad0; /* 8104 */ + VOL32 alt_step; /* 8108 */ + VOL32 _pad1; /* 810c */ + VOL32 err_term; /* 8110 */ + VOL32 _pad2; /* 8114 */ + VOL32 cmd_gp_stat; /* 8118 */ + VOL32 short_stroke; /* 811c */ + VOL32 bg; /* 8120 */ + VOL32 fg; /* 8124 */ + VOL32 write_mask; /* 8128 */ + VOL32 read_mask; /* 812c */ + VOL32 color_cmp; /* 8130 */ + VOL32 alt_mix; /* 8134 */ + VOL32 scissors_tl; /* 8138 */ + VOL32 scissors_br; /* 813c */ + VOL32 pix_cntl_mult_misc2; /* 8140 */ + VOL32 mult_misc_read_sel; /* 8144 */ + VOL32 alt_pcnt; /* 8148 min_axis_pcnt, maj_axis_pcnt */ + VOL8 _pad3[0x19c]; /* 814c */ + VOL16 cur_y; /* 82e8 */ + VOL8 _pad4[0xc6]; /* 82ea */ + + VOL8 crt_vga_3b0; /* 83b0 */ + VOL8 crt_vga_3b1; /* 83b1 */ + VOL8 crt_vga_3b2; /* 83b2 */ + VOL8 crt_vga_3b3; /* 83b3 */ + VOL8 crt_vga_3b4; /* 83b4 */ + VOL8 crt_vga_3b5; /* 83b5 */ + VOL8 crt_vga_3b6; /* 83b6 */ + VOL8 crt_vga_3b7; /* 83b7 */ + VOL8 crt_vga_3b8; /* 83b8 */ + VOL8 crt_vga_3b9; /* 83b9 */ + VOL8 crt_vga_3ba; /* 83ba */ + VOL8 crt_vga_3bb; /* 83bb */ + VOL8 crt_vga_3bc; /* 83bc */ + VOL8 crt_vga_3bd; /* 83bd */ + VOL8 crt_vga_3be; /* 83be */ + VOL8 crt_vga_3bf; /* 83bf */ + + VOL8 crt_vga_3c0; /* 83c0 */ + VOL8 crt_vga_3c1; /* 83c1 */ + VOL8 crt_vga_3c2; /* 83c2 */ + VOL8 crt_vga_3c3; /* 83c3 */ + VOL8 crt_vga_3c4; /* 83c4 */ + VOL8 crt_vga_3c5; /* 83c5 */ + VOL8 crt_vga_dac_ad_mk; /* 83c6 */ + VOL8 crt_vga_dac_rd_ad; /* 83c7 */ + VOL8 crt_vga_dac_wt_ad; /* 83c8 */ + VOL8 crt_vga_dac_data; /* 83c9 */ + VOL8 crt_vga_3ca; /* 83ca */ + VOL8 crt_vga_3cb; /* 83cb */ + VOL8 crt_vga_3cc; /* 83cc */ + VOL8 crt_vga_3cd; /* 83cd */ + VOL8 crt_vga_3ce; /* 83ce */ + VOL8 crt_vga_3cf; /* 83cf */ + + VOL8 crt_vga_3d0; /* 83d0 */ + VOL8 crt_vga_3d1; /* 83d1 */ + VOL8 crt_vga_3d2; /* 83d2 */ + VOL8 crt_vga_3d3; /* 83d3 */ + VOL8 crt_vga_3d4; /* 83d4 */ + VOL8 crt_vga_3d5; /* 83d5 */ + VOL8 crt_vga_3d6; /* 83d6 */ + VOL8 crt_vga_3d7; /* 83d7 */ + VOL8 crt_vga_3d8; /* 83d8 */ + VOL8 crt_vga_3d9; /* 83d9 */ + VOL8 crt_vga_status_1; /* 83da */ + VOL8 crt_vga_3db; /* 83db */ + VOL8 crt_vga_3dc; /* 83dc */ + VOL8 crt_vga_3dd; /* 83dd */ + VOL8 crt_vga_3de; /* 83de */ + VOL8 crt_vga_3df; /* 83df */ + + VOL8 _pad5[0x124]; /* 83e0 */ + VOL16 subsys_status; /* 8504 */ + VOL8 _pad6[0x6]; /* 8506 */ + VOL16 adv_control; /* 850c */ + VOL8 _pad7[0x1da]; /* 850e */ + VOL16 cur_x; /* 86e8 */ + VOL8 _pad8[0x3fe]; /* 86ea */ + VOL16 desty_axstp; /* 8ae8 */ + VOL8 _pad9[0x3fe]; /* 8aea */ + VOL16 destx_diastp; /* 8ee8 */ + VOL8 _pad10[0x3fe]; /* 8eea */ + VOL16 enh_err_term; /* 92e8 */ + VOL8 _pad11[0x3fe]; /* 92ea */ + VOL16 maj_axis_pcnt; /* 96e8 */ + VOL8 _pad12[0x3fe]; /* 96ea */ + VOL16 enh_cmd_gp_stat; /* 9ae8 */ + VOL8 _pad13[0x3fe]; /* 9aea */ + VOL16 enh_short_stroke; /* 9ee8 */ + VOL8 _pad14[0x3fe]; /* 9eea */ + VOL16 enh_bg; /* a2e8 */ + VOL8 _pad15[0x3fe]; /* a2ea */ + VOL16 enh_fg; /* a6e8 */ + VOL8 _pad16[0x3fe]; /* a6ea */ + VOL16 enh_wrt_mask; /* aae8 */ + VOL8 _pad17[0x3fe]; /* aaea */ + VOL16 enh_rd_mask; /* aee8 */ + VOL8 _pad18[0x3fe]; /* aeea */ + VOL16 enh_color_cmp; /* b2e8 */ + VOL8 _pad19[0x3fe]; /* b2ea */ + VOL16 enh_bg_mix; /* b6e8 */ + VOL8 _pad20[0x3fe]; /* b6ea */ + VOL16 enh_fg_mix; /* bae8 */ + VOL8 _pad21[0x3fe]; /* baea */ + VOL16 enh_rd_reg_dt; /* bee8 */ + VOL8 _pad22[0x23fe]; /* beea */ + VOL32 pix_trans; /* e2e8 */ +} S3, *S3Ptr; + +#define VGA_STATUS_1_DTM 0x01 +#define VGA_STATUS_1_VSY 0x08 + +#define DAC_MASK 0x03c6 +#define DAC_R_INDEX 0x03c7 +#define DAC_W_INDEX 0x03c8 +#define DAC_DATA 0x03c9 +#define DISP_STAT 0x02e8 +#define H_TOTAL 0x02e8 +#define H_DISP 0x06e8 +#define H_SYNC_STRT 0x0ae8 +#define H_SYNC_WID 0x0ee8 +#define V_TOTAL 0x12e8 +#define V_DISP 0x16e8 +#define V_SYNC_STRT 0x1ae8 +#define V_SYNC_WID 0x1ee8 +#define DISP_CNTL 0x22e8 +#define ADVFUNC_CNTL 0x4ae8 +#define SUBSYS_STAT 0x42e8 +#define SUBSYS_CNTL 0x42e8 +#define ROM_PAGE_SEL 0x46e8 +#define CUR_Y 0x82e8 +#define CUR_X 0x86e8 +#define DESTY_AXSTP 0x8ae8 +#define DESTX_DIASTP 0x8ee8 +#define ERR_TERM 0x92e8 +#define MAJ_AXIS_PCNT 0x96e8 +#define GP_STAT 0x9ae8 +#define CMD 0x9ae8 +#define SHORT_STROKE 0x9ee8 +#define BKGD_COLOR 0xa2e8 +#define FRGD_COLOR 0xa6e8 +#define WRT_MASK 0xaae8 +#define RD_MASK 0xaee8 +#define COLOR_CMP 0xb2e8 +#define BKGD_MIX 0xb6e8 +#define FRGD_MIX 0xbae8 +#define MULTIFUNC_CNTL 0xbee8 +#define MIN_AXIS_PCNT 0x0000 +#define SCISSORS_T 0x1000 +#define SCISSORS_L 0x2000 +#define SCISSORS_B 0x3000 +#define SCISSORS_R 0x4000 +#define MEM_CNTL 0x5000 +#define PATTERN_L 0x8000 +#define PATTERN_H 0x9000 +#define PIX_CNTL 0xa000 +#define CONTROL_MISC2 0xd000 +#define PIX_TRANS 0xe2e8 + +/* Advanced Function Control Regsiter */ +#define CLKSEL 0x0004 +#define DISABPASSTHRU 0x0001 + +/* Graphics Processor Status Register */ + +#define GPNSLOT 13 + +#define GPBUSY_1 0x0080 +#define GPBUSY_2 0x0040 +#define GPBUSY_3 0x0020 +#define GPBUSY_4 0x0010 +#define GPBUSY_5 0x0008 +#define GPBUSY_6 0x0004 +#define GPBUSY_7 0x0002 +#define GPBUSY_8 0x0001 +#define GPBUSY_9 0x8000 +#define GPBUSY_10 0x4000 +#define GPBUSY_11 0x2000 +#define GPBUSY_12 0x1000 +#define GPBUSY_13 0x0800 + +#define GPEMPTY 0x0400 +#define GPBUSY 0x0200 +#define DATDRDY 0x0100 + +/* Command Register */ +#define CMD_NOP 0x0000 +#define CMD_LINE 0x2000 +#define CMD_RECT 0x4000 +#define CMD_RECTV1 0x6000 +#define CMD_RECTV2 0x8000 +#define CMD_LINEAF 0xa000 +#define CMD_BITBLT 0xc000 +#define CMD_PATBLT 0xe000 +#define CMD_OP_MSK 0xe000 +#define BYTSEQ 0x1000 +#define _32BITNOPAD 0x0600 +#define _32BIT 0x0400 +#define _16BIT 0x0200 +#define _8BIT 0x0000 +#define PCDATA 0x0100 +#define INC_Y 0x0080 +#define YMAJAXIS 0x0040 +#define INC_X 0x0020 +#define DRAW 0x0010 +#define LINETYPE 0x0008 +#define LASTPIX 0x0004 /* Draw last pixel in line */ +#define PLANAR 0x0002 +#define WRTDATA 0x0001 + +/* Background Mix Register */ +#define BSS_BKGDCOL 0x0000 +#define BSS_FRGDCOL 0x0020 +#define BSS_PCDATA 0x0040 +#define BSS_BITBLT 0x0060 + +/* Foreground Mix Register */ +#define FSS_BKGDCOL 0x0000 +#define FSS_FRGDCOL 0x0020 +#define FSS_PCDATA 0x0040 +#define FSS_BITBLT 0x0060 + +/* The Mixes */ +#define MIX_MASK 0x001f + +#define MIX_NOT_DST 0x0000 +#define MIX_0 0x0001 +#define MIX_1 0x0002 +#define MIX_DST 0x0003 +#define MIX_NOT_SRC 0x0004 +#define MIX_XOR 0x0005 +#define MIX_XNOR 0x0006 +#define MIX_SRC 0x0007 +#define MIX_NAND 0x0008 +#define MIX_NOT_SRC_OR_DST 0x0009 +#define MIX_SRC_OR_NOT_DST 0x000a +#define MIX_OR 0x000b +#define MIX_AND 0x000c +#define MIX_SRC_AND_NOT_DST 0x000d +#define MIX_NOT_SRC_AND_DST 0x000e +#define MIX_NOR 0x000f + +#define MIX_MIN 0x0010 +#define MIX_DST_MINUS_SRC 0x0011 +#define MIX_SRC_MINUS_DST 0x0012 +#define MIX_PLUS 0x0013 +#define MIX_MAX 0x0014 +#define MIX_HALF__DST_MINUS_SRC 0x0015 +#define MIX_HALF__SRC_MINUS_DST 0x0016 +#define MIX_AVERAGE 0x0017 +#define MIX_DST_MINUS_SRC_SAT 0x0018 +#define MIX_SRC_MINUS_DST_SAT 0x001a +#define MIX_HALF__DST_MINUS_SRC_SAT 0x001c +#define MIX_HALF__SRC_MINUS_DST_SAT 0x001e +#define MIX_AVERAGE_SAT 0x001f + +/* Pixel Control Register */ +#define MIXSEL_FRGDMIX 0x0000 +#define MIXSEL_PATT 0x0040 +#define MIXSEL_EXPPC 0x0080 +#define MIXSEL_EXPBLT 0x00c0 +#define COLCMPOP_F 0x0000 +#define COLCMPOP_T 0x0008 +#define COLCMPOP_GE 0x0010 +#define COLCMPOP_LT 0x0018 +#define COLCMPOP_NE 0x0020 +#define COLCMPOP_EQ 0x0028 +#define COLCMPOP_LE 0x0030 +#define COLCMPOP_GT 0x0038 +#define PLANEMODE 0x0004 + +#define FIFO_SLOTS 13 + +#define GPSLOT(n) (1 << ((n) > 8 ? (15 - ((n) - 9)) : (8 - (n)))) + +/* Wait for n slots to become available */ +#if 0 +#define _s3WaitSlots(s3,n) { \ + DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitSlots 0x%x %d", (s3)->cmd_gp_stat, n)); \ + while (((s3)->cmd_gp_stat & GPSLOT(n)) != 0); \ + DRAW_DEBUG ((DEBUG_CRTC, " s3 0x%x %d slots ready", (s3)->cmd_gp_stat, n)); \ +} +#else +/* let PCI retries solve this problem */ +#define _s3WaitSlots(s3,n) +#endif + +/* Wait until queue is empty */ +#define _s3WaitEmpty(s3) { \ + DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitEmpty 0x%x", (s3)->cmd_gp_stat)); \ + while (!((s3)->cmd_gp_stat & GPEMPTY)) ; \ + DRAW_DEBUG ((DEBUG_CRTC, " s3 empty")); \ +} + +/* Wait until GP is idle and queue is empty */ +#define _s3WaitIdleEmpty(s3) { \ + DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitIdleEmpty 0x%x", (s3)->cmd_gp_stat)); \ + while (((s3)->cmd_gp_stat & (GPBUSY|GPEMPTY)) != GPEMPTY) ; \ + DRAW_DEBUG ((DEBUG_CRTC, " s3 idle empty")); \ +} + +/* Wait until GP is idle */ +#define _s3WaitIdle(s3) { \ + DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitIdle 0x%x", (s3)->cmd_gp_stat)); \ + while ((s3)->cmd_gp_stat & GPBUSY) ; \ + DRAW_DEBUG ((DEBUG_CRTC, " s3 idle")); \ +} + +typedef struct _s3Cursor { + int width, height; + int xhot, yhot; + Bool has_cursor; + CursorPtr pCursor; + Pixel source, mask; +} S3Cursor; + +typedef struct _s3PatternCache { + int id; + int x, y; +} S3PatternCache; + +typedef struct _s3Patterns { + S3PatternCache *cache; + int ncache; + int last_used; + int last_id; +} S3Patterns; + +typedef struct _crtc { + CARD8 h_total_0_7; /* CR0 */ + CARD8 h_display_end_0_7; /* CR1 */ + CARD8 h_blank_start_0_7; /* CR2 */ + union { + struct { + CARD8 _h_blank_end_0_4 : 5; + CARD8 _display_skew : 2; + CARD8 : 1; + } _h_blank_end_s; + CARD8 __h_blank_end; /* CR3 */ + } _h_blank_end_u; +#define h_blank_end_0_4 _h_blank_end_u._h_blank_end_s._h_blank_end_0_4 +#define display_skew _h_blank_end_u._h_blank_end_s._display_skew +#define _h_blank_end _h_blank_end_u.__h_blank_end + + CARD8 h_sync_start_0_7; /* CR4 */ + + union { + struct { + CARD8 _h_sync_end_0_4 : 5; + CARD8 _horizontal_skew : 2; + CARD8 _h_blank_end_5 : 1; + } _h_sync_end_s; + CARD8 __h_sync_end; /* CR5 */ + } _h_sync_end_u; + +#define h_sync_end_0_4 _h_sync_end_u._h_sync_end_s._h_sync_end_0_4 +#define horizontal_skew _h_sync_end_u._h_sync_end_s._horizontal_skew +#define h_blank_end_5 _h_sync_end_u._h_sync_end_s._h_blank_end_5 +#define _h_sync_end _h_sync_end_u.__h_sync_end + + CARD8 v_total_0_7; /* CR6 */ + + union { + struct { + CARD8 _v_total_8 : 1; + CARD8 _v_display_end_8 : 1; + CARD8 _v_retrace_start_8 : 1; + CARD8 _v_blank_start_8 : 1; + CARD8 _line_compare_8 : 1; + CARD8 _v_total_9 : 1; + CARD8 _v_display_end_9 : 1; + CARD8 _v_retrace_start_9 : 1; + } _crtc_overflow_s; + CARD8 _crtc_overflow; /* CR7 */ + } _crtc_overflow_u; + +#define v_total_8 _crtc_overflow_u._crtc_overflow_s._v_total_8 +#define v_display_end_8 _crtc_overflow_u._crtc_overflow_s._v_display_end_8 +#define v_retrace_start_8 _crtc_overflow_u._crtc_overflow_s._v_retrace_start_8 +#define v_blank_start_8 _crtc_overflow_u._crtc_overflow_s._v_blank_start_8 +#define line_compare_8 _crtc_overflow_u._crtc_overflow_s._line_compare_8 +#define v_total_9 _crtc_overflow_u._crtc_overflow_s._v_total_9 +#define v_display_end_9 _crtc_overflow_u._crtc_overflow_s._v_display_end_9 +#define v_retrace_start_9 _crtc_overflow_u._crtc_overflow_s._v_retrace_start_9 +#define crtc_overflow _crtc_overflow_u._crtc_overflow + + CARD8 preset_row_scan; /* CR8 (unused) */ + + union { + struct { + CARD8 _max_scan_line : 5; + CARD8 _v_blank_start_9 : 1; + CARD8 _line_compare_9 : 1; + CARD8 _double_scan : 1; + } _max_scan_line_s; + CARD8 __max_scan_line; /* CR9 */ + } _max_scan_line_u; + +#define max_scan_line _max_scan_line_u._max_scan_line_s._max_scan_line +#define v_blank_start_9 _max_scan_line_u._max_scan_line_s._v_blank_start_9 +#define line_compare_9 _max_scan_line_u._max_scan_line_s._line_compare_9 +#define double_scan _max_scan_line_u._max_scan_line_s._double_scan +#define _max_scan_line _max_scan_line_u.__max_scan_line + + CARD8 cursor_start; + CARD8 cursor_end; + + CARD8 start_address_8_15; /* CRC */ + CARD8 start_address_0_7; /* CRD */ + + CARD8 cursor_loc_high; + CARD8 cursor_loc_low; + + CARD8 v_retrace_start_0_7; /* CR10 */ + union { + struct { + CARD8 _v_retrace_end_0_3 : 4; + CARD8 _clear_v_retrace_int : 1; + CARD8 _disable_v_retrace_int : 1; + CARD8 _refresh_cycle_select : 1; + CARD8 _lock_crtc : 1; + } _v_retrace_end_s; + CARD8 __v_retrace_end; /* CR11 */ + } _v_retrace_end_u; + +#define v_retrace_end_0_3 _v_retrace_end_u._v_retrace_end_s._v_retrace_end_0_3 +#define clear_v_retrace_int _v_retrace_end_u._v_retrace_end_s._clear_v_retrace_int +#define disable_v_retrace_int _v_retrace_end_u._v_retrace_end_s._disable_v_retrace_int +#define refresh_cycle_select _v_retrace_end_u._v_retrace_end_s._refresh_cycle_select +#define lock_crtc _v_retrace_end_u._v_retrace_end_s._lock_crtc +#define _v_retrace_end _v_retrace_end_u.__v_retrace_end + + CARD8 v_display_end_0_7; /* CR12 */ + + CARD8 screen_off_0_7; /* CR13 */ + + union { + struct { + CARD8 _underline_location : 5; + CARD8 _count_by_four : 1; + CARD8 _doubleword_mode : 1; + CARD8 : 1; + } _underline_location_s; + CARD8 __underline_location; /* CR14 (unused) */ + } _underline_location_u; + +#define underline_location _underline_location_u._underline_location_s._underline_location +#define count_by_four _underline_location_u._underline_location_s._count_by_four +#define doubleword_mode _underline_location_u._underline_location_s._doubleword_mode +#define _underline_location _underline_location_u.__underline_location + + CARD8 v_blank_start_0_7; /* CR15 */ + CARD8 v_blank_end_0_7; /* CR16 */ + + union { + struct { + CARD8 _two_bk_cga : 1; + CARD8 _four_bk_cga : 1; + CARD8 _v_total_double : 1; + CARD8 _word_mode : 1; + CARD8 : 1; + CARD8 _address_wrap : 1; + CARD8 _byte_mode : 1; + CARD8 _hardware_reset : 1; + } _crtc_mode_s; + CARD8 _crtc_mode; /* CR17 (unused) */ + } _crtc_mode_u; + + CARD8 line_compare_0_7; /* CR18 (unused) */ + + union { + struct { + CARD8 _enable_base_offset : 1; + CARD8 _enable_two_page : 1; + CARD8 _enable_vga_16_bit : 1; + CARD8 _enhanced_mode_mapping : 1; + CARD8 _old_display_start : 2; + CARD8 _enable_high_speed_text : 1; + CARD8 : 1; + } _memory_configuration_s; + CARD8 _memory_configuration; /* CR31 (unused) */ + } _memory_configuration_u; + +#define memory_configuration _memory_configuration_u._memory_configuration +#define enable_base_offset _memory_configuration_u._memory_configuration_s._enable_base_offset +#define enable_two_page _memory_configuration_u._memory_configuration_s._enable_two_page +#define enable_vga_16_bit _memory_configuration_u._memory_configuration_s._enable_vga_16_bit +#define enhanved_mode_mapping _memory_configuration_u._memory_configuration_s._enhanced_mode_mapping +#define old_display_start _memory_configuration_u._memory_configuration_s._old_display_start +#define enable_high_speed_text _memory_configuration_u._memory_configuration_s._enable_high_speed_text + + union { + struct { + CARD8 _alt_refresh_count : 2; + CARD8 _enable_alt_refresh : 1; + CARD8 _enable_top_memory : 1; + CARD8 _enable_256_or_more : 1; + CARD8 _high_speed_text : 1; + CARD8 : 1; + CARD8 _pci_burst_disabled : 1; + } _misc_1_s; + CARD8 _misc_1; /* CR3A */ + } _misc_1_u; +#define misc_1 _misc_1_u._misc_1 +#define alt_refresh_count _misc_1_u._misc_1_s._alt_refresh_count +#define enable_alt_refresh _misc_1_u._misc_1_s._enable_alt_refresh +#define enable_top_memory _misc_1_u._misc_1_s._enable_top_memory +#define enable_256_or_more _misc_1_u._misc_1_s._enable_256_or_more +#define high_speed_text _misc_1_u._misc_1_s._high_speed_text +#define pci_burst_disabled _misc_1_u._misc_1_s._pci_burst_disabled + + CARD8 h_start_fifo_fetch_0_7; /* CR3B */ + + union { + struct { + CARD8 : 5; + CARD8 interlace : 1; + CARD8 : 2; + } _mode_control_s; + CARD8 _mode_control; /* CR42 */ + } _mode_control_u; + +#define mode_control _mode_control_u._mode_control + + union { + struct { + CARD8 : 2; + CARD8 _old_screen_off_8 : 1; + CARD8 : 4; + CARD8 h_counter_double_mode : 1; + } _extended_mode_s; + CARD8 _extended_mode; /* CR43 (unused) */ + } _extended_mode_u; + +#define extended_mode _extended_mode_u._extended_mode +#define old_screen_off_8 _extended_mode_u._extended_mode_s._old_screen_off_8 + + union { + struct { + CARD8 _hardware_cursor_enable : 1; + CARD8 : 3; + CARD8 _hardware_cursor_right : 1; + CARD8 : 3; + } _hardware_cursor_mode_s; + CARD8 _hardware_cursor_mode; /* CR45 */ + } _hardware_cursor_mode_u; + +#define hardware_cursor_mode _hardware_cursor_mode_u._hardware_cursor_mode +#define hardware_cursor_enable _hardware_cursor_mode_u._hardware_cursor_mode_s._hardware_cursor_enable + + CARD8 cursor_address_8_15; /* CR4C */ + CARD8 cursor_address_0_7; /* CR4D */ + + union { + struct { + CARD8 _ge_screen_width_2 : 1; + CARD8 : 3; + CARD8 _pixel_length : 2; + CARD8 _ge_screen_width_0_1 : 2; + } _extended_system_control_1_s; + CARD8 _extended_system_control_1; /* CR50 */ + } _extended_system_control_1_u; +#define ge_screen_width_2 _extended_system_control_1_u._extended_system_control_1_s._ge_screen_width_2 +#define pixel_length _extended_system_control_1_u._extended_system_control_1_s._pixel_length +#define ge_screen_width_0_1 _extended_system_control_1_u._extended_system_control_1_s._ge_screen_width_0_1 +#define extended_system_control_1 _extended_system_control_1_u._extended_system_control_1 + + union { + struct { + CARD8 : 4; + CARD8 _screen_off_8_9 : 2; + CARD8 : 2; + } _extended_system_control_2_s; + CARD8 _extended_system_control_2; /* CR51 */ + } _extended_system_control_2_u; +#define extended_system_control_2 _extended_system_control_2_u._extended_system_control_2 +#define screen_off_8_9 _extended_system_control_2_u._extended_system_control_2_s._screen_off_8_9 + + union { + struct { + CARD8 : 1; + CARD8 big_endian_linear : 2; + CARD8 mmio_select : 2; + CARD8 mmio_window : 1; + CARD8 swap_nibbles : 1; + CARD8 : 1; + } _extended_memory_control_s; + CARD8 _extended_memory_control; /* CR53 */ + } _extended_memory_control_u; +#define extended_memory_control _extended_memory_control_u._extended_memory_control + + union { + struct { + CARD8 : 2; + CARD8 _enable_gir : 1; + CARD8 : 1; + CARD8 _hardware_cursor_ms_x11 : 1; + CARD8 : 2; + CARD8 _tri_state_off_vclk : 1; + } _extended_ramdac_control_s; + CARD8 _extended_ramdac_control; /* CR55 */ + } _extended_ramdac_control_u; +#define extended_ramdac_control _extended_ramdac_control_u._extended_ramdac_control +#define hardware_cursor_ms_x11 _extended_ramdac_control_u._extended_ramdac_control_s._hardware_cursor_ms_x11 + + + union { + struct { + CARD8 _h_total_8 : 1; + CARD8 _h_display_end_8 : 1; + CARD8 _h_blank_start_8 : 1; + CARD8 _h_blank_extend : 1; /* extend h_blank by 64 */ + CARD8 _h_sync_start_8 : 1; + CARD8 _h_sync_extend : 1; /* extend h_sync by 32 */ + CARD8 _h_start_fifo_fetch_8 : 1; + CARD8 : 1; + } _extended_horizontal_overflow_s; + CARD8 _extended_horizontal_overflow; /* CR5D */ + } _extended_horizontal_overflow_u; +#define extended_horizontal_overflow _extended_horizontal_overflow_u._extended_horizontal_overflow +#define h_total_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_total_8 +#define h_display_end_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_display_end_8 +#define h_blank_start_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_blank_start_8 +#define h_blank_extend _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_blank_extend +#define h_sync_start_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_sync_start_8 +#define h_sync_extend _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_sync_extend +#define h_start_fifo_fetch_8 _extended_horizontal_overflow_u._extended_horizontal_overflow_s._h_start_fifo_fetch_8 + + + union { + struct { + CARD8 _v_total_10 : 1; + CARD8 _v_display_end_10 : 1; + CARD8 _v_blank_start_10 : 1; + CARD8 : 1; + CARD8 _v_retrace_start_10 : 1; + CARD8 : 1; + CARD8 _line_compare_10 : 1; + CARD8 : 1; + } _extended_vertical_overflow_s; + CARD8 _extended_vertical_overflow; /* CR5E */ + } _extended_vertical_overflow_u; +#define extended_vertical_overflow _extended_vertical_overflow_u._extended_vertical_overflow +#define v_total_10 _extended_vertical_overflow_u._extended_vertical_overflow_s._v_total_10 +#define v_display_end_10 _extended_vertical_overflow_u._extended_vertical_overflow_s._v_display_end_10 +#define v_blank_start_10 _extended_vertical_overflow_u._extended_vertical_overflow_s._v_blank_start_10 +#define v_retrace_start_10 _extended_vertical_overflow_u._extended_vertical_overflow_s._v_retrace_start_10 +#define line_compare_10 _extended_vertical_overflow_u._extended_vertical_overflow_s._line_compare_10 + + + CARD8 l_parm_0_7; /* CR62 (undocumented) */ + + union { + struct { + CARD8 : 3; + CARD8 _delay_blank : 2; + CARD8 : 3; + } _extended_misc_control_s; + CARD8 _extended_misc_control; /* CR65 */ + } _extended_misc_control_u; +#define extended_misc_control _extended_misc_control_u._extended_misc_control +#define delay_blank _extended_misc_control_u._extended_misc_control_s._delay_blank + + union { + struct { + CARD8 _v_clock_phase : 1; + CARD8 : 3; + CARD8 _color_mode : 4; + } _extended_misc_control_2_s; + CARD8 _extended_misc_control_2; /* CR67 */ + } _extended_misc_control_2_u; + +#define v_clock_phase _extended_misc_control_2_u._extended_misc_control_2_s._v_clock_phase +#define color_mode _extended_misc_control_2_u._extended_misc_control_2_s._color_mode +#define extended_misc_control_2 _extended_misc_control_2_u._extended_misc_control_2 + + + union { + struct { + CARD8 cas_oe_str : 2; + CARD8 ras_low : 1; + CARD8 ras_precharge : 1; + CARD8 : 3; + CARD8 _memory_bus_size : 1; /* 0 = 32, 1 = 32/64 */ + } _configuration_3_s; + CARD8 _configuration_3; /* CR68 */ + } _configuration_3_u; +#define configuration_3 _configuration_3_u._configuration_3 +#define memory_bus_size _configuration_3_u._configuration_3_s._memory_bus_size + + union { + struct { + CARD8 _start_address_16_19 : 4; + CARD8 : 4; + } _extended_system_control_3_s; + CARD8 _extended_system_control_3; /* CR69 */ + } _extended_system_control_3_u; +#define extended_system_control_3 _extended_system_control_3_u._extended_system_control_3 +#define start_address_16_19 _extended_system_control_3_u._extended_system_control_3_s._start_address_16_19 + + CARD8 extended_bios_5; /* CR6D */ + + union { + struct { + CARD8 dot_clock_vclki : 1; /* testing only */ + CARD8 vclki_with_vafc : 1; /* feature connector */ + CARD8 : 1; + CARD8 bpp_24_mode : 1; /* 24 bpp mode */ + CARD8 alt_color_mode : 4; /* feature connector mode */ + } _extended_sequencer_b_s; + CARD8 _extended_sequencer_b; /* SRB */ + } _extended_sequencer_b_u; + +#define extended_sequencer_b _extended_sequencer_b_u._extended_sequencer_b + + union extended_sequencer_d_u { + struct { + CARD8 enable_feature : 1; + CARD8 lpb_feature : 1; + CARD8 : 2; + CARD8 _hsync_control : 2; + CARD8 _vsync_control : 2; + } _extended_sequencer_d_s; + CARD8 _extended_sequencer_d; + } _extended_sequencer_d_u; + +#define extended_sequencer_d _extended_sequencer_d_u._extended_sequencer_d +#define hsync_control _extended_sequencer_d_u._extended_sequencer_d_s._hsync_control +#define vsync_control _extended_sequencer_d_u._extended_sequencer_d_s._vsync_control + + union { + struct { + CARD8 _dclk_pll_n : 5; + CARD8 _dclk_pll_r : 2; + CARD8 : 1; + } _dclk_value_low_s; + CARD8 _dclk_value_low; /* SR12 */ + } _dclk_value_low_u; + +#define dclk_value_low _dclk_value_low_u._dclk_value_low +#define dclk_pll_n_trio _dclk_value_low_u._dclk_value_low_s._dclk_pll_n +#define dclk_pll_r_trio _dclk_value_low_u._dclk_value_low_s._dclk_pll_r + + union { + struct { + CARD8 _dclk_pll_m : 7; + CARD8 : 1; + } _dclk_value_high_s; + CARD8 _dclk_value_high; /* SR13 */ + } _dclk_value_high_u; + +#define dclk_value_high _dclk_value_high_u._dclk_value_high +#define dclk_pll_m_trio _dclk_value_high_u._dclk_value_high_s._dclk_pll_m + + union { + struct { + CARD8 _mfrq_en : 1; + CARD8 _dfrq_en : 1; + CARD8 _mclk_out : 1; + CARD8 _vclk_out : 1; + CARD8 _dclk_over_2 : 1; + CARD8 _clk_load : 1; + CARD8 _dclk_invert : 1; + CARD8 _ena_2_cycle_write : 1; + } _control_2_s; + CARD8 _control_2; /* SR15 */ + } _control_2_u; + +#define control_2 _control_2_u._control_2 +#define mfrq_en _control_2_u._control_2_s._mfrq_en +#define dfrq_en _control_2_u._control_2_s._dfrq_en +#define mclk_out _control_2_u._control_2_s._mclk_out +#define vclk_out _control_2_u._control_2_s._vclk_out +#define dclk_over_2 _control_2_u._control_2_s._dclk_over_2 +#define clk_load _control_2_u._control_2_s._clk_load +#define dclk_invert _control_2_u._control_2_s._dclk_invert +#define ena_2_cycle_write _control_2_u._control_2_s._ena_2_cycle_write + + union { + struct { + CARD8 : 5; + CARD8 _dac_power_down : 1; + CARD8 _lut_write_control : 1; + CARD8 _enable_clock_double : 1; + } _ramdac_control_s; + CARD8 _ramdac_control; /* SR18 */ + } _ramdac_control_u; + +#define ramdac_control _ramdac_control_u._ramdac_control +#define enable_clock_double _ramdac_control_u._ramdac_control_s._enable_clock_double + + union { + struct { + CARD8 _dclk_pll_n : 6; + CARD8 _dclk_pll_r : 2; + } _dclk_value_low_s; + CARD8 _dclk_value_low; /* SR36 */ + } _dclk_value_low_savage_u; + +#define dclk_value_low_savage _dclk_value_low_savage_u._dclk_value_low +#define dclk_pll_n_savage_0_5 _dclk_value_low_savage_u._dclk_value_low_s._dclk_pll_n +#define dclk_pll_r_savage_0_1 _dclk_value_low_savage_u._dclk_value_low_s._dclk_pll_r + + CARD8 dclk_pll_m0_savage_0_7; /* SR37 */ + CARD8 dclk_pll_m1_savage_0_7; /* SR38 */ + + struct { + CARD8 _dclk_pll_m : 8; + } _dclk_value_high_s_savage; + + union { + struct { + CARD8 _dclk_select : 1; + CARD8 : 1; + CARD8 _dclk_pll_r_2 : 1; + CARD8 _dclk_pll_m_8 : 1; + CARD8 _dclk_pll_n_6 : 1; + CARD8 _pce : 1; + CARD8 _ccg : 1; + CARD8 _csp : 1; + } _extended_seq_39_s; + CARD8 _extended_seq_39; /* SR39 */ + } _extended_seq_39_u; + +#define extended_seq_39 _extended_seq_39_u._extended_seq_39 +#define dclk_pll_select_savage _extended_seq_39_u._extended_seq_39_s._dclk_select +#define dclk_pll_r_savage_2 _extended_seq_39_u._extended_seq_39_s._dclk_pll_r_2 +#define dclk_pll_m_savage_8 _extended_seq_39_u._extended_seq_39_s._dclk_pll_m_8 +#define dclk_pll_n_savage_6 _extended_seq_39_u._extended_seq_39_s._dclk_pll_n_6 + + /* computed values */ + CARD16 ge_screen_pitch; + CARD8 bits_per_pixel; + CARD8 depth; + CARD8 double_pixel_mode; + CARD16 pixel_width; +} S3Crtc; + +#define crtc_v_total(crtc) ((crtc)->v_total_0_7 | \ + ((crtc)->v_total_8 << 8) | \ + ((crtc)->v_total_9 << 9) | \ + ((crtc)->v_total_10 << 10)) + +#define crtc_set_v_total(crtc,v) { \ + ((crtc))->v_total_0_7 = (v); \ + ((crtc))->v_total_8 = (v) >> 8; \ + ((crtc))->v_total_9 = (v) >> 9; \ + ((crtc))->v_total_10 = (v) >> 10; \ +} + +#define crtc_v_display_end(crtc) ((crtc)->v_display_end_0_7 | \ + ((crtc)->v_display_end_8 << 8) | \ + ((crtc)->v_display_end_9 << 9) | \ + ((crtc)->v_display_end_10 << 10)) + +#define crtc_set_v_display_end(crtc,v) {\ + ((crtc))->v_display_end_0_7 = (v); \ + ((crtc))->v_display_end_8 = (v) >> 8; \ + ((crtc))->v_display_end_9 = (v) >> 9; \ + ((crtc))->v_display_end_10 = (v) >> 10; \ +} + +#define crtc_v_retrace_start(crtc) ((crtc)->v_retrace_start_0_7 | \ + ((crtc)->v_retrace_start_8 << 8) | \ + ((crtc)->v_retrace_start_9 << 9) | \ + ((crtc)->v_retrace_start_10 << 10)) + +#define crtc_set_v_retrace_start(crtc,v) {\ + ((crtc))->v_retrace_start_0_7 = (v); \ + ((crtc))->v_retrace_start_8 = (v) >> 8; \ + ((crtc))->v_retrace_start_9 = (v) >> 9; \ + ((crtc))->v_retrace_start_10 = (v) >> 10; \ +} + +#define crtc_v_blank_start(crtc) ((crtc)->v_blank_start_0_7 | \ + ((crtc)->v_blank_start_8 << 8) | \ + ((crtc)->v_blank_start_9 << 9) | \ + ((crtc)->v_blank_start_10 << 10)) + +#define crtc_set_v_blank_start(crtc,v) {\ + ((crtc))->v_blank_start_0_7 = (v); \ + ((crtc))->v_blank_start_8 = (v) >> 8; \ + ((crtc))->v_blank_start_9 = (v) >> 9; \ + ((crtc))->v_blank_start_10 = (v) >> 10; \ +} + +#define crtc_h_total(crtc) ((crtc)->h_total_0_7 | \ + ((crtc)->h_total_8 << 8)) + +#define crtc_set_h_total(crtc,v) {\ + ((crtc))->h_total_0_7 = (v); \ + ((crtc))->h_total_8 = (v) >> 8; \ +} + +#define crtc_h_display_end(crtc) ((crtc)->h_display_end_0_7 | \ + ((crtc)->h_display_end_8 << 8)) + +#define crtc_set_h_display_end(crtc,v) {\ + ((crtc))->h_display_end_0_7 = (v); \ + ((crtc))->h_display_end_8 = (v) >> 8; \ +} + +#define crtc_h_blank_start(crtc) ((crtc)->h_blank_start_0_7 | \ + ((crtc)->h_blank_start_8 << 8)) + +#define crtc_set_h_blank_start(crtc,v) {\ + ((crtc))->h_blank_start_0_7 = (v); \ + ((crtc))->h_blank_start_8 = (v) >> 8; \ +} + +#define crtc_h_blank_end(crtc) ((crtc)->h_blank_end_0_4 | \ + ((crtc)->h_blank_end_5 << 5)) + +#define crtc_set_h_blank_end(crtc,v) {\ + ((crtc))->h_blank_end_0_4 = (v); \ + ((crtc))->h_blank_end_5 = (v) >> 5; \ +} + +#define crtc_h_sync_start(crtc) ((crtc)->h_sync_start_0_7 | \ + ((crtc)->h_sync_start_8 << 8)) + +#define crtc_set_h_sync_start(crtc,v) {\ + ((crtc))->h_sync_start_0_7 = (v); \ + ((crtc))->h_sync_start_8 = (v) >> 8; \ +} + +#define crtc_h_sync_end(crtc) ((crtc)->h_sync_end_0_4) + +#define crtc_set_h_sync_end(crtc,v) {\ + ((crtc))->h_sync_end_0_4 = (v); \ +} + +#define crtc_screen_off(crtc) ((crtc)->screen_off_0_7 | \ + (((crtc)->screen_off_8_9 ? \ + ((crtc))->screen_off_8_9 : \ + ((crtc))->old_screen_off_8) << 8)) + +#define crtc_set_screen_off(crtc,v) {\ + ((crtc))->screen_off_0_7 = (v); \ + ((crtc))->old_screen_off_8 = 0; \ + ((crtc))->screen_off_8_9 = (v) >> 8; \ +} + +#define crtc_ge_screen_width(crtc) ((crtc)->ge_screen_width_0_1 | \ + ((crtc)->ge_screen_width_2 << 2)) + +#define crtc_set_ge_screen_width(crtc,v) { \ + (crtc)->ge_screen_width_0_1 = (v); \ + (crtc)->ge_screen_width_2 = (v) >> 2; \ +} + +#define crtc_h_start_fifo_fetch(crtc) ((crtc)->h_start_fifo_fetch_0_7 | \ + ((crtc)->h_start_fifo_fetch_8 << 8)) + +#define crtc_set_h_start_fifo_fetch(crtc,v) {\ + (crtc)->h_start_fifo_fetch_0_7 = (v); \ + (crtc)->h_start_fifo_fetch_8 = (v) >> 8; \ +} + +#define crtc_start_address(crtc) ((crtc)->start_address_0_7 | \ + ((crtc)->start_address_8_15 << 8) | \ + ((crtc)->start_address_16_19 << 16)) + +#define crtc_set_start_address(crtc,v) {\ + (crtc)->start_address_0_7 = (v); \ + (crtc)->start_address_8_15 = (v) >> 8; \ + (crtc)->start_address_16_19 = (v) >> 16; \ +} + +#define crtc_line_compare(crtc) ((crtc)->line_compare_0_7 | \ + ((crtc)->line_compare_8 << 8) | \ + ((crtc)->line_compare_9 << 9) | \ + ((crtc)->line_compare_10 << 10)) + +#define crtc_set_line_compare(crtc,v) { \ + ((crtc))->line_compare_0_7 = (v); \ + ((crtc))->line_compare_8 = (v) >> 8; \ + ((crtc))->line_compare_9 = (v) >> 9; \ + ((crtc))->line_compare_10 = (v) >> 10; \ +} + + +#define GetCrtc(s3,i) _s3ReadIndexRegister (&(s3)->crt_vga_3d4, (i)) +#define PutCrtc(s3,i,v) _s3WriteIndexRegister (&(s3)->crt_vga_3d4, (i), (v)) + +#define GetSrtc(s3,i) _s3ReadIndexRegister (&(s3)->crt_vga_3c4, (i)) +#define PutSrtc(s3,i,v) _s3WriteIndexRegister (&(s3)->crt_vga_3c4, (i), (v)) + +#define S3_CLOCK_REF 14318 /* KHz */ + +#define S3_CLOCK(m,n,r) (S3_CLOCK_REF * ((m) + 2) / (((n) + 2) * (1 << (r)))) + +#if PLATFORM == 200 +#define S3_MAX_CLOCK 80000 /* KHz */ +#endif +#if PLATFORM == 300 +#define S3_MAX_CLOCK 135000 /* KHz */ +#endif + +typedef struct _s3Save { + CARD8 cursor_fg; + CARD8 cursor_bg; + CARD8 lock1; + CARD8 lock2; + CARD8 locksrtc; + CARD8 clock_mode; + CARD32 alt_mix; + CARD32 write_mask; + CARD32 fg; + CARD32 bg; + S3Crtc crtc; +} S3Save; + +typedef struct _s3CardInfo { + S3Ptr s3; /* pointer to register structure */ + int memory; /* amount of memory */ + CARD8 *frameBuffer; /* pointer to frame buffer */ + CARD8 *registers; /* pointer to register map */ + S3Save save; + Bool savage; + Bool need_sync; +} S3CardInfo; + +typedef struct _s3FbInfo { + CARD8 *offscreen; /* pointer to offscreen area */ + int offscreen_y; /* top y coordinate of offscreen area */ + int offscreen_x; /* top x coordinate of offscreen area */ + int offscreen_width; /* width of offscreen area */ + int offscreen_height; /* height of offscreen area */ + S3Patterns patterns; + CARD32 bitmap_offset; + int accel_stride; + int accel_bpp; +} S3FBInfo; + +typedef struct _s3ScreenInfo { + CARD8 *cursor_base; /* pointer to cursor area */ + S3Cursor cursor; + S3FBInfo fb[1]; +} S3ScreenInfo; + +#define LockS3(s3c) +#define UnlockS3(s3c) + +#define getS3CardInfo(kd) ((S3CardInfo *) ((kd)->card->driver)) +#define s3CardInfo(kd) S3CardInfo *s3c = getS3CardInfo(kd) + +#define getS3ScreenInfo(kd) ((S3ScreenInfo *) ((kd)->screen->driver)) +#define s3ScreenInfo(kd) S3ScreenInfo *s3s = getS3ScreenInfo(kd) + +Bool s3CardInit (KdCardInfo *); +Bool s3ScreenInit (KdScreenInfo *); +Bool s3Enable (ScreenPtr pScreen); +void s3Disable (ScreenPtr pScreen); +void s3Fini (ScreenPtr pScreen); + +Bool s3CursorInit (ScreenPtr pScreen); +void s3CursorEnable (ScreenPtr pScreen); +void s3CursorDisable (ScreenPtr pScreen); +void s3CursorFini (ScreenPtr pScreen); +void s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs); + +Bool s3DrawInit (ScreenPtr pScreen); +void s3DrawEnable (ScreenPtr pScreen); +void s3DrawSync (ScreenPtr pScreen); +void s3DrawDisable (ScreenPtr pScreen); +void s3DrawFini (ScreenPtr pScreen); + +void s3GetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); +void s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); + +void S3InitCard (KdCardAttr *attr); + +void s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR); + +CARD8 _s3ReadIndexRegister (VOL8 *base, CARD8 index); +void _s3WriteIndexRegister (VOL8 *base, CARD8 index, CARD8 value); + +extern KdCardFuncs s3Funcs; + +/* + * Wait for the begining of the retrace interval + */ + +#define S3_RETRACE_LOOP_CHECK if (++_loop_count > 300000) {\ + DRAW_DEBUG ((DEBUG_FAILURE, "S3 wait loop failed at %s:%d", \ + __FILE__, __LINE__)); \ + break; \ +} + +#define _s3WaitVRetrace(s3) { \ + VOL8 *_status = &s3->crt_vga_status_1; \ + int _loop_count; \ + DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitVRetrace 0x%x", *_status)); \ + _loop_count = 0; \ + while ((*_status & VGA_STATUS_1_VSY) != 0) S3_RETRACE_LOOP_CHECK; \ + _loop_count = 0; \ + while ((*_status & VGA_STATUS_1_VSY) == 0) S3_RETRACE_LOOP_CHECK; \ +} +/* + * Wait for the begining of the retrace interval + */ +#define _s3WaitVRetraceEnd(s3) { \ + VOL8 *_status = &s3->crt_vga_status_1; \ + int _loop_count; \ + DRAW_DEBUG ((DEBUG_CRTC, "_s3WaitVRetraceEnd 0x%x", *_status)); \ + _loop_count = 0; \ + while ((*_status & VGA_STATUS_1_VSY) == 0) S3_RETRACE_LOOP_CHECK; \ + _loop_count = 0; \ + while ((*_status & VGA_STATUS_1_VSY) != 0) S3_RETRACE_LOOP_CHECK; \ +} + +/* + * This extension register must contain a magic bit pattern to enable + * the remaining extended registers + */ + +#define _s3UnlockExt(s3) _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x39, 0xa0) +#define _s3LockExt(s3) _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x39, 0x00) + +#define S3_CURSOR_WIDTH 64 +#define S3_CURSOR_HEIGHT 64 +#define S3_CURSOR_SIZE ((S3_CURSOR_WIDTH * S3_CURSOR_HEIGHT + 7) / 8) + +#define S3_TILE_SIZE 8 + +#endif /* _S3_H_ */ --- xorg-server-1.4.99.906.orig/hw/kdrive/trio/s3clock.c +++ xorg-server-1.4.99.906/hw/kdrive/trio/s3clock.c @@ -0,0 +1,85 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "s3.h" + +/* + * Clock synthesis: + * + * f_out = f_ref * ((M + 2) / ((N + 2) * (1 << R))) + * + * Constraints: + * + * 1. 135MHz <= f_ref * ((M + 2) / (N + 2)) <= 270 MHz + * 2. N >= 1 + * + * Vertical refresh rate = clock / ((hsize + hblank) * (vsize + vblank)) + * Horizontal refresh rate = clock / (hsize + hblank) + */ + +/* all in kHz */ +#define MIN_VCO 180000.0 +#define MAX_VCO 360000.0 + +void +s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR) +{ + int M, N, R, bestM, bestN; + int f_vco, f_out; + int err, abserr, besterr; + + /* + * Compute correct R value to keep VCO in range + */ + for (R = 0; R <= maxR; R++) + { + f_vco = target * (1 << R); + if (MIN_VCO <= f_vco && f_vco < MAX_VCO) + break; + } + + /* M = f_out / f_ref * ((N + 2) * (1 << R)); */ + besterr = target; + for (N = 0; N <= maxN; N++) + { + M = (target * (N + 2) * (1 << R) + (S3_CLOCK_REF/2)) / S3_CLOCK_REF - 2; + if (0 <= M && M <= maxM) + { + f_out = S3_CLOCK(M,N,R); + err = target - f_out; + if (err < 0) + err = -err; + if (err < besterr) + { + besterr = err; + bestM = M; + bestN = N; + } + } + } + *Mp = bestM; + *Np = bestN; + *Rp = R; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/trio/s3cmap.c +++ xorg-server-1.4.99.906/hw/kdrive/trio/s3cmap.c @@ -0,0 +1,70 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "s3.h" + +void +s3GetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) +{ + KdScreenPriv(pScreen); + s3CardInfo(pScreenPriv); + S3Ptr s3 = s3c->s3; + VOL8 *dac_rd_ad = &s3->crt_vga_dac_rd_ad; + VOL8 *dac_data = &s3->crt_vga_dac_data; + + LockS3 (s3c); + while (ndef--) + { + *dac_rd_ad = pdefs->pixel; + pdefs->red = *dac_data << 10; + pdefs->green = *dac_data << 10; + pdefs->blue = *dac_data << 10; + pdefs++; + } + UnlockS3(s3c); +} + +void +s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) +{ + KdScreenPriv(pScreen); + s3CardInfo(pScreenPriv); + S3Ptr s3 = s3c->s3; + VOL8 *dac_wt_ad = &s3->crt_vga_dac_wt_ad; + VOL8 *dac_data = &s3->crt_vga_dac_data; + + LockS3(s3c); + _s3WaitVRetrace (s3); + while (ndef--) + { + *dac_wt_ad = pdefs->pixel; + *dac_data = pdefs->red >> 10; + *dac_data = pdefs->green >> 10; + *dac_data = pdefs->blue >> 10; + pdefs++; + } + UnlockS3(s3c); +} + --- xorg-server-1.4.99.906.orig/hw/kdrive/trio/s3curs.c +++ xorg-server-1.4.99.906/hw/kdrive/trio/s3curs.c @@ -0,0 +1,408 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "s3.h" +#include "s3draw.h" +#include "cursorstr.h" + +#define SetupCursor(s) KdScreenPriv(s); \ + s3CardInfo(pScreenPriv); \ + s3ScreenInfo(pScreenPriv); \ + S3Ptr s3 = s3c->s3; \ + S3Cursor *pCurPriv = &s3s->cursor + +static void +_s3MoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CARD8 xlow, xhigh, ylow, yhigh; + CARD8 xoff, yoff; + + x -= pCurPriv->xhot; + xoff = 0; + if (x < 0) + { + xoff = -x; + x = 0; + } + y -= pCurPriv->yhot; + yoff = 0; + if (y < 0) + { + yoff = -y; + y = 0; + } + xlow = (CARD8) x; + xhigh = (CARD8) (x >> 8); + ylow = (CARD8) y; + yhigh = (CARD8) (y >> 8); + + + /* This is the recommended order to move the cursor */ + + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x46, xhigh); + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x47, xlow); + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x49, ylow); + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4e, xoff); + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4f, yoff); + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x48, yhigh); +} + +static void +s3MoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor (pScreen); + + if (!pCurPriv->has_cursor) + return; + + if (!pScreenPriv->enabled) + return; + + LockS3(s3c); + _s3UnlockExt(s3); + _s3MoveCursor (pScreen, x, y); + _s3LockExt(s3); + UnlockS3(s3c); +} + +static void +s3AllocCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + xColorItem sourceColor, maskColor; + + KdAllocateCursorPixels (pScreen, 0, pCursor, + &pCurPriv->source, &pCurPriv->mask); + switch (pScreenPriv->screen->fb[0].bitsPerPixel) { + case 4: + pCurPriv->source |= pCurPriv->source << 4; + pCurPriv->mask |= pCurPriv->mask << 4; + case 8: + pCurPriv->source |= pCurPriv->source << 8; + pCurPriv->mask |= pCurPriv->mask << 8; + case 16: + pCurPriv->source |= pCurPriv->source << 16; + pCurPriv->mask |= pCurPriv->mask << 16; + } +} + +static void +_s3SetCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + /* set foreground */ + /* Reset cursor color stack pointers */ + (void) _s3ReadIndexRegister(&s3->crt_vga_3d4, 0x45); + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4a, pCurPriv->source); + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4a, pCurPriv->source >> 8); + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4a, pCurPriv->source >> 16); + + /* set background */ + /* Reset cursor color stack pointers */ + (void) _s3ReadIndexRegister(&s3->crt_vga_3d4, 0x45); + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4b, pCurPriv->mask); + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4b, pCurPriv->mask >> 8); + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x4b, pCurPriv->mask >> 16); +} + +void +s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + xColorItem sourceColor, maskColor; + + if (!pCurPriv->has_cursor || !pCursor) + return; + + if (!pScreenPriv->enabled) + return; + + if (pdef) + { + while (ndef) + { + if (pdef->pixel == pCurPriv->source || + pdef->pixel == pCurPriv->mask) + break; + ndef--; + } + if (!ndef) + return; + } + s3AllocCursorColors (pScreen); + LockS3 (s3c); + _s3UnlockExt(s3); + _s3SetCursorColors (pScreen); + _s3LockExt (s3); + UnlockS3 (s3c); +} + +static void +s3LoadCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + CursorBitsPtr bits = pCursor->bits; + int w, h; + unsigned char r[2], g[2], b[2]; + unsigned long *ram; + unsigned long *msk, *mskLine, *src, *srcLine; + unsigned long and, xor; + int i, j; + int cursor_address; + int wsrc; + unsigned char ramdac_control_; + + /* + * Allocate new colors + */ + s3AllocCursorColors (pScreen); + + pCurPriv->pCursor = pCursor; + pCurPriv->xhot = pCursor->bits->xhot; + pCurPriv->yhot = pCursor->bits->yhot; + + /* + * Stick new image into cursor memory + */ + ram = (unsigned long *) s3s->cursor_base; + mskLine = (unsigned long *) bits->mask; + srcLine = (unsigned long *) bits->source; + + h = bits->height; + if (h > S3_CURSOR_HEIGHT) + h = S3_CURSOR_HEIGHT; + + wsrc = BitmapBytePad(bits->width) / 4; /* ulongs per line */ + + for (i = 0; i < S3_CURSOR_HEIGHT; i++) + { + msk = mskLine; + src = srcLine; + mskLine += wsrc; + srcLine += wsrc; + for (j = 0; j < S3_CURSOR_WIDTH / 32; j++) { + + unsigned long m, s; + + if (i < h && j < wsrc) + { + m = *msk++; + s = *src++; + xor = m & s; + and = ~m; + } + else + { + and = 0xffffffff; + xor = 0x00000000; + } + + S3AdjustBits32(and); + S3AdjustBits32(xor); + *ram++ = (and & 0xffff) | (xor << 16); + *ram++ = (and >> 16) | (xor & 0xffff0000); + } + } + + _s3WaitIdle (s3); + _s3UnlockExt (s3); + + /* Set new color */ + _s3SetCursorColors (pScreen); + + /* Enable the cursor */ + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x45, 0x01); + + /* Wait for VRetrace to make sure the position is read */ + _s3WaitVRetrace (s3); + + /* Move to new position */ + _s3MoveCursor (pScreen, x, y); + + _s3LockExt (s3); + UnlockS3(s3c); +} + +static void +s3UnloadCursor (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + LockS3 (s3c); + _s3UnlockExt(s3); + + /* Disable cursor */ + _s3WriteIndexRegister (&s3->crt_vga_3d4, 0x45, 0); + + _s3LockExt(s3); + UnlockS3 (s3c); +} + +static Bool +s3RealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + SetupCursor(pScreen); + + if (!pScreenPriv->enabled) + return TRUE; + + /* miRecolorCursor does this */ + if (pCurPriv->pCursor == pCursor) + { + if (pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + s3LoadCursor (pScreen, x, y); + } + } + return TRUE; +} + +static Bool +s3UnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + return TRUE; +} + +static void +s3SetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +{ + SetupCursor(pScreen); + + pCurPriv->pCursor = pCursor; + + if (!pScreenPriv->enabled) + return; + + if (pCursor) + s3LoadCursor (pScreen, x, y); + else + s3UnloadCursor (pScreen); +} + +miPointerSpriteFuncRec s3PointerSpriteFuncs = { + s3RealizeCursor, + s3UnrealizeCursor, + s3SetCursor, + s3MoveCursor, +}; + +static void +s3QueryBestSize (int class, + unsigned short *pwidth, unsigned short *pheight, + ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + switch (class) + { + case CursorShape: + if (*pwidth > pCurPriv->width) + *pwidth = pCurPriv->width; + if (*pheight > pCurPriv->height) + *pheight = pCurPriv->height; + if (*pwidth > pScreen->width) + *pwidth = pScreen->width; + if (*pheight > pScreen->height) + *pheight = pScreen->height; + break; + default: + fbQueryBestSize (class, pwidth, pheight, pScreen); + break; + } +} + +Bool +s3CursorInit (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!s3s->cursor_base) + { + pCurPriv->has_cursor = FALSE; + return FALSE; + } + + pCurPriv->width = S3_CURSOR_WIDTH; + pCurPriv->height= S3_CURSOR_HEIGHT; + pScreen->QueryBestSize = s3QueryBestSize; + miPointerInitialize (pScreen, + &s3PointerSpriteFuncs, + &kdPointerScreenFuncs, + FALSE); + pCurPriv->has_cursor = TRUE; + pCurPriv->pCursor = NULL; + return TRUE; +} + +void +s3CursorEnable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + s3LoadCursor (pScreen, x, y); + } + else + s3UnloadCursor (pScreen); + } +} + +void +s3CursorDisable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!pScreenPriv->enabled) + return; + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + s3UnloadCursor (pScreen); + } + } +} + +void +s3CursorFini (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + pCurPriv->pCursor = NULL; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/trio/s3stub.c +++ xorg-server-1.4.99.906/hw/kdrive/trio/s3stub.c @@ -0,0 +1,66 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "s3.h" + +void +InitCard (char *name) +{ + KdCardAttr attr; + CARD32 count; + + count = 0; + while (LinuxFindPci (0x5333, 0x8904, count, &attr)) + { + KdCardInfoAdd (&s3Funcs, &attr, 0); + count++; + } +} + +void +InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) +{ + KdInitOutput (pScreenInfo, argc, argv); +} + +void +InitInput (int argc, char **argv) +{ + KdOsAddInputDrivers (); + KdInitInput (); +} + +void +ddxUseMsg (void) +{ + KdUseMsg(); +} + +int +ddxProcessArgument (int argc, char **argv, int i) +{ + return KdProcessArgument (argc, argv, i); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/trio/s3.c +++ xorg-server-1.4.99.906/hw/kdrive/trio/s3.c @@ -0,0 +1,1013 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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_CONFIG_H +#include +#endif +#include "s3.h" + +#define REGISTERS_OFFSET (0x1000000) +#define PACKED_OFFSET (0x8100) + + +CARD8 +_s3ReadIndexRegister (volatile CARD8 *base, CARD8 index) +{ + CARD8 ret; + *base = index; + ret = *(base + 1); + DRAW_DEBUG ((DEBUG_CRTC, " 0x%3x 0x%02x -> 0x%02x", + ((int) base) & 0xfff, index, ret)); + return ret; +} + +void +_s3WriteIndexRegister (volatile CARD8 *base, CARD8 index, CARD8 value) +{ + DRAW_DEBUG ((DEBUG_CRTC, " 0x%3x 0x%02x <- 0x%02x", + ((int) base) & 0xfff, index, value)); + *base = index; + *(base + 1) = value; +} + +/* + * Map the S3 card and detect its configuration. Do not touch the card + */ + +static void +_s3LoadCrtc (S3Ptr s3, S3Crtc *crtc) +{ + crtc->h_total_0_7 = GetCrtc (s3, 0x00); + crtc->h_display_end_0_7 = GetCrtc (s3, 0x01); + crtc->h_blank_start_0_7 = GetCrtc (s3, 0x02); + crtc->_h_blank_end = GetCrtc (s3, 0x03); + crtc->h_sync_start_0_7 = GetCrtc (s3, 0x04); + crtc->_h_sync_end = GetCrtc (s3, 0x05); + crtc->v_total_0_7 = GetCrtc (s3, 0x06); + crtc->crtc_overflow = GetCrtc (s3, 0x07); + crtc->preset_row_scan = GetCrtc (s3, 0x08); + crtc->_max_scan_line = GetCrtc (s3, 0x09); + + crtc->start_address_8_15 = GetCrtc (s3, 0x0c); + crtc->start_address_0_7 = GetCrtc (s3, 0x0d); + + crtc->v_retrace_start_0_7 = GetCrtc (s3, 0x10); + crtc->_v_retrace_end = GetCrtc (s3, 0x11); + crtc->v_display_end_0_7 = GetCrtc (s3, 0x12); + crtc->screen_off_0_7 = GetCrtc (s3, 0x13); + + crtc->v_blank_start_0_7 = GetCrtc (s3, 0x15); + crtc->v_blank_end_0_7 = GetCrtc (s3, 0x16); + + crtc->line_compare_0_7 = GetCrtc (s3, 0x18); + + crtc->memory_configuration = GetCrtc (s3, 0x31); + + crtc->misc_1 = GetCrtc (s3, 0x3a); + crtc->h_start_fifo_fetch_0_7 = GetCrtc (s3, 0x3b); + + crtc->mode_control = GetCrtc (s3, 0x42); + + crtc->hardware_cursor_mode = GetCrtc (s3, 0x45); + crtc->cursor_address_8_15 = GetCrtc (s3, 0x4C); + crtc->cursor_address_0_7 = GetCrtc (s3, 0x4D); + + crtc->extended_system_control_1 = GetCrtc (s3, 0x50); + crtc->extended_system_control_2 = GetCrtc (s3, 0x51); + + crtc->extended_memory_control = GetCrtc (s3, 0x53); + + crtc->extended_ramdac_control = GetCrtc (s3, 0x55); + + crtc->extended_horizontal_overflow = GetCrtc (s3, 0x5d); + crtc->extended_vertical_overflow = GetCrtc (s3, 0x5e); + + crtc->l_parm_0_7 = GetCrtc (s3, 0x62); + + crtc->extended_misc_control = GetCrtc (s3, 0x65); + + crtc->extended_misc_control_2 = GetCrtc (s3, 0x67); + + crtc->configuration_3 = GetCrtc (s3, 0x68); + + crtc->extended_system_control_3 = GetCrtc (s3, 0x69); + + crtc->extended_bios_5 = GetCrtc (s3, 0x6d); + + crtc->extended_sequencer_b = GetSrtc (s3, 0x0b); + crtc->extended_sequencer_d = GetSrtc (s3, 0x0d); + crtc->dclk_value_low = GetSrtc (s3, 0x12); + crtc->dclk_value_high = GetSrtc (s3, 0x13); + crtc->control_2 = GetSrtc (s3, 0x15); + crtc->ramdac_control = GetSrtc (s3, 0x18); + +/* combine values */ + + switch (crtc_ge_screen_width(crtc)) { + case 0: + if (crtc->enable_two_page) + crtc->ge_screen_pitch = 2048; + else + crtc->ge_screen_pitch = 1024; + break; + case 1: + crtc->ge_screen_pitch = 640; + break; + case 2: + /* ignore magic 1600x1200x4 mode */ + crtc->ge_screen_pitch = 800; + break; + case 3: + crtc->ge_screen_pitch = 1280; + break; + case 4: + crtc->ge_screen_pitch = 1152; + break; + case 5: + crtc->ge_screen_pitch = 0; /* reserved */ + break; + case 6: + crtc->ge_screen_pitch = 1600; + break; + case 7: + crtc->ge_screen_pitch = 0; /* reserved */ + break; + } + switch (crtc->pixel_length) { + case 0: + crtc->bits_per_pixel = 8; + crtc->pixel_width = (crtc_h_display_end(crtc) + 1) * 8; + break; + case 1: + crtc->bits_per_pixel = 16; + crtc->pixel_width = (crtc_h_display_end(crtc) + 1) * 4; + break; + case 3: + crtc->bits_per_pixel = 32; + crtc->pixel_width = (crtc_h_display_end(crtc) + 1) * 8; + break; + } + crtc->double_pixel_mode = 0; + switch (crtc->color_mode) { + case 0x0: + crtc->depth = 8; break; + case 0x1: + crtc->depth = 8; crtc->double_pixel_mode = 1; break; + case 0x3: + crtc->depth = 15; break; + case 0x5: + crtc->depth = 16; break; + case 0x7: + crtc->depth = 24; break; /* unused */ + case 0xd: + crtc->depth = 24; break; + } +} + +static void +_s3SetBlank (S3Ptr s3, Bool blank) +{ + CARD8 clock_mode; + + DRAW_DEBUG ((DEBUG_S3INIT, "3c4 at 0x%x\n", &s3->crt_vga_3c4)); + clock_mode = _s3ReadIndexRegister (&s3->crt_vga_3c4, 0x01); + if (blank) + clock_mode |= 0x20; + else + clock_mode &= ~0x20; + _s3WaitVRetrace (s3); + _s3WriteIndexRegister (&s3->crt_vga_3c4, 0x01, clock_mode); + DRAW_DEBUG ((DEBUG_S3INIT, "blank is set to 0x%x", clock_mode)); +} + +static void +_s3SetDepth (S3Ptr s3, S3Crtc *crtc) +{ + CARD8 save_3c2; + _s3SetBlank (s3, TRUE); + PutCrtc(s3, 0x38, 0x48); + PutCrtc(s3, 0x39, 0xA0); + PutCrtc(s3, 0x00, crtc->h_total_0_7); + PutCrtc(s3, 0x01, crtc->h_display_end_0_7); + PutCrtc(s3, 0x02, crtc->h_blank_start_0_7); + PutCrtc(s3, 0x03, crtc->_h_blank_end); + PutCrtc(s3, 0x04, crtc->h_sync_start_0_7); + PutCrtc(s3, 0x05, crtc->_h_sync_end); + PutCrtc(s3, 0x06, crtc->v_total_0_7); + PutCrtc(s3, 0x07, crtc->crtc_overflow); + PutCrtc(s3, 0x09, crtc->_max_scan_line); + PutCrtc(s3, 0x0c, crtc->start_address_8_15); + PutCrtc(s3, 0x0d, crtc->start_address_0_7); + PutCrtc(s3, 0x10, crtc->v_retrace_start_0_7); + PutCrtc(s3, 0x11, crtc->_v_retrace_end); + PutCrtc(s3, 0x12, crtc->v_display_end_0_7); + PutCrtc(s3, 0x13, crtc->screen_off_0_7); + PutCrtc(s3, 0x15, crtc->v_blank_start_0_7); + PutCrtc(s3, 0x16, crtc->v_blank_end_0_7); + PutCrtc(s3, 0x18, crtc->line_compare_0_7); + PutCrtc(s3, 0x31, crtc->memory_configuration); + PutCrtc(s3, 0x3a, crtc->misc_1); + PutCrtc(s3, 0x3b, crtc->h_start_fifo_fetch_0_7); + PutCrtc(s3, 0x42, crtc->mode_control); + PutCrtc(s3, 0x45, crtc->hardware_cursor_mode); + PutCrtc(s3, 0x4c, crtc->cursor_address_8_15); + PutCrtc(s3, 0x4d, crtc->cursor_address_0_7); + PutCrtc(s3, 0x50, crtc->extended_system_control_1); + PutCrtc(s3, 0x51, crtc->extended_system_control_2); + PutCrtc(s3, 0x53, crtc->extended_memory_control); + PutCrtc(s3, 0x55, crtc->extended_ramdac_control); + PutCrtc(s3, 0x5d, crtc->extended_horizontal_overflow); + PutCrtc(s3, 0x5e, crtc->extended_vertical_overflow); + PutCrtc(s3, 0x62, crtc->l_parm_0_7); + PutCrtc(s3, 0x65, crtc->extended_misc_control); + PutCrtc(s3, 0x67, crtc->extended_misc_control_2); + PutCrtc(s3, 0x68, crtc->configuration_3); + PutCrtc(s3, 0x69, crtc->extended_system_control_3); + PutCrtc(s3, 0x6d, crtc->extended_bios_5); + PutCrtc(s3, 0x39, 0x00); + PutCrtc(s3, 0x38, 0x00); + PutSrtc(s3, 0x0b, crtc->extended_sequencer_b); + PutSrtc(s3, 0x0d, crtc->extended_sequencer_d); + /* + * Move new dclk/mclk values into PLL + */ + save_3c2 = s3->crt_vga_3cc; + DRAW_DEBUG ((DEBUG_S3INIT, "save_3c2 0x%x", save_3c2)); + s3->crt_vga_3c2 = save_3c2 | 0x0c; + + PutSrtc(s3, 0x12, crtc->dclk_value_low); + PutSrtc(s3, 0x13, crtc->dclk_value_high); + + DRAW_DEBUG ((DEBUG_S3INIT, "Set PLL load enable, frobbing clk_load...")); + crtc->dfrq_en = 1; + PutSrtc(s3, 0x15, crtc->control_2); + PutSrtc(s3, 0x18, crtc->ramdac_control); + + DRAW_DEBUG ((DEBUG_S3INIT, "Clk load frobbed, restoring 3c2 to 0x%x", save_3c2)); + s3->crt_vga_3c2 = save_3c2; + + DRAW_DEBUG ((DEBUG_S3INIT, "Enabling display")); + _s3SetBlank (s3, FALSE); +} + +void +_s3RestoreCrtc (S3Ptr s3, S3Crtc *crtc) +{ + _s3SetDepth (s3, crtc); +} + +s3Reset (S3CardInfo *s3c) +{ + S3Ptr s3 = s3c->s3; + S3Save *save = &s3c->save; + CARD8 *cursor_base; + + LockS3 (s3c); + + _s3UnlockExt (s3); + + _s3RestoreCrtc (s3, &save->crtc); + + /* set foreground */ + /* Reset cursor color stack pointers */ + (void) GetCrtc(s3, 0x45); + PutCrtc(s3, 0x4a, save->cursor_fg); + /* XXX for deeper screens? */ + + /* set background */ + /* Reset cursor color stack pointers */ + (void) GetCrtc(s3, 0x45); + PutCrtc(s3, 0x4b, save->cursor_bg); + + _s3LockExt (s3); + + /* graphics engine state */ + s3->alt_mix = save->alt_mix; + s3->write_mask = save->write_mask; + s3->fg = save->fg; + s3->bg = save->bg; + /* XXX should save and restore real values? */ + s3->scissors_tl = 0x00000000; + s3->scissors_br = 0x0fff0fff; + + _s3WriteIndexRegister (&s3->crt_vga_3c4, 0x01, save->clock_mode); + PutCrtc(s3, 0x39, save->lock2); + PutCrtc(s3, 0x38, save->lock1); + + UnlockS3 (s3c); +} + +void +s3Save (S3CardInfo *s3c) +{ + S3Ptr s3 = s3c->s3; + S3Save *save = &s3c->save; + S3Crtc newCrtc; + CARD8 t1, t2; + CARD8 *cursor_base; + + LockS3 (s3c); + + save->alt_mix = s3->alt_mix; + save->write_mask = s3->write_mask; + save->fg = s3->fg; + save->bg = s3->bg; + + save->lock1 = GetCrtc(s3, 0x38); + save->lock2 = GetCrtc(s3, 0x39); + save->clock_mode = _s3ReadIndexRegister (&s3->crt_vga_3c4, 0x01); + + _s3UnlockExt (s3); + save->cursor_fg = GetCrtc(s3, 0x4a); + save->cursor_bg = GetCrtc(s3, 0x4b); + + _s3LoadCrtc (s3, &save->crtc); + + _s3LockExt (s3); + + UnlockS3 (s3c); +} +Bool +s3CardInit (KdCardInfo *card) +{ + S3CardInfo *s3c; + S3Ptr s3; + int size; + CARD8 *registers; + CARD32 s3Address = card->attr.address[0]; + CARD8 *temp_buffer; + + DRAW_DEBUG ((DEBUG_S3INIT, "s3CardInit")); + s3c = (S3CardInfo *) xalloc (sizeof (S3CardInfo)); + if (!s3c) + { + DRAW_DEBUG ((DEBUG_FAILURE, "can't alloc s3 card info")); + goto bail0; + } + + memset (s3c, '\0', sizeof (S3CardInfo)); + + card->driver = s3c; + + fprintf (stderr, "S3 at 0x%x\n", s3Address); + registers = KdMapDevice (s3Address + REGISTERS_OFFSET, + sizeof (S3) + PACKED_OFFSET); + if (!registers) + { + ErrorF ("Can't map s3 device\n"); + goto bail2; + } + s3 = (S3Ptr) (registers + PACKED_OFFSET); + s3c->registers = registers; + s3c->s3 = s3; + + s3->crt_vga_3c3 = 1; /* wake up part from deep sleep */ + s3->crt_vga_3c2 = 0x01 | 0x02 | 0x0c; + + s3->crt_vga_3c4 = 0x58; + s3->crt_vga_3c5 = 0x10 | 0x3; + + /* + * Can't trust S3 register value for frame buffer amount, must compute + */ + temp_buffer = KdMapDevice (s3Address, 4096 * 1024); + + s3c->memory = KdFrameBufferSize (temp_buffer, 4096 * 1024); + + DRAW_DEBUG ((DEBUG_S3INIT, "Detected frame buffer %d", s3c->memory)); + + KdUnmapDevice (temp_buffer, 4096 * 1024); + + if (!s3c->memory) + { + ErrorF ("Can't detect s3 frame buffer\n"); + goto bail3; + } + + s3c->frameBuffer = KdMapDevice (s3Address, s3c->memory); + if (!s3c->frameBuffer) + { + ErrorF ("Can't map s3 frame buffer\n"); + goto bail3; + } + + card->driver = s3c; + + return TRUE; +bail3: + KdUnmapDevice ((void *) s3, sizeof (S3)); +bail2: +bail1: + xfree (s3c); +bail0: + return FALSE; +} + +Bool +s3ModeSupported (KdScreenInfo *screen, + const KdMonitorTiming *t) +{ + if (t->horizontal != 1600 && + t->horizontal != 1280 && + t->horizontal != 1152 && + t->horizontal != 1024 && + t->horizontal != 800 && + t->horizontal != 640) + return FALSE; + if (t->clock > S3_MAX_CLOCK * 2) + return FALSE; + return TRUE; +} + +Bool +s3ModeUsable (KdScreenInfo *screen) +{ + KdCardInfo *card = screen->card; + S3CardInfo *s3c = (S3CardInfo *) card->driver; + int screen_size; + int pixel_width; + int byte_width; + + if (screen->fb[0].depth >= 24) + { + screen->fb[0].depth = 24; + screen->fb[0].bitsPerPixel = 32; + } + else if (screen->fb[0].depth >= 16) + { + screen->fb[0].depth = 16; + screen->fb[0].bitsPerPixel = 16; + } + else if (screen->fb[0].depth >= 15) + { + screen->fb[0].depth = 15; + screen->fb[0].bitsPerPixel = 16; + } + else + { + screen->fb[0].depth = 8; + screen->fb[0].bitsPerPixel = 8; + } + + byte_width = screen->width * (screen->fb[0].bitsPerPixel >> 3); + pixel_width = screen->width; + screen->fb[0].pixelStride = pixel_width; + screen->fb[0].byteStride = byte_width; + + screen_size = byte_width * screen->height; + + return screen_size <= s3c->memory; +} + +Bool +s3ScreenInit (KdScreenInfo *screen) +{ + KdCardInfo *card = screen->card; + S3CardInfo *s3c = (S3CardInfo *) card->driver; + S3ScreenInfo *s3s; + int screen_size; + int memory; + int requested_memory; + int v_total, h_total; + int byte_width; + int pixel_width; + int m, n, r; + int i; + const KdMonitorTiming *t; + + DRAW_DEBUG ((DEBUG_S3INIT, "s3ScreenInit")); + s3s = (S3ScreenInfo *) xalloc (sizeof (S3ScreenInfo)); + if (!s3s) + return FALSE; + + memset (s3s, '\0', sizeof (S3ScreenInfo)); + + if (!screen->width || !screen->height) + { + screen->width = 800; + screen->height = 600; + screen->rate = 72; + } + if (!screen->fb[0].depth) + screen->fb[0].depth = 8; + + DRAW_DEBUG ((DEBUG_S3INIT, "Requested parameters %dx%dx%d", + screen->width, screen->height, screen->rate)); + t = KdFindMode (screen, s3ModeSupported); + screen->rate = t->rate; + screen->width = t->horizontal; + screen->height = t->vertical; + s3GetClock (t->clock, &m, &n, &r, 127, 31, 3); +#if 0 + fprintf (stderr, "computed %d,%d,%d (%d) provided %d,%d,%d (%d)\n", + m, n, r, S3_CLOCK(m,n,r), + t->dac_m, t->dac_n, t->dac_r, + S3_CLOCK(t->dac_m, t->dac_n, t->dac_r)); +#endif + /* + * Can only operate in pixel-doubled mode at 8 bits per pixel + */ + if (screen->fb[0].depth > 8 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK) + screen->fb[0].depth = 8; + + if (!KdTuneMode (screen, s3ModeUsable, s3ModeSupported)) + { + xfree (s3s); + return FALSE; + } + + memory = s3c->memory - screen_size; + + /* + * Stick frame buffer at start of memory + */ + screen->fb[0].frameBuffer = s3c->frameBuffer; + + /* + * Stick cursor at end of memory + */ + if (memory >= 2048) + { + s3s->cursor_base = s3c->frameBuffer + (s3c->memory - 2048); + memory -= 2048; + } + else + s3s->cursor_base = 0; + + /* + * Use remaining memory for off-screen storage, but only use + * one piece (either right or bottom). + */ + if (memory >= byte_width * S3_TILE_SIZE) + { + s3s->fb[0].offscreen = s3c->frameBuffer + screen_size; + s3s->fb[0].offscreen_x = 0; + s3s->fb[0].offscreen_y = screen_size / byte_width; + s3s->fb[0].offscreen_width = pixel_width; + s3s->fb[0].offscreen_height = memory / byte_width; + memory -= s3s->fb[0].offscreen_height * byte_width; + } + else if (pixel_width - screen->width >= S3_TILE_SIZE) + { + s3s->fb[0].offscreen = s3c->frameBuffer + screen->width; + s3s->fb[0].offscreen_x = screen->width; + s3s->fb[0].offscreen_y = 0; + s3s->fb[0].offscreen_width = pixel_width - screen->width; + s3s->fb[0].offscreen_height = screen->height; + } + else + s3s->fb[0].offscreen = 0; + + DRAW_DEBUG ((DEBUG_S3INIT, "depth %d bits %d", screen->fb[0].depth, screen->fb[0].bitsPerPixel)); + + DRAW_DEBUG ((DEBUG_S3INIT, "Screen size %dx%d memory %d", + screen->width, screen->height, s3c->memory)); + DRAW_DEBUG ((DEBUG_S3INIT, "frame buffer 0x%x cursor 0x%x offscreen 0x%x", + s3c->frameBuffer, s3s->cursor_base, s3s->offscreen)); + DRAW_DEBUG ((DEBUG_S3INIT, "offscreen %dx%d+%d+%d", + s3s->offscreen_width, s3s->offscreen_height, + s3s->offscreen_x, s3s->offscreen_y)); + + switch (screen->fb[0].depth) { + case 8: + screen->fb[0].visuals = ((1 << StaticGray) | + (1 << GrayScale) | + (1 << StaticColor) | + (1 << PseudoColor) | + (1 << TrueColor) | + (1 << DirectColor)); + screen->fb[0].blueMask = 0x00; + screen->fb[0].greenMask = 0x00; + screen->fb[0].redMask = 0x00; + break; + case 15: + screen->fb[0].visuals = (1 << TrueColor); + screen->fb[0].blueMask = 0x001f; + screen->fb[0].greenMask = 0x03e0; + screen->fb[0].redMask = 0x7c00; + break; + case 16: + screen->fb[0].visuals = (1 << TrueColor); + screen->fb[0].blueMask = 0x001f; + screen->fb[0].greenMask = 0x07e0; + screen->fb[0].redMask = 0xf800; + break; + case 24: + screen->fb[0].visuals = (1 << TrueColor); + screen->fb[0].blueMask = 0x0000ff; + screen->fb[0].greenMask = 0x00ff00; + screen->fb[0].redMask = 0xff0000; + break; + } + + screen->driver = s3s; + + return TRUE; +} + +void +s3Preserve (KdCardInfo *card) +{ + S3CardInfo *s3c = card->driver; + + s3Save (s3c); +} + +/* + * Enable the card for rendering. Manipulate the initial settings + * of the card here. + */ +Bool +s3Enable (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + KdScreenInfo *screen = pScreenPriv->screen; + s3CardInfo (pScreenPriv); + s3ScreenInfo (pScreenPriv); + + S3Crtc crtcR, *crtc; + int hactive, hblank, hfp, hbp; + int vactive, vblank, vfp, vbp; + int hsize; + + int h_total; + int h_display_end; + int h_blank_start; + int h_blank_end; + int h_sync_start; + int h_sync_end; + int h_screen_off; + int h_start_fifo_fetch; + + int v_total; + int v_retrace_start; + int v_retrace_end; + int v_display_end; + int v_blank_start; + int v_blank_end; + + int h_adjust; + int h_sync_extend_; + int h_blank_extend_; + int i; + CARD16 cursor_address; + const KdMonitorTiming *t; + int m, n, r; + + DRAW_DEBUG ((DEBUG_S3INIT, "s3Enable")); + + DRAW_DEBUG ((DEBUG_S3INIT, "requested bpp %d current %d", + pScreenPriv->bitsPerPixel, s3c->save.crtc.bits_per_pixel)); + + t = KdFindMode (screen, s3ModeSupported); + + hfp = t->hfp; + hbp = t->hbp; + hblank = t->hblank; + hactive = t->horizontal; + + vfp = t->vfp; + vbp = t->vbp; + vblank = t->vblank; + vactive = t->vertical; + + crtcR = s3c->save.crtc; + crtc = &crtcR; + + s3GetClock (t->clock, &m, &n, &r, 127, 31, 3); + crtc->dclk_pll_m_trio = m; + crtc->dclk_pll_n_trio = n; + crtc->dclk_pll_r_trio = r; + + crtc->alt_refresh_count = 0x02; + crtc->enable_alt_refresh = 1; + crtc->enable_256_or_more = 1; + + DRAW_DEBUG ((DEBUG_S3INIT, "memory_bus_size %d\n", crtc->memory_bus_size)); + crtc->memory_bus_size = 1; + + crtc->dclk_over_2 = 0; + crtc->dclk_invert = 0; + crtc->enable_clock_double = 0; + crtc->delay_blank = 0; + crtc->extended_bios_5 = 0; + /* + * Compute character lengths for horizontal timing values + */ + switch (screen->fb[0].bitsPerPixel) { + case 8: + hactive = screen->width / 8; + hblank /= 8; + hfp /= 8; + hbp /= 8; + h_screen_off = hactive; + crtc->pixel_length = 0; + crtc->color_mode = 0; + /* + * Set up for double-pixel mode, switch color modes, + * divide the dclk and delay h blank by 2 dclks + */ + if (S3_CLOCK(crtc->dclk_pll_m_trio, crtc->dclk_pll_n_trio, + crtc->dclk_pll_r_trio) > S3_MAX_CLOCK) + { + DRAW_DEBUG ((DEBUG_S3INIT, "S3 clock %g > 80MHz, using pixel double mode", + S3_CLOCK(crtc->dclk_pll_m_trio, crtc->dclk_pll_n_trio, + crtc->dclk_pll_r_trio))); + crtc->color_mode = 1; + crtc->dclk_over_2 = 1; + crtc->enable_clock_double = 1; + crtc->delay_blank = 2; + crtc->extended_bios_5 = 2; + } + h_adjust = 1; + break; + case 16: + hactive = screen->width / 4; + hblank /= 4; + hfp /= 4; + hbp /= 4; + h_screen_off = hactive; + crtc->pixel_length = 1; + crtc->extended_bios_5 = 2; + if (crtc->depth == 15) + crtc->color_mode = 3; + else + crtc->color_mode = 5; + h_adjust = 2; + break; + case 32: + hactive = screen->width / 8; + hblank /= 8; + hfp /= 8; + hbp /= 8; + h_screen_off = hactive * 4; + crtc->pixel_length = 3; + crtc->color_mode = 0xd; + h_adjust = 1; + break; + } + + /* + * X server starts frame buffer at top of memory + */ + DRAW_DEBUG ((DEBUG_S3INIT, "Old start address 0x%x\n", + crtc_start_address (crtc))); + crtc_set_start_address (crtc, 0); + + /* + * Compute horizontal register values from timings + */ + h_total = hactive + hblank - 5; + h_display_end = hactive - 1; + h_blank_start = h_display_end; + h_blank_end = h_blank_start + hblank - h_adjust; + h_sync_start = hactive + hfp + h_adjust; + h_sync_end = h_sync_start + hblank - hbp - hfp; + h_start_fifo_fetch = h_total - 5; + + DRAW_DEBUG ((DEBUG_S3INIT, "blank_end 0x%x sync_end 0x%x sync_start 0x%x\n", + h_blank_end, h_sync_end, h_sync_start)); + + if (h_blank_end - h_blank_start > 0x40) + h_blank_extend_ = 1; + else + h_blank_extend_ = 0; + + if (h_sync_end - h_sync_start > 0x20) + h_sync_extend_ = 1; + else + h_sync_extend_ = 0; + + DRAW_DEBUG ((DEBUG_S3INIT, "blank_end 0x%x sync_end 0x%x extend %d\n", + h_blank_end, h_sync_end, h_sync_extend_)); + + crtc_set_h_total(crtc, h_total); + crtc_set_h_display_end (crtc, h_display_end); + crtc_set_h_blank_start (crtc, h_blank_start); + crtc_set_h_blank_end (crtc, h_blank_end); + crtc_set_h_sync_start (crtc, h_sync_start); + crtc_set_h_sync_end (crtc, h_sync_end); + crtc_set_screen_off (crtc, h_screen_off); + crtc_set_h_start_fifo_fetch (crtc, h_start_fifo_fetch); + crtc->h_sync_extend = h_sync_extend_; + crtc->h_blank_extend = h_blank_extend_; + + + v_total = vactive + vblank - 2; + v_retrace_start = vactive + vfp - 1; + v_retrace_end = v_retrace_start + vblank - vbp - 1; + v_display_end = vactive - 1; + v_blank_start = vactive - 1; + v_blank_end = v_blank_start + vblank - 1; + + crtc_set_v_total(crtc, v_total); + crtc_set_v_retrace_start (crtc, v_retrace_start); + crtc->v_retrace_end_0_3 = v_retrace_end; + crtc_set_v_display_end (crtc, v_display_end); + crtc_set_v_blank_start (crtc, v_blank_start); + crtc->v_blank_end_0_7 = v_blank_end; + + /* + * Set cursor + */ + if (!screen->softCursor) + { + cursor_address = (s3s->cursor_base - screen->fb[0].frameBuffer) / 1024; + + crtc->cursor_address_0_7 = cursor_address; + crtc->cursor_address_8_15 = cursor_address >> 8; + crtc->hardware_cursor_ms_x11 = 0; + crtc->hardware_cursor_enable = 1; + } + else + crtc->hardware_cursor_enable = 0; + + /* + * Set accelerator + */ + switch (screen->width) { + case 640: crtc_set_ge_screen_width(crtc,1); break; + case 800: crtc_set_ge_screen_width(crtc,2); break; + case 1024: crtc_set_ge_screen_width(crtc,0); break; + case 1152: crtc_set_ge_screen_width(crtc,4); break; + case 1280: crtc_set_ge_screen_width(crtc,3); break; + case 1600: crtc_set_ge_screen_width(crtc,6); break; + } + + /* + * Set depth values + */ + crtc->bits_per_pixel = screen->fb[0].bitsPerPixel; + crtc->depth = screen->fb[0].depth; + + crtc->l_parm_0_7 = screen->width / 4; /* Undocumented. */ + + crtc->disable_v_retrace_int = 1; /* don't let retrace interrupt */ + + DRAW_DEBUG ((DEBUG_S3INIT, "new h total %d display_end %d", + crtc_h_total(crtc), + crtc_h_display_end(crtc))); + DRAW_DEBUG ((DEBUG_S3INIT, " sync_start %d sync_end %d (%d)", + crtc_h_sync_start(crtc), + crtc_h_sync_end(crtc), h_sync_end)); + + DRAW_DEBUG ((DEBUG_S3INIT, " blank_start %d blank_end %d", + crtc_h_blank_start(crtc), + crtc_h_blank_end(crtc))); + + DRAW_DEBUG ((DEBUG_S3INIT, " screen_off %d start_fifo %d", + crtc_screen_off(crtc), crtc_h_start_fifo_fetch(crtc))); + + DRAW_DEBUG ((DEBUG_S3INIT, " active %d blank %d fp %d bp %d", + hactive, hblank, hfp, hbp)); + + DRAW_DEBUG ((DEBUG_S3INIT, "new v total %d display_end %d", + crtc_v_total(crtc), + crtc_v_display_end(crtc))); + DRAW_DEBUG ((DEBUG_S3INIT, " retrace_start %d retrace_end %d (%d)", + crtc_v_retrace_start(crtc), + crtc->v_retrace_end, + v_retrace_end)); + DRAW_DEBUG ((DEBUG_S3INIT, " blank_start %d blank_end %d", + crtc_v_blank_start(crtc), + crtc->v_blank_end_0_7)); + + DRAW_DEBUG ((DEBUG_S3INIT, " active %d blank %d fp %d bp %d", + vactive, vblank, vfp, vbp)); + + /* + * Set DPMS to normal + */ + crtc->hsync_control = 0; + crtc->vsync_control = 0; + + LockS3 (s3c); + _s3SetDepth (s3c->s3, crtc); + UnlockS3 (s3c); + return TRUE; +} + +void +s3Disable (ScreenPtr pScreen) +{ +} + +void +s3Restore (KdCardInfo *card) +{ + S3CardInfo *s3c = card->driver; + + s3Reset (s3c); +} + +void +_s3SetSync (S3CardInfo *s3c, int hsync, int vsync) +{ + /* this abuses the macros defined to access the crtc structure */ + union extended_sequencer_d_u _extended_sequencer_d_u; + S3Ptr s3 = s3c->s3; + + extended_sequencer_d = s3c->save.crtc.extended_sequencer_d; + hsync_control = hsync; + vsync_control = vsync; + PutSrtc (s3, 0x0d, extended_sequencer_d); +} + +Bool +s3DPMS (ScreenPtr pScreen, int mode) +{ + KdScreenPriv(pScreen); + s3CardInfo(pScreenPriv); + + switch (mode) { + case KD_DPMS_NORMAL: + _s3SetSync (s3c, 0, 0); + _s3SetBlank (s3c->s3, FALSE); + break; + case KD_DPMS_STANDBY: + _s3SetBlank (s3c->s3, TRUE); + _s3SetSync (s3c, 1, 0); + break; + case KD_DPMS_SUSPEND: + _s3SetBlank (s3c->s3, TRUE); + _s3SetSync (s3c, 0, 1); + break; + case KD_DPMS_POWERDOWN: + _s3SetBlank (s3c->s3, TRUE); + _s3SetSync (s3c, 1, 1); + break; + } + return TRUE; +} + +void +s3ScreenFini (KdScreenInfo *screen) +{ + S3ScreenInfo *s3s = (S3ScreenInfo *) screen->driver; + + xfree (s3s); + screen->driver = 0; +} + +void +s3CardFini (KdCardInfo *card) +{ + S3CardInfo *s3c = (S3CardInfo *) card->driver; + + KdUnmapDevice (s3c->frameBuffer, s3c->memory); + KdUnmapDevice (s3c->registers, sizeof (S3) + PACKED_OFFSET); +/* DeleteCriticalSection (&s3c->lock); */ + xfree (s3c); + card->driver = 0; +} + +KdCardFuncs s3Funcs = { + s3CardInit, + s3ScreenInit, + 0, + s3Preserve, + s3Enable, + s3DPMS, + s3Disable, + s3Restore, + s3ScreenFini, + s3CardFini, + s3CursorInit, + s3CursorEnable, + s3CursorDisable, + s3CursorFini, + s3RecolorCursor, + s3DrawInit, + s3DrawEnable, + s3DrawSync, + s3DrawDisable, + s3DrawFini, + s3GetColors, + s3PutColors, +}; + +void +S3InitCard (KdCardAttr *attr) +{ + KdCardInfoAdd (&s3Funcs, attr, 0); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/ipaq/ipaq.c +++ xorg-server-1.4.99.906/hw/kdrive/ipaq/ipaq.c @@ -0,0 +1,70 @@ +/* + * Copyright © 1999 Keith Packard + * + * 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 Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD 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. + * + * Adapted from ts300.c by Alan Hourihane + * For the Compaq IPAQ handheld, with the HP VGA Out Card (F1252A). + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "pcmcia.h" + +extern KdCardFuncs pcmciaFuncs; + +void +InitCard (char *name) +{ + KdCardAttr attr; + if (name && !strcmp(name, "pcmcia")) + KdCardInfoAdd (&pcmciaFuncs, &attr, 0); + else + KdCardInfoAdd (&fbdevFuncs, &attr, 0); +} + +void +InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) +{ + KdInitOutput (pScreenInfo, argc, argv); +} + +void +InitInput (int argc, char **argv) +{ + KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); +#ifdef TOUCHSCREEN + KdAddMouseDriver (&TsFuncs); +#endif +} + +extern pcmciaDisplayModeRec pcmciaDefaultModes[]; + +void +ddxUseMsg (void) +{ + KdUseMsg(); +} + +int +ddxProcessArgument (int argc, char **argv, int i) +{ + return KdProcessArgument (argc, argv, i); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3reg.h +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3reg.h @@ -0,0 +1,227 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifndef _S3REG_H_ +#define _S3REG_H_ + +#include "vga.h" + +#define S3_SR 0 +#define S3_NSR 0x70 +#define S3_GR (S3_SR+S3_NSR) +#define S3_NGR 0x09 +#define S3_AR (S3_GR+S3_NGR) +#define S3_NAR 0x15 +#define S3_CR (S3_AR+S3_NAR) +#define S3_NCR 0xc0 +#define S3_DAC (S3_CR+S3_NCR) +#define S3_NDAC 4 +#define S3_MISC_OUT (S3_DAC + S3_NDAC) +#define S3_INPUT_STATUS_1 (S3_MISC_OUT+1) +#define S3_NREG (S3_INPUT_STATUS_1+1) + +extern VgaReg s3_h_total[]; +extern VgaReg s3_h_display_end[]; +extern VgaReg s3_h_blank_start[]; +extern VgaReg s3_h_blank_end[]; +extern VgaReg s3_display_skew[]; +extern VgaReg s3_h_sync_start[]; +extern VgaReg s3_h_sync_end[]; +extern VgaReg s3_h_skew[]; +extern VgaReg s3_v_total[]; +extern VgaReg s3_preset_row_scan[]; +extern VgaReg s3_max_scan_line[]; +extern VgaReg s3_start_address[]; +extern VgaReg s3_v_retrace_start[]; +extern VgaReg s3_v_retrace_end[]; +extern VgaReg s3_clear_v_retrace_int[]; +extern VgaReg s3_disable_v_retrace_int[]; +extern VgaReg s3_lock_crtc[]; +extern VgaReg s3_v_display_end[]; +extern VgaReg s3_screen_offset[]; +extern VgaReg s3_count_by_4_mode[]; +extern VgaReg s3_doubleword_mode[]; +extern VgaReg s3_v_blank_start[]; +extern VgaReg s3_v_blank_end[]; +extern VgaReg s3_2bk_cga[]; +extern VgaReg s3_4bk_hga[]; +extern VgaReg s3_v_total_double[]; +extern VgaReg s3_address_16k_wrap[]; +extern VgaReg s3_word_mode[]; +extern VgaReg s3_byte_mode[]; +extern VgaReg s3_hardware_reset[]; +extern VgaReg s3_line_compare[]; +extern VgaReg s3_delay_primary_load[]; +extern VgaReg s3_device_id[]; +extern VgaReg s3_revision[]; +extern VgaReg s3_enable_vga_16bit[]; +extern VgaReg s3_enhanced_memory_mapping[]; +extern VgaReg s3_enable_sff[]; +extern VgaReg s3_lock_dac_writes[]; +extern VgaReg s3_border_select[]; +extern VgaReg s3_lock_palette[]; +extern VgaReg s3_lock_vert[]; +extern VgaReg s3_lock_horz[]; +extern VgaReg s3_io_disable[]; +extern VgaReg s3_mem_size[]; +extern VgaReg s3_register_lock_1 []; +extern VgaReg s3_register_lock_2 []; +extern VgaReg s3_refresh_control[]; +extern VgaReg s3_enable_256[]; +extern VgaReg s3_disable_pci_read_bursts[]; +extern VgaReg s3_h_start_fifo_fetch[]; +extern VgaReg s3_enable_2d_access[]; +extern VgaReg s3_interlace[]; +extern VgaReg s3_old_screen_off_8[]; +extern VgaReg s3_h_counter_double_mode[]; +extern VgaReg s3_cursor_enable[]; +extern VgaReg s3_cursor_right[]; +extern VgaReg s3_cursor_xhigh[]; +extern VgaReg s3_cursor_xlow[]; +extern VgaReg s3_cursor_yhigh[]; +extern VgaReg s3_cursor_ylow[]; +extern VgaReg s3_cursor_fg[]; +extern VgaReg s3_cursor_bg[]; +extern VgaReg s3_cursor_address[]; +extern VgaReg s3_cursor_xoff[]; +extern VgaReg s3_cursor_yoff[]; +extern VgaReg s3_ge_screen_width[]; +extern VgaReg s3_pixel_length[]; +extern VgaReg s3_big_endian_linear[]; +extern VgaReg s3_mmio_select[]; +extern VgaReg s3_mmio_window[]; +extern VgaReg s3_swap_nibbles[]; +extern VgaReg s3_cursor_ms_x11[]; +extern VgaReg s3_linear_window_size[]; +extern VgaReg s3_enable_linear[]; +extern VgaReg s3_h_blank_extend[]; +extern VgaReg s3_h_sync_extend[]; +extern VgaReg s3_sdclk_skew[]; +extern VgaReg s3_delay_blank[]; +extern VgaReg s3_delay_h_enable[]; +extern VgaReg s3_enable_2d_3d[]; +extern VgaReg s3_pci_disconnect_enable[]; +extern VgaReg s3_primary_load_control[]; +extern VgaReg s3_secondary_load_control[]; +extern VgaReg s3_pci_retry_enable[]; +extern VgaReg s3_streams_mode[]; +extern VgaReg s3_color_mode[]; +extern VgaReg s3_primary_stream_definition[]; +extern VgaReg s3_primary_stream_timeout[]; +extern VgaReg s3_master_control_unit_timeout[]; +extern VgaReg s3_command_buffer_timeout[]; +extern VgaReg s3_lpb_timeout[]; +extern VgaReg s3_cpu_timeout[]; +extern VgaReg s3_2d_graphics_engine_timeout[]; +extern VgaReg s3_fifo_drain_delay[]; +extern VgaReg s3_fifo_fetch_timing[]; +extern VgaReg s3_dac_power_up_time[]; +extern VgaReg s3_dac_power_saving_disable[]; +extern VgaReg s3_flat_panel_output_control_1[]; +extern VgaReg s3_streams_fifo_delay[]; +extern VgaReg s3_flat_panel_output_control_2[]; +extern VgaReg s3_enable_l1_parameter[]; +extern VgaReg s3_primary_stream_l1[]; + +extern VgaReg s3_dot_clock_8[]; +extern VgaReg s3_screen_off[]; +extern VgaReg s3_enable_write_plane[]; +extern VgaReg s3_extended_memory_access[]; +extern VgaReg s3_sequential_addressing_mode[]; +extern VgaReg s3_select_chain_4_mode[]; + +extern VgaReg s3_unlock_extended_sequencer[]; +extern VgaReg s3_linear_addressing_control[]; +extern VgaReg s3_disable_io_ports[]; +extern VgaReg s3_hsync_control[]; +extern VgaReg s3_vsync_control[]; +extern VgaReg s3_mclk_n[]; +extern VgaReg s3_mclk_r[]; +extern VgaReg s3_mclk_m[]; +extern VgaReg s3_dclk_n[]; +extern VgaReg s3_dclk_r[]; +extern VgaReg s3_dclk_m[]; +extern VgaReg s3_mclk_load[]; +extern VgaReg s3_dclk_load[]; +extern VgaReg s3_dclk_over_2[]; +extern VgaReg s3_clock_load_imm[]; +extern VgaReg s3_dclk_invert[]; +extern VgaReg s3_enable_clock_double[]; +extern VgaReg s3_dclk_double_15_16_invert[]; +extern VgaReg s3_enable_gamma_correction[]; +extern VgaReg s3_enable_8_bit_luts[]; +extern VgaReg s3_dclk_control[]; +extern VgaReg s3_eclk_n[]; +extern VgaReg s3_eclk_r[]; +extern VgaReg s3_eclk_m[]; +extern VgaReg s3_vga_dclk_n[]; +extern VgaReg s3_vga_dclk_r[]; +extern VgaReg s3_vga_dclk_m1[]; +extern VgaReg s3_vga_dclk_m2[]; +extern VgaReg s3_vga_clk_select[]; +extern VgaReg s3_select_graphics_mode[]; +extern VgaReg s3_enable_blinking[]; +extern VgaReg s3_border_color[]; + +extern VgaReg s3_io_addr_select[]; +extern VgaReg s3_enable_ram[]; +extern VgaReg s3_clock_select[]; +extern VgaReg s3_horz_sync_neg[]; +extern VgaReg s3_vert_sync_neg[]; + +extern VgaReg s3_display_mode_inactive[]; +extern VgaReg s3_vertical_sync_active[]; + +extern VgaReg s3_dac_mask[]; +extern VgaReg s3_dac_read_index[]; +extern VgaReg s3_dac_write_index[]; +extern VgaReg s3_dac_data[]; + +#define s3Get(sv,r) VgaGet(&(sv)->card, (r)) +#define s3GetImm(sv,r) VgaGetImm(&(sv)->card, (r)) +#define s3Set(sv,r,v) VgaSet(&(sv)->card, (r), (v)) +#define s3SetImm(sv,r,v) VgaSetImm(&(sv)->card, (r), (v)) + +typedef struct _s3Vga { + VgaCard card; + VgaValue values[S3_NREG]; + VGA32 save_lock_crtc; + VGA32 save_register_lock_1; + VGA32 save_register_lock_2; + VGA32 save_unlock_extended_sequencer; + VGA32 save_lock_dac_writes; + VGA32 save_lock_horz; + VGA32 save_lock_vert; + VGA32 save_dot_clock_8; +} S3Vga; + +void +s3RegInit (S3Vga *s3vga, VGAVOL8 *mmio); + +void +s3Save (S3Vga *s3vga); + +void +s3Reset (S3Vga *s3vga); + +#endif /* _S3REG_H_ */ --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3draw.c +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3draw.c @@ -0,0 +1,3114 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "s3.h" +#include "s3draw.h" + +#include "Xmd.h" +#include "gcstruct.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "regionstr.h" +#include "mistruct.h" +#include "fontstruct.h" +#include "dixfontstr.h" +#include "fb.h" +#include "migc.h" +#include "miline.h" + +/* + * Map X rops to S3 rops + */ + +short s3alu[16] = { + MIX_0, + MIX_AND, + MIX_SRC_AND_NOT_DST, + MIX_SRC, + MIX_NOT_SRC_AND_DST, + MIX_DST, + MIX_XOR, + MIX_OR, + MIX_NOR, + MIX_XNOR, + MIX_NOT_DST, + MIX_SRC_OR_NOT_DST, + MIX_NOT_SRC, + MIX_NOT_SRC_OR_DST, + MIX_NAND, + MIX_1 +}; + +/* + * Handle pixel transfers + */ + +#define BURST +#ifdef BURST +#define PixTransDeclare VOL32 *pix_trans_base = (VOL32 *) (s3c->registers),\ + *pix_trans = pix_trans_base +#define PixTransStart(n) if (pix_trans + (n) > pix_trans_base + 8192) pix_trans = pix_trans_base +#define PixTransStore(t) *pix_trans++ = (t) +#else +#define PixTransDeclare VOL32 *pix_trans = &s3->pix_trans +#define PixTransStart(n) +#define PixTransStore(t) *pix_trans = (t) +#endif + +DevPrivateKey s3GCPrivateKey = &s3GCPrivateKey; +DevPrivateKey s3WindowPrivateKey = &s3WindowPrivateKey; + +/* + s3DoBitBlt + ============= + Bit Blit for all window to window blits. +*/ + +#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3)) + +void +s3CopyNtoN (DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pbox, + int nbox, + int dx, + int dy, + Bool reverse, + Bool upsidedown, + Pixel bitplane, + void *closure) +{ + SetupS3(pDstDrawable->pScreen); + int srcX, srcY, dstX, dstY; + int w, h; + int flags; + + if (sourceInvarient (pGC->alu)) + { + s3FillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu, pGC->planemask); + return; + } + + s3SetGlobalBitmap (pDstDrawable->pScreen, s3GCMap (pGC)); + _s3SetBlt(s3,pGC->alu,pGC->planemask); + DRAW_DEBUG ((DEBUG_RENDER, "s3CopyNtoN alu %d planemask 0x%x", + pGC->alu, pGC->planemask)); + while (nbox--) + { + w = pbox->x2 - pbox->x1; + h = pbox->y2 - pbox->y1; + flags = 0; + if (reverse) + { + dstX = pbox->x2 - 1; + } + else + { + dstX = pbox->x1; + flags |= INC_X; + } + srcX = dstX + dx; + + if (upsidedown) + { + dstY = pbox->y2 - 1; + } + else + { + dstY = pbox->y1; + flags |= INC_Y; + } + srcY = dstY + dy; + + _s3Blt (s3, srcX, srcY, dstX, dstY, w, h, flags); + pbox++; + } + MarkSyncS3 (pSrcDrawable->pScreen); +} + +RegionPtr +s3CopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, + int srcx, int srcy, int width, int height, int dstx, int dsty) +{ + SetupS3(pDstDrawable->pScreen); + + if (pSrcDrawable->type == DRAWABLE_WINDOW && + pDstDrawable->type == DRAWABLE_WINDOW) + { + return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, + dstx, dsty, s3CopyNtoN, 0, 0); + } + return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, dstx, dsty); +} + +typedef struct _s31toNargs { + unsigned long copyPlaneFG, copyPlaneBG; + Bool opaque; +} s31toNargs; + +void +_s3Stipple (S3CardInfo *s3c, + FbStip *psrcBase, + FbStride widthSrc, + int srcx, + int srcy, + int dstx, + int dsty, + int width, + int height) +{ + S3Ptr s3 = s3c->s3; + FbStip *psrcLine, *psrc; + FbStride widthRest; + FbStip bits, tmp, lastTmp; + int leftShift, rightShift; + int nl, nlMiddle; + int r; + PixTransDeclare; + + /* Compute blt address and parameters */ + psrc = psrcBase + srcy * widthSrc + (srcx >> 5); + nlMiddle = (width + 31) >> 5; + leftShift = srcx & 0x1f; + rightShift = 32 - leftShift; + widthRest = widthSrc - nlMiddle; + + _s3PlaneBlt(s3,dstx,dsty,width,height); + + if (leftShift == 0) + { + while (height--) + { + nl = nlMiddle; + PixTransStart(nl); + while (nl--) + { + tmp = *psrc++; + S3AdjustBits32 (tmp); + PixTransStore (tmp); + } + psrc += widthRest; + } + } + else + { + widthRest--; + while (height--) + { + bits = *psrc++; + nl = nlMiddle; + PixTransStart(nl); + while (nl--) + { + tmp = FbStipLeft(bits, leftShift); + bits = *psrc++; + tmp |= FbStipRight(bits, rightShift); + S3AdjustBits32(tmp); + PixTransStore (tmp); + } + psrc += widthRest; + } + } +} + +void +s3Copy1toN (DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pbox, + int nbox, + int dx, + int dy, + Bool reverse, + Bool upsidedown, + Pixel bitplane, + void *closure) +{ + SetupS3(pDstDrawable->pScreen); + + s31toNargs *args = closure; + int dstx, dsty; + FbStip *psrcBase; + FbStride widthSrc; + int srcBpp; + int srcXoff, srcYoff; + + if (args->opaque && sourceInvarient (pGC->alu)) + { + s3FillBoxSolid (pDstDrawable, nbox, pbox, + pGC->bgPixel, pGC->alu, pGC->planemask); + return; + } + + s3SetGlobalBitmap (pDstDrawable->pScreen, s3GCMap (pGC)); + fbGetStipDrawable (pSrcDrawable, psrcBase, widthSrc, srcBpp, srcXoff, srcYoff); + + if (args->opaque) + { + _s3SetOpaquePlaneBlt(s3,pGC->alu,pGC->planemask,args->copyPlaneFG, + args->copyPlaneBG); + } + else + { + _s3SetTransparentPlaneBlt (s3, pGC->alu, + pGC->planemask, args->copyPlaneFG); + } + + while (nbox--) + { + dstx = pbox->x1; + dsty = pbox->y1; + + _s3Stipple (s3c, + psrcBase, widthSrc, + dstx + dx - srcXoff, dsty + dy - srcYoff, + dstx, dsty, + pbox->x2 - dstx, pbox->y2 - dsty); + pbox++; + } + MarkSyncS3 (pDstDrawable->pScreen); +} + +RegionPtr +s3CopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, + int srcx, int srcy, int width, int height, + int dstx, int dsty, unsigned long bitPlane) +{ + SetupS3 (pDstDrawable->pScreen); + RegionPtr ret; + s31toNargs args; + + if (pDstDrawable->type == DRAWABLE_WINDOW && + pSrcDrawable->depth == 1) + { + args.copyPlaneFG = pGC->fgPixel; + args.copyPlaneBG = pGC->bgPixel; + args.opaque = TRUE; + return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, + dstx, dsty, s3Copy1toN, bitPlane, &args); + } + return KdCheckCopyPlane(pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, + dstx, dsty, bitPlane); +} + +void +s3PushPixels (GCPtr pGC, PixmapPtr pBitmap, + DrawablePtr pDrawable, + int w, int h, int x, int y) +{ + SetupS3 (pDrawable->pScreen); + s31toNargs args; + + if (pDrawable->type == DRAWABLE_WINDOW && pGC->fillStyle == FillSolid) + { + args.opaque = FALSE; + args.copyPlaneFG = pGC->fgPixel; + (void) fbDoCopy ((DrawablePtr) pBitmap, pDrawable, pGC, + 0, 0, w, h, x, y, s3Copy1toN, 1, &args); + } + else + { + KdCheckPushPixels (pGC, pBitmap, pDrawable, w, h, x, y); + } +} + +void +s3FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, + unsigned long pixel, int alu, unsigned long planemask) +{ + SetupS3(pDrawable->pScreen); + register int r; + + s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable)); + _s3SetSolidFill(s3,pixel,alu,planemask); + + while (nBox--) { + _s3SolidRect(s3,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1); + pBox++; + } + MarkSyncS3 (pDrawable->pScreen); +} + +void +_s3SetPattern (ScreenPtr pScreen, int ma, + int alu, unsigned long planemask, s3PatternPtr pPattern) +{ + SetupS3(pScreen); + S3PatternCache *cache; + + _s3LoadPattern (pScreen, ma, pPattern); + cache = pPattern->cache; + + switch (pPattern->fillStyle) { + case FillTiled: + _s3SetTile(s3,alu,planemask); + break; + case FillStippled: + _s3SetStipple(s3,alu,planemask,pPattern->fore); + break; + case FillOpaqueStippled: + _s3SetOpaqueStipple(s3,alu,planemask,pPattern->fore,pPattern->back); + break; + } +} + +void +s3FillBoxPattern (DrawablePtr pDrawable, int nBox, BoxPtr pBox, + int alu, unsigned long planemask, s3PatternPtr pPattern) +{ + SetupS3(pDrawable->pScreen); + S3PatternCache *cache; + int patx, paty; + + s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable)); + _s3SetPattern (pDrawable->pScreen, s3DrawMap(pDrawable), alu, planemask, pPattern); + cache = pPattern->cache; + while (nBox--) + { + _s3PatRect(s3,cache->x, cache->y, + pBox->x1, pBox->y1, + pBox->x2-pBox->x1, pBox->y2-pBox->y1); + pBox++; + } + MarkSyncS3 (pDrawable->pScreen); +} + +void +s3FillBoxLargeStipple (DrawablePtr pDrawable, GCPtr pGC, + int nBox, BoxPtr pBox) +{ + SetupS3(pDrawable->pScreen); + DrawablePtr pStipple = &pGC->stipple->drawable; + int xRot = pGC->patOrg.x + pDrawable->x; + int yRot = pGC->patOrg.y + pDrawable->y; + FbStip *stip; + FbStride stipStride; + int stipBpp; + int stipXoff, stipYoff; + int stipWidth, stipHeight; + int dstX, dstY, width, height; + + stipWidth = pStipple->width; + stipHeight = pStipple->height; + fbGetStipDrawable (pStipple, stip, stipStride, stipBpp, stipXoff, stipYoff); + + s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable)); + if (pGC->fillStyle == FillOpaqueStippled) + { + _s3SetOpaquePlaneBlt(s3,pGC->alu,pGC->planemask, + pGC->fgPixel, pGC->bgPixel); + + } + else + { + _s3SetTransparentPlaneBlt(s3,pGC->alu,pGC->planemask, pGC->fgPixel); + } + + while (nBox--) + { + int stipX, stipY, sx; + int widthTmp; + int h, w; + int x, y; + + dstX = pBox->x1; + dstY = pBox->y1; + width = pBox->x2 - pBox->x1; + height = pBox->y2 - pBox->y1; + pBox++; + modulus (dstY - yRot - stipYoff, stipHeight, stipY); + modulus (dstX - xRot - stipXoff, stipWidth, stipX); + y = dstY; + while (height) + { + h = stipHeight - stipY; + if (h > height) + h = height; + height -= h; + widthTmp = width; + x = dstX; + sx = stipX; + while (widthTmp) + { + w = (stipWidth - sx); + if (w > widthTmp) + w = widthTmp; + widthTmp -= w; + _s3Stipple (s3c, + stip, + stipStride, + sx, stipY, + x, y, + w, h); + x += w; + sx = 0; + } + y += h; + stipY = 0; + } + } + MarkSyncS3 (pDrawable->pScreen); +} + +#define NUM_STACK_RECTS 1024 + +void +s3PolyFillRect (DrawablePtr pDrawable, GCPtr pGC, + int nrectFill, xRectangle *prectInit) +{ + s3GCPrivate(pGC); + xRectangle *prect; + RegionPtr prgnClip; + register BoxPtr pbox; + register BoxPtr pboxClipped; + BoxPtr pboxClippedBase; + BoxPtr pextent; + BoxRec stackRects[NUM_STACK_RECTS]; + int numRects; + int n; + int xorg, yorg; + int x, y; + + prgnClip = fbGetCompositeClip(pGC); + xorg = pDrawable->x; + yorg = pDrawable->y; + + if (xorg || yorg) + { + prect = prectInit; + n = nrectFill; + while(n--) + { + prect->x += xorg; + prect->y += yorg; + prect++; + } + } + + prect = prectInit; + + numRects = REGION_NUM_RECTS(prgnClip) * nrectFill; + if (numRects > NUM_STACK_RECTS) + { + pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec)); + if (!pboxClippedBase) + return; + } + else + pboxClippedBase = stackRects; + + pboxClipped = pboxClippedBase; + + if (REGION_NUM_RECTS(prgnClip) == 1) + { + int x1, y1, x2, y2, bx2, by2; + + pextent = REGION_RECTS(prgnClip); + x1 = pextent->x1; + y1 = pextent->y1; + x2 = pextent->x2; + y2 = pextent->y2; + while (nrectFill--) + { + if ((pboxClipped->x1 = prect->x) < x1) + pboxClipped->x1 = x1; + + if ((pboxClipped->y1 = prect->y) < y1) + pboxClipped->y1 = y1; + + bx2 = (int) prect->x + (int) prect->width; + if (bx2 > x2) + bx2 = x2; + pboxClipped->x2 = bx2; + + by2 = (int) prect->y + (int) prect->height; + if (by2 > y2) + by2 = y2; + pboxClipped->y2 = by2; + + prect++; + if ((pboxClipped->x1 < pboxClipped->x2) && + (pboxClipped->y1 < pboxClipped->y2)) + { + pboxClipped++; + } + } + } + else + { + int x1, y1, x2, y2, bx2, by2; + + pextent = REGION_EXTENTS(pGC->pScreen, prgnClip); + x1 = pextent->x1; + y1 = pextent->y1; + x2 = pextent->x2; + y2 = pextent->y2; + while (nrectFill--) + { + BoxRec box; + + if ((box.x1 = prect->x) < x1) + box.x1 = x1; + + if ((box.y1 = prect->y) < y1) + box.y1 = y1; + + bx2 = (int) prect->x + (int) prect->width; + if (bx2 > x2) + bx2 = x2; + box.x2 = bx2; + + by2 = (int) prect->y + (int) prect->height; + if (by2 > y2) + by2 = y2; + box.y2 = by2; + + prect++; + + if ((box.x1 >= box.x2) || (box.y1 >= box.y2)) + continue; + + n = REGION_NUM_RECTS (prgnClip); + pbox = REGION_RECTS(prgnClip); + + /* clip the rectangle to each box in the clip region + this is logically equivalent to calling Intersect() + */ + while(n--) + { + pboxClipped->x1 = max(box.x1, pbox->x1); + pboxClipped->y1 = max(box.y1, pbox->y1); + pboxClipped->x2 = min(box.x2, pbox->x2); + pboxClipped->y2 = min(box.y2, pbox->y2); + pbox++; + + /* see if clipping left anything */ + if(pboxClipped->x1 < pboxClipped->x2 && + pboxClipped->y1 < pboxClipped->y2) + { + pboxClipped++; + } + } + } + } + if (pboxClipped != pboxClippedBase) + { + if (pGC->fillStyle == FillSolid) + s3FillBoxSolid(pDrawable, + pboxClipped-pboxClippedBase, pboxClippedBase, + pGC->fgPixel, pGC->alu, pGC->planemask); + else if (s3Priv->pPattern) + s3FillBoxPattern (pDrawable, + pboxClipped-pboxClippedBase, pboxClippedBase, + pGC->alu, pGC->planemask, + s3Priv->pPattern); + else + s3FillBoxLargeStipple (pDrawable, pGC, + pboxClipped-pboxClippedBase, + pboxClippedBase); + } + if (pboxClippedBase != stackRects) + xfree(pboxClippedBase); +} + +void +_s3FillSpanLargeStipple (DrawablePtr pDrawable, GCPtr pGC, + int n, DDXPointPtr ppt, int *pwidth) +{ + SetupS3 (pDrawable->pScreen); + DrawablePtr pStipple = &pGC->stipple->drawable; + int xRot = pGC->patOrg.x + pDrawable->x; + int yRot = pGC->patOrg.y + pDrawable->y; + FbStip *stip; + FbStride stipStride; + int stipBpp; + int stipXoff, stipYoff; + int stipWidth, stipHeight; + int dstX, dstY, width, height; + + s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); + stipWidth = pStipple->width; + stipHeight = pStipple->height; + fbGetStipDrawable (pStipple, stip, stipStride, stipBpp, stipXoff, stipYoff); + if (pGC->fillStyle == FillOpaqueStippled) + { + _s3SetOpaquePlaneBlt(s3,pGC->alu,pGC->planemask, + pGC->fgPixel, pGC->bgPixel); + + } + else + { + _s3SetTransparentPlaneBlt(s3,pGC->alu,pGC->planemask, pGC->fgPixel); + } + while (n--) + { + int stipX, stipY, sx; + int w; + int x, y; + + dstX = ppt->x; + dstY = ppt->y; + ppt++; + width = *pwidth++; + modulus (dstY - yRot - stipYoff, stipHeight, stipY); + modulus (dstX - xRot - stipXoff, stipWidth, stipX); + y = dstY; + x = dstX; + sx = stipX; + while (width) + { + w = (stipWidth - sx); + if (w > width) + w = width; + width -= w; + _s3Stipple (s3c, + stip, + stipStride, + sx, stipY, + x, y, + w, 1); + x += w; + sx = 0; + } + } +} + +void +s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n, + DDXPointPtr ppt, int *pwidth, int fSorted) +{ + s3GCPrivate(pGC); + SetupS3(pDrawable->pScreen); + int x, y, x1, y1, x2, y2; + int width; + /* next three parameters are post-clip */ + int nTmp; + int *pwidthFree;/* copies of the pointers to free */ + DDXPointPtr pptFree; + BoxPtr extents; + S3PatternCache *cache; + RegionPtr pClip = fbGetCompositeClip (pGC); + + s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); + if (REGION_NUM_RECTS(pClip) == 1 && + (pGC->fillStyle == FillSolid || s3Priv->pPattern)) + { + extents = REGION_RECTS(pClip); + x1 = extents->x1; + x2 = extents->x2; + y1 = extents->y1; + y2 = extents->y2; + if (pGC->fillStyle == FillSolid) + { + _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask); + cache = 0; + } + else + { + _s3SetPattern (pDrawable->pScreen, s3GCMap(pGC), pGC->alu, pGC->planemask, + s3Priv->pPattern); + cache = s3Priv->pPattern->cache; + } + while (n--) + { + y = ppt->y; + if (y1 <= y && y < y2) + { + x = ppt->x; + width = *pwidth; + if (x < x1) + { + width -= (x1 - x); + x = x1; + } + if (x2 < x + width) + width = x2 - x; + if (width > 0) + { + if (cache) + { + _s3PatRect(s3, cache->x, cache->y, x, y, width, 1); + } + else + { + _s3SolidRect(s3,x,y,width,1); + } + } + } + ppt++; + pwidth++; + } + } + else + { + nTmp = n * miFindMaxBand(pClip); + pwidthFree = (int *)xalloc(nTmp * sizeof(int)); + pptFree = (DDXPointRec *)xalloc(nTmp * sizeof(DDXPointRec)); + if(!pptFree || !pwidthFree) + { + if (pptFree) xfree(pptFree); + if (pwidthFree) xfree(pwidthFree); + return; + } + n = miClipSpans(fbGetCompositeClip(pGC), + ppt, pwidth, n, + pptFree, pwidthFree, fSorted); + pwidth = pwidthFree; + ppt = pptFree; + if (pGC->fillStyle == FillSolid) + { + _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask); + while (n--) + { + x = ppt->x; + y = ppt->y; + ppt++; + width = *pwidth++; + if (width) + { + _s3SolidRect(s3,x,y,width,1); + } + } + } + else if (s3Priv->pPattern) + { + _s3SetPattern (pDrawable->pScreen, s3GCMap(pGC), pGC->alu, pGC->planemask, + s3Priv->pPattern); + cache = s3Priv->pPattern->cache; + while (n--) + { + x = ppt->x; + y = ppt->y; + ppt++; + width = *pwidth++; + if (width) + { + _s3PatRect(s3, cache->x, cache->y, x, y, width, 1); + } + } + } + else + { + _s3FillSpanLargeStipple (pDrawable, pGC, n, ppt, pwidth); + } + xfree(pptFree); + xfree(pwidthFree); + } + MarkSyncS3 (pDrawable->pScreen); +} + +#include "mifillarc.h" + +#define FILLSPAN(s3,y,__x1,__x2) {\ + DRAW_DEBUG ((DEBUG_ARCS, "FILLSPAN %d: %d->%d", y, __x1, __x2)); \ + if ((__x2) >= (__x1)) {\ + _s3SolidRect(s3,(__x1),(y),(__x2)-(__x1)+1,1); \ + } \ +} + +#define FILLSLICESPANS(flip,__y) \ + if (!flip) \ + { \ + FILLSPAN(s3,__y,xl,xr) \ + } \ + else \ + { \ + xc = xorg - x; \ + FILLSPAN(s3, __y, xc, xr) \ + xc += slw - 1; \ + FILLSPAN(s3, __y, xl, xc) \ + } + +static void +_s3FillEllipse (DrawablePtr pDraw, S3Ptr s3, xArc *arc) +{ + KdScreenPriv(pDraw->pScreen); + int x, y, e; + int yk, xk, ym, xm, dx, dy, xorg, yorg; + int y_top, y_bot; + miFillArcRec info; + register int xpos; + int slw; + + s3SetGlobalBitmap (pDraw->pScreen, s3DrawMap (pDraw)); + miFillArcSetup(arc, &info); + MIFILLARCSETUP(); + y_top = pDraw->y + yorg - y; + y_bot = pDraw->y + yorg + y + dy; + xorg += pDraw->x; + while (y) + { + y_top++; + y_bot--; + MIFILLARCSTEP(slw); + if (!slw) + continue; + xpos = xorg - x; + _s3SolidRect (s3,xpos,y_top,slw,1); + if (miFillArcLower(slw)) + _s3SolidRect (s3,xpos,y_bot,slw,1); + } +} + + +static void +_s3FillArcSlice (DrawablePtr pDraw, GCPtr pGC, S3Ptr s3, xArc *arc) +{ + KdScreenPriv(pDraw->pScreen); + int yk, xk, ym, xm, dx, dy, xorg, yorg, slw; + register int x, y, e; + miFillArcRec info; + miArcSliceRec slice; + int xl, xr, xc; + int y_top, y_bot; + + s3SetGlobalBitmap (pDraw->pScreen, s3DrawMap (pDraw)); + DRAW_DEBUG ((DEBUG_ARCS, "slice %dx%d+%d+%d %d->%d", + arc->width, arc->height, arc->x, arc->y, + arc->angle1, arc->angle2)); + miFillArcSetup(arc, &info); + miFillArcSliceSetup(arc, &slice, pGC); + DRAW_DEBUG ((DEBUG_ARCS, "edge1.x %d edge2.x %d", + slice.edge1.x, slice.edge2.x)); + MIFILLARCSETUP(); + DRAW_DEBUG ((DEBUG_ARCS, "xorg %d yorg %d", + xorg, yorg)); + xorg += pDraw->x; + yorg += pDraw->y; + y_top = yorg - y; + y_bot = yorg + y + dy; + slice.edge1.x += pDraw->x; + slice.edge2.x += pDraw->x; + DRAW_DEBUG ((DEBUG_ARCS, "xorg %d y_top %d y_bot %d", + xorg, y_top, y_bot)); + while (y > 0) + { + y_top++; + y_bot--; + MIFILLARCSTEP(slw); + MIARCSLICESTEP(slice.edge1); + MIARCSLICESTEP(slice.edge2); + if (miFillSliceUpper(slice)) + { + MIARCSLICEUPPER(xl, xr, slice, slw); + FILLSLICESPANS(slice.flip_top, y_top); + } + if (miFillSliceLower(slice)) + { + MIARCSLICELOWER(xl, xr, slice, slw); + FILLSLICESPANS(slice.flip_bot, y_bot); + } + } +} + +void +s3PolyFillArcSolid (DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs) +{ + SetupS3(pDraw->pScreen); + xArc *arc; + int i; + int x, y; + BoxRec box; + RegionPtr pClip = fbGetCompositeClip(pGC); + BOOL set; + + set = FALSE; + for (; --narcs >= 0; parcs++) + { + if (miFillArcEmpty(parcs)) + continue; + if (miCanFillArc(parcs)) + { + box.x1 = parcs->x + pDraw->x; + box.y1 = parcs->y + pDraw->y; + box.x2 = box.x1 + (int)parcs->width + 1; + box.y2 = box.y1 + (int)parcs->height + 1; + switch (RECT_IN_REGION(pDraw->pScreen, pClip, &box)) + { + case rgnIN: + if (!set) + { + _s3SetSolidFill (s3, pGC->fgPixel, pGC->alu, pGC->planemask); + set = TRUE; + } + if ((parcs->angle2 >= FULLCIRCLE) || + (parcs->angle2 <= -FULLCIRCLE)) + { + DRAW_DEBUG ((DEBUG_ARCS, "Full circle ellipse %dx%d", + parcs->width, parcs->height)); + _s3FillEllipse (pDraw, s3, parcs); + } + else + { + DRAW_DEBUG ((DEBUG_ARCS, "Partial ellipse %dx%d", + parcs->width, parcs->height)); + _s3FillArcSlice (pDraw, pGC, s3, parcs); + } + /* fall through ... */ + case rgnOUT: + continue; + case rgnPART: + break; + } + } + if (set) + { + MarkSyncS3 (pDraw->pScreen); + set = FALSE; + } + KdCheckPolyFillArc(pDraw, pGC, 1, parcs); + } + if (set) + { + MarkSyncS3 (pDraw->pScreen); + set = FALSE; + } +} + +void +s3FillPoly (DrawablePtr pDrawable, GCPtr pGC, int shape, + int mode, int countInit, DDXPointPtr ptsIn) +{ + SetupS3(pDrawable->pScreen); + int nwidth; + int maxy; + int origin; + int count; + register int vertex1, vertex2; + int c; + RegionPtr pClip = fbGetCompositeClip(pGC); + BoxPtr extents; + int clip; + int y, sy; + int *vertex1p, *vertex2p; + int *endp; + int x1, x2, sx; + int dx1, dx2; + int dy1, dy2; + int e1, e2; + int step1, step2; + int sign1, sign2; + int h; + int l, r; + int nmiddle; + + if (mode == CoordModePrevious || REGION_NUM_RECTS(pClip) != 1) + { + KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn); + return; + } + + s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); + sy = pDrawable->y; + sx = pDrawable->x; + origin = *((int *) &pDrawable->x); + origin -= (origin & 0x8000) << 1; + extents = &pClip->extents; + vertex1 = *((int *) &extents->x1) - origin; + vertex2 = *((int *) &extents->x2) - origin - 0x00010001; + clip = 0; + + y = 32767; + maxy = 0; + vertex2p = (int *) ptsIn; + endp = vertex2p + countInit; + if (shape == Convex) + { + count = countInit; + while (count--) + { + c = *vertex2p; + clip |= (c - vertex1) | (vertex2 - c); + c = intToY(c); + DRAW_DEBUG ((DEBUG_POLYGON, "Y coordinate %d", c)); + if (c < y) + { + y = c; + vertex1p = vertex2p; + } + vertex2p++; + if (c > maxy) + maxy = c; + } + } + else + { + int yFlip = 0; + dx1 = 1; + x2 = -1; + x1 = -1; + count = countInit; + while (count--) + { + c = *vertex2p; + clip |= (c - vertex1) | (vertex2 - c); + c = intToY(c); + DRAW_DEBUG ((DEBUG_POLYGON, "Y coordinate %d", c)); + if (c < y) + { + y = c; + vertex1p = vertex2p; + } + vertex2p++; + if (c > maxy) + maxy = c; + if (c == x1) + continue; + if (dx1 > 0) + { + if (x2 < 0) + x2 = c; + else + dx2 = dx1 = (c - x1) >> 31; + } + else + if ((c - x1) >> 31 != dx1) + { + dx1 = ~dx1; + yFlip++; + } + x1 = c; + } + x1 = (x2 - c) >> 31; + if (x1 != dx1) + yFlip++; + if (x1 != dx2) + yFlip++; + if (yFlip != 2) + clip = 0x8000; + } + if (y == maxy) + return; + + if (clip & 0x80008000) + { + KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn); + return; + } + _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask); + + vertex2p = vertex1p; + vertex2 = vertex1 = *vertex2p++; + if (vertex2p == endp) + vertex2p = (int *) ptsIn; +#define Setup(c,x,vertex,dx,dy,e,sign,step) {\ + x = intToX(vertex); \ + if (dy = intToY(c) - y) { \ + dx = intToX(c) - x; \ + step = 0; \ + if (dx >= 0) \ + { \ + e = 0; \ + sign = 1; \ + if (dx >= dy) {\ + step = dx / dy; \ + dx = dx % dy; \ + } \ + } \ + else \ + { \ + e = 1 - dy; \ + sign = -1; \ + dx = -dx; \ + if (dx >= dy) { \ + step = - (dx / dy); \ + dx = dx % dy; \ + } \ + } \ + } \ + x += sx; \ + vertex = c; \ +} + +#define Step(x,dx,dy,e,sign,step) {\ + x += step; \ + if ((e += dx) > 0) \ + { \ + x += sign; \ + e -= dy; \ + } \ +} + sy += y; + DRAW_DEBUG ((DEBUG_POLYGON, "Starting polygon at %d", sy)); + for (;;) + { + DRAW_DEBUG ((DEBUG_POLYGON, "vertex1 0x%x vertex2 0x%x y %d vy1 %d vy2 %d", + vertex1, vertex2, + y, intToY(vertex1), intToY (vertex2))); + if (y == intToY(vertex1)) + { + DRAW_DEBUG ((DEBUG_POLYGON, "Find next -- vertext")); + do + { + if (vertex1p == (int *) ptsIn) + vertex1p = endp; + c = *--vertex1p; + Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1); + DRAW_DEBUG ((DEBUG_POLYGON, "-- vertex 0x%x y %d", + vertex1, intToY(vertex1))); + } while (y >= intToY(vertex1)); + h = dy1; + } + else + { + Step(x1,dx1,dy1,e1,sign1,step1) + h = intToY(vertex1) - y; + } + if (y == intToY(vertex2)) + { + DRAW_DEBUG ((DEBUG_POLYGON, "Find next ++ vertext")); + do + { + c = *vertex2p++; + if (vertex2p == endp) + vertex2p = (int *) ptsIn; + Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2) + DRAW_DEBUG ((DEBUG_POLYGON, "++ vertex 0x%x y %d", + vertex1, intToY(vertex1))); + } while (y >= intToY(vertex2)); + if (dy2 < h) + h = dy2; + } + else + { + Step(x2,dx2,dy2,e2,sign2,step2) + if ((c = (intToY(vertex2) - y)) < h) + h = c; + } + DRAW_DEBUG ((DEBUG_POLYGON, "This band %d", h)); + /* fill spans for this segment */ + for (;;) + { + nmiddle = x2 - x1; + DRAW_DEBUG ((DEBUG_POLYGON, "This span %d->%d", x1, x2)); + if (nmiddle) + { + l = x1; + if (nmiddle < 0) + { + nmiddle = -nmiddle; + l = x2; + } + _s3SolidRect(s3,l,sy,nmiddle,1); + } + y++; + sy++; + if (!--h) + break; + Step(x1,dx1,dy1,e1,sign1,step1) + Step(x2,dx2,dy2,e2,sign2,step2) + } + if (y == maxy) + break; + } + MarkSyncS3 (pDrawable->pScreen); +} + +void +s3PolyGlyphBltClipped (DrawablePtr pDrawable, + GCPtr pGC, + int x, int y, + unsigned int nglyph, + CharInfoPtr *ppciInit, + pointer pglyphBase) +{ + SetupS3(pDrawable->pScreen); + int h; + int w; + int xBack, yBack; + int hBack, wBack; + int lw; + FontPtr pfont = pGC->font; + CharInfoPtr pci; + unsigned long *bits; + BoxPtr extents; + BoxRec bbox; + CARD32 b; + CharInfoPtr *ppci; + FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC); + RegionPtr pClip = fbGetCompositeClip(pGC); + BoxPtr pBox; + int nbox; + int x1, y1, x2, y2; + unsigned char alu; + Bool set; + PixTransDeclare; + + s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); + x += pDrawable->x; + y += pDrawable->y; + + if (pglyphBase == (pointer) 1) + { + xBack = x; + yBack = y - FONTASCENT(pGC->font); + wBack = 0; + hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); + if (hBack) + { + h = nglyph; + ppci = ppciInit; + while (h--) + wBack += (*ppci++)->metrics.characterWidth; + } + if (wBack < 0) + { + xBack = xBack + wBack; + wBack = -wBack; + } + if (hBack < 0) + { + yBack = yBack + hBack; + hBack = -hBack; + } + alu = GXcopy; + } + else + { + wBack = 0; + alu = pGC->alu; + } + + if (wBack) + { + _s3SetSolidFill (s3, pGC->bgPixel, GXcopy, pGC->planemask); + for (nbox = REGION_NUM_RECTS (pClip), + pBox = REGION_RECTS (pClip); + nbox--; + pBox++) + { + x1 = xBack; + x2 = xBack + wBack; + y1 = yBack; + y2 = yBack + hBack; + if (x1 < pBox->x1) x1 = pBox->x1; + if (x2 > pBox->x2) x2 = pBox->x2; + if (y1 < pBox->y1) y1 = pBox->y1; + if (y2 > pBox->y2) y2 = pBox->y2; + if (x1 < x2 && y1 < y2) + { + _s3SolidRect (s3, x1, y1, x2 - x1, y2 - y1); + } + } + MarkSyncS3 (pDrawable->pScreen); + } + ppci = ppciInit; + set = FALSE; + while (nglyph--) + { + pci = *ppci++; + h = pci->metrics.ascent + pci->metrics.descent; + w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; + x1 = x + pci->metrics.leftSideBearing; + y1 = y - pci->metrics.ascent; + bbox.x1 = x1; + bbox.y1 = y1; + bbox.x2 = x1 + w; + bbox.y2 = y1 + h; + switch (RECT_IN_REGION(pGC->pScreen, pClip, &bbox)) + { + case rgnIN: +#if 1 + lw = h * ((w + 31) >> 5); + if (lw) + { + if (!set) + { + _s3SetTransparentPlaneBlt (s3, alu, pGC->planemask, pGC->fgPixel); + set = TRUE; + } + _s3PlaneBlt(s3, + x + pci->metrics.leftSideBearing, + y - pci->metrics.ascent, + w, h); + bits = (unsigned long *) pci->bits; + PixTransStart (lw); + while (lw--) + { + b = *bits++; + S3AdjustBits32 (b); + PixTransStore(b); + } + MarkSyncS3 (pDrawable->pScreen); + } + break; +#endif + case rgnPART: + set = FALSE; + CheckSyncS3 (pDrawable->pScreen); + fbPutXYImage (pDrawable, + pClip, + fbPriv->fg, + fbPriv->bg, + fbPriv->pm, + alu, + FALSE, + x1, y1, + w, h, + (FbStip *) pci->bits, + (w + 31) >> 5, + 0); + break; + case rgnOUT: + break; + } + x += pci->metrics.characterWidth; + } +} + +/* + * Blt glyphs using S3 image transfer register, this does both + * poly glyph blt and image glyph blt (when pglyphBase == 1) + */ + +void +s3PolyGlyphBlt (DrawablePtr pDrawable, + GCPtr pGC, + int x, int y, + unsigned int nglyph, + CharInfoPtr *ppciInit, + pointer pglyphBase) +{ + SetupS3(pDrawable->pScreen); + int h; + int w; + int xBack, yBack; + int hBack, wBack; + int lw; + FontPtr pfont = pGC->font; + CharInfoPtr pci; + unsigned long *bits; + BoxPtr extents; + BoxRec bbox; + CARD32 b; + CharInfoPtr *ppci; + unsigned char alu; + PixTransDeclare; + + s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); + x += pDrawable->x; + y += pDrawable->y; + + /* compute an approximate (but covering) bounding box */ + ppci = ppciInit; + w = 0; + h = nglyph; + while (h--) + w += (*ppci++)->metrics.characterWidth; + if (w < 0) + { + bbox.x1 = x + w; + bbox.x2 = x; + } + else + { + bbox.x1 = x; + bbox.x2 = x + w; + } + w = FONTMINBOUNDS(pfont,leftSideBearing); + if (w < 0) + bbox.x1 += w; + w = FONTMAXBOUNDS(pfont, rightSideBearing) - FONTMINBOUNDS(pfont, characterWidth); + if (w > 0) + bbox.x2 += w; + bbox.y1 = y - FONTMAXBOUNDS(pfont,ascent); + bbox.y2 = y + FONTMAXBOUNDS(pfont,descent); + + DRAW_DEBUG ((DEBUG_TEXT, "PolyGlyphBlt %d box is %d %d", nglyph, + bbox.x1, bbox.x2)); + switch (RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox)) + { + case rgnIN: + break; + case rgnPART: + s3PolyGlyphBltClipped(pDrawable, pGC, x - pDrawable->x, + y - pDrawable->y, + nglyph, ppciInit, pglyphBase); + case rgnOUT: + return; + } + + if (pglyphBase == (pointer) 1) + { + xBack = x; + yBack = y - FONTASCENT(pGC->font); + wBack = 0; + hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); + if (hBack) + { + h = nglyph; + ppci = ppciInit; + while (h--) + wBack += (*ppci++)->metrics.characterWidth; + } + if (wBack < 0) + { + xBack = xBack + wBack; + wBack = -wBack; + } + if (hBack < 0) + { + yBack = yBack + hBack; + hBack = -hBack; + } + alu = GXcopy; + } + else + { + wBack = 0; + alu = pGC->alu; + } + + if (wBack) + { + _s3SetSolidFill (s3, pGC->bgPixel, GXcopy, pGC->planemask); + _s3SolidRect (s3, xBack, yBack, wBack, hBack); + } + _s3SetTransparentPlaneBlt (s3, alu, pGC->planemask, pGC->fgPixel); + ppci = ppciInit; + while (nglyph--) + { + pci = *ppci++; + h = pci->metrics.ascent + pci->metrics.descent; + w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing; + lw = h * ((w + 31) >> 5); + if (lw) + { + _s3PlaneBlt(s3, + x + pci->metrics.leftSideBearing, + y - pci->metrics.ascent, + w, h); + bits = (unsigned long *) pci->bits; + PixTransStart(lw); + while (lw--) + { + b = *bits++; + S3AdjustBits32 (b); + PixTransStore(b); + } + } + x += pci->metrics.characterWidth; + } + MarkSyncS3 (pDrawable->pScreen); +} + +void +s3ImageGlyphBlt (DrawablePtr pDrawable, + GCPtr pGC, + int x, int y, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase) +{ + s3PolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, (pointer) 1); +} + +/* + * Blt TE fonts using S3 image transfer. Differs from + * above in that it doesn't need to fill a solid rect for + * the background and it can draw multiple characters at a time + */ + +void +s3ImageTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, + int xInit, int yInit, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase) +{ + SetupS3(pDrawable->pScreen); + int x, y; + int h, lw, lwTmp; + int w; + FontPtr pfont = pGC->font; + unsigned long *char1, *char2, *char3, *char4; + int widthGlyphs, widthGlyph; + BoxRec bbox; + CARD32 tmp; + PixTransDeclare; + + s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); + widthGlyph = FONTMAXBOUNDS(pfont,characterWidth); + if (!widthGlyph) + return; + + h = FONTASCENT(pfont) + FONTDESCENT(pfont); + if (!h) + return; + + DRAW_DEBUG ((DEBUG_TEXT, "ImageTEGlyphBlt chars are %d %d", + widthGlyph, h)); + + x = xInit + FONTMAXBOUNDS(pfont,leftSideBearing) + pDrawable->x; + y = yInit - FONTASCENT(pfont) + pDrawable->y; + + bbox.x1 = x; + bbox.x2 = x + (widthGlyph * nglyph); + bbox.y1 = y; + bbox.y2 = y + h; + + switch (RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox)) + { + case rgnIN: + break; + case rgnPART: + if (pglyphBase == (pointer) 1) + pglyphBase = 0; + else + pglyphBase = (pointer) 1; + s3PolyGlyphBltClipped(pDrawable, pGC, + xInit, + yInit, + nglyph, ppci, + pglyphBase); + case rgnOUT: + return; + } + + if (pglyphBase == (pointer) 1) + { + _s3SetTransparentPlaneBlt (s3, pGC->alu, pGC->planemask, pGC->fgPixel); + } + else + { + _s3SetOpaquePlaneBlt (s3, GXcopy, pGC->planemask, pGC->fgPixel, pGC->bgPixel); + } + +#if BITMAP_BIT_ORDER == LSBFirst +#define SHIFT << +#else +#define SHIFT >> +#endif + +#define LoopIt(count, w, loadup, fetch) \ + while (nglyph >= count) \ + { \ + nglyph -= count; \ + _s3PlaneBlt (s3, x, y, w, h); \ + x += w; \ + loadup \ + lwTmp = h; \ + PixTransStart(h); \ + while (lwTmp--) { \ + tmp = fetch; \ + S3AdjustBits32(tmp); \ + PixTransStore(tmp); \ + } \ + } + + if (widthGlyph <= 8) + { + widthGlyphs = widthGlyph << 2; + LoopIt(4, widthGlyphs, + char1 = (unsigned long *) (*ppci++)->bits; + char2 = (unsigned long *) (*ppci++)->bits; + char3 = (unsigned long *) (*ppci++)->bits; + char4 = (unsigned long *) (*ppci++)->bits;, + (*char1++ | ((*char2++ | ((*char3++ | (*char4++ + SHIFT widthGlyph)) + SHIFT widthGlyph)) + SHIFT widthGlyph))) + } + else if (widthGlyph <= 10) + { + widthGlyphs = (widthGlyph << 1) + widthGlyph; + LoopIt(3, widthGlyphs, + char1 = (unsigned long *) (*ppci++)->bits; + char2 = (unsigned long *) (*ppci++)->bits; + char3 = (unsigned long *) (*ppci++)->bits;, + (*char1++ | ((*char2++ | (*char3++ SHIFT widthGlyph)) SHIFT widthGlyph))) + } + else if (widthGlyph <= 16) + { + widthGlyphs = widthGlyph << 1; + LoopIt(2, widthGlyphs, + char1 = (unsigned long *) (*ppci++)->bits; + char2 = (unsigned long *) (*ppci++)->bits;, + (*char1++ | (*char2++ SHIFT widthGlyph))) + } + lw = h * ((widthGlyph + 31) >> 5); + while (nglyph--) + { + _s3PlaneBlt (s3, x, y, widthGlyph, h); + x += widthGlyph; + char1 = (unsigned long *) (*ppci++)->bits; + lwTmp = lw; + PixTransStart(lw); + while (lwTmp--) + { + tmp = *char1++; + S3AdjustBits32(tmp); + PixTransStore(tmp); + } + } + MarkSyncS3 (pDrawable->pScreen); +} + +void +s3PolyTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, + int x, int y, + unsigned int nglyph, CharInfoPtr *ppci, + pointer pglyphBase) +{ + s3ImageTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, (pointer) 1); +} + +Bool +_s3Segment (DrawablePtr pDrawable, + GCPtr pGC, + int x1, + int y1, + int x2, + int y2, + Bool drawLast, + Bool s3Set) +{ + SetupS3(pDrawable->pScreen); + FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); + RegionPtr pClip = fbGetCompositeClip(pGC); + BoxPtr pBox; + int nBox; + int adx; /* abs values of dx and dy */ + int ady; + int signdx; /* sign of dx and dy */ + int signdy; + int e, e1, e2; /* bresenham error and increments */ + int len; /* length of segment */ + int axis; /* major axis */ + int octant; + int cmd; + unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); + unsigned int oc1; /* outcode of point 1 */ + unsigned int oc2; /* outcode of point 2 */ + + CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy, + 1, 1, octant); + + cmd = LASTPIX; + + if (adx > ady) + { + axis = X_AXIS; + e1 = ady << 1; + e2 = e1 - (adx << 1); + e = e1 - adx; + len = adx; + } + else + { + cmd |= YMAJAXIS; + axis = Y_AXIS; + e1 = adx << 1; + e2 = e1 - (ady << 1); + e = e1 - ady; + SetYMajorOctant(octant); + len = ady; + } + + /* S3 line drawing hardware has limited resolution for error terms */ + if (len >= 4096) + { + int dashOff = 0; + + KdCheckSync (pDrawable->pScreen); + fbSegment (pDrawable, pGC, x1, y1, x2, y2, drawLast, &dashOff); + return FALSE; + } + + FIXUP_ERROR (e, octant, bias); + + nBox = REGION_NUM_RECTS (pClip); + pBox = REGION_RECTS (pClip); + + if (signdx > 0) + cmd |= INC_X; + if (signdy > 0) + cmd |= INC_Y; + + /* we have bresenham parameters and two points. + all we have to do now is clip and draw. + */ + + if (drawLast) + len++; + while(nBox--) + { + oc1 = 0; + oc2 = 0; + OUTCODES(oc1, x1, y1, pBox); + OUTCODES(oc2, x2, y2, pBox); + if ((oc1 | oc2) == 0) + { + if (!s3Set) + { + s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); + _s3SetSolidFill (s3, pGC->fgPixel, pGC->alu, pGC->planemask); + s3Set = TRUE; + } + _s3SetCur (s3, x1, y1); + _s3ClipLine (s3, cmd, e1, e2, e, len); + break; + } + else if (oc1 & oc2) + { + pBox++; + } + else + { + int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; + int clip1 = 0, clip2 = 0; + int clipdx, clipdy; + int err; + + if (miZeroClipLine(pBox->x1, pBox->y1, pBox->x2-1, + pBox->y2-1, + &new_x1, &new_y1, &new_x2, &new_y2, + adx, ady, &clip1, &clip2, + octant, bias, oc1, oc2) == -1) + { + pBox++; + continue; + } + + if (axis == X_AXIS) + len = abs(new_x2 - new_x1); + else + len = abs(new_y2 - new_y1); + if (clip2 != 0 || drawLast) + len++; + if (len) + { + /* unwind bresenham error term to first point */ + err = e; + if (clip1) + { + clipdx = abs(new_x1 - x1); + clipdy = abs(new_y1 - y1); + if (axis == X_AXIS) + err += (e2 - e1) * clipdy + e1 * clipdx; + else + err += (e2 - e1) * clipdx + e1 * clipdy; + } + if (!s3Set) + { + s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); + _s3SetSolidFill (s3, pGC->fgPixel, pGC->alu, pGC->planemask); + s3Set = TRUE; + } + _s3SetCur (s3, new_x1, new_y1); + _s3ClipLine (s3, cmd, e1, e2, err, len); + } + pBox++; + } + } /* while (nBox--) */ + return s3Set; +} + +void +s3Polylines (DrawablePtr pDrawable, GCPtr pGC, + int mode, int npt, DDXPointPtr ppt) +{ + SetupS3(pDrawable->pScreen); + int x, y, nx, ny; + int ox = pDrawable->x, oy = pDrawable->y; + Bool s3Set = FALSE; + + if (!npt) + return; + + x = ppt->x + ox; + y = ppt->y + oy; + while (--npt) + { + ++ppt; + if (mode == CoordModePrevious) + { + nx = x + ppt->x; + ny = y + ppt->y; + } + else + { + nx = ppt->x + ox; + ny = ppt->y + oy; + } + s3Set = _s3Segment (pDrawable, pGC, x, y, nx, ny, + npt == 1 && pGC->capStyle != CapNotLast, + s3Set); + x = nx; + y = ny; + } + if (s3Set) + MarkSyncS3 (pDrawable->pScreen); +} + +void +s3PolySegment (DrawablePtr pDrawable, GCPtr pGC, + int nsegInit, xSegment *pSegInit) +{ + SetupS3(pDrawable->pScreen); + int x, y; + int ox = pDrawable->x, oy = pDrawable->y; + RegionPtr pClip = fbGetCompositeClip (pGC); + BoxPtr pBox; + int nbox; + int nseg; + xSegment *pSeg; + int dx, dy; + int maj, min, len, inc; + int t; + CARD32 cmd; + CARD32 init_cmd; + Bool drawLast; + Bool s3Set = FALSE; + + drawLast = pGC->capStyle != CapNotLast; + + for (nseg = nsegInit, pSeg = pSegInit; nseg--; pSeg++) + { + s3Set = _s3Segment (pDrawable, pGC, pSeg->x1 + ox, pSeg->y1 + oy, + pSeg->x2 + ox, pSeg->y2 + oy, drawLast, s3Set); + + } + if (s3Set) + MarkSyncS3 (pDrawable->pScreen); +} + +/* + * Check to see if a pattern can be painted with the S3 + */ + +#define _s3CheckPatternSize(s) ((s) <= S3_TILE_SIZE && ((s) & ((s) - 1)) == 0) +#define s3CheckPattern(w,h) (_s3CheckPatternSize(w) && _s3CheckPatternSize(h)) + +Bool +s3AllocPattern (ScreenPtr pScreen, + int ma, + PixmapPtr pPixmap, + int xorg, int yorg, + int fillStyle, Pixel fg, Pixel bg, + s3PatternPtr *ppPattern) +{ + KdScreenPriv(pScreen); + s3ScreenInfo(pScreenPriv); + s3PatternPtr pPattern; + + if (s3s->fb[ma].patterns.cache && fillStyle != FillSolid && + s3CheckPattern (pPixmap->drawable.width, pPixmap->drawable.height)) + { + if (!(pPattern = *ppPattern)) + { + pPattern = (s3PatternPtr) xalloc (sizeof (s3PatternRec)); + if (!pPattern) + return FALSE; + *ppPattern = pPattern; + } + + pPattern->cache = 0; + pPattern->id = 0; + pPattern->pPixmap = pPixmap; + pPattern->fillStyle = fillStyle; + pPattern->xrot = (-xorg) & (S3_TILE_SIZE-1); + pPattern->yrot = (-yorg) & (S3_TILE_SIZE-1); + pPattern->fore = fg; + pPattern->back = bg; + return TRUE; + } + else + { + if (*ppPattern) + { + xfree (*ppPattern); + *ppPattern = 0; + } + return FALSE; + } +} + +void +s3CheckGCFill (GCPtr pGC) +{ + s3PrivGCPtr s3Priv = s3GetGCPrivate (pGC); + PixmapPtr pPixmap; + + switch (pGC->fillStyle) { + case FillSolid: + pPixmap = 0; + break; + case FillOpaqueStippled: + case FillStippled: + pPixmap = pGC->stipple; + break; + case FillTiled: + pPixmap = pGC->tile.pixmap; + break; + } + s3AllocPattern (pGC->pScreen, + s3GCMap(pGC), + pPixmap, + pGC->patOrg.x + pGC->lastWinOrg.x, + pGC->patOrg.y + pGC->lastWinOrg.y, + pGC->fillStyle, pGC->fgPixel, pGC->bgPixel, + &s3Priv->pPattern); +} + +void +s3MoveGCFill (GCPtr pGC) +{ + s3PrivGCPtr s3Priv = s3GetGCPrivate (pGC); + int xorg, yorg; + s3PatternPtr pPattern; + + if (pPattern = s3Priv->pPattern) + { + /* + * Reset origin + */ + xorg = pGC->patOrg.x + pGC->lastWinOrg.x; + yorg = pGC->patOrg.y + pGC->lastWinOrg.y; + pPattern->xrot = (-xorg) & (S3_TILE_SIZE - 1); + pPattern->yrot = (-yorg) & (S3_TILE_SIZE - 1); + /* + * Invalidate cache entry + */ + pPattern->id = 0; + pPattern->cache = 0; + } +} + +/* + * S3 Patterns. These are always full-depth images, stored in off-screen + * memory. + */ + +Pixel +s3FetchPatternPixel (s3PatternPtr pPattern, int x, int y) +{ + CARD8 *src; + CARD16 *src16; + CARD32 *src32; + PixmapPtr pPixmap = pPattern->pPixmap; + + x = (x + pPattern->xrot) % pPixmap->drawable.width; + y = (y + pPattern->yrot) % pPixmap->drawable.height; + src = (CARD8 *) pPixmap->devPrivate.ptr + y * pPixmap->devKind; + switch (pPixmap->drawable.bitsPerPixel) { + case 1: + return (src[x>>3] >> (x & 7)) & 1 ? 0xffffffff : 0x00; + case 4: + if (x & 1) + return src[x>>1] >> 4; + else + return src[x>>1] & 0xf; + case 8: + return src[x]; + case 16: + src16 = (CARD16 *) src; + return src16[x]; + case 32: + src32 = (CARD32 *) src; + return src32[x]; + } +} + +/* + * Place pattern image on screen; done with S3 locked + */ +void +_s3PutPattern (ScreenPtr pScreen, int ma, s3PatternPtr pPattern) +{ + SetupS3(pScreen); + s3ScreenInfo(pScreenPriv); + int x, y; + CARD8 *dstLine, *dst8; + CARD16 *dst16; + CARD32 *dst32; + S3PatternCache *cache = pPattern->cache; +#ifdef S3_TRIO + int fb = 0; +#else + int fb = s3s->fbmap[ma]; +#endif + + DRAW_DEBUG ((DEBUG_PATTERN, "_s3PutPattern 0x%x id %d to %d %d", + pPattern, pPattern->id, cache->x, cache->y)); + + dstLine = (pScreenPriv->screen->fb[fb].frameBuffer + + cache->y * pScreenPriv->screen->fb[fb].byteStride + + cache->x * pScreenPriv->bytesPerPixel[fb]); + + CheckSyncS3 (pScreen); + + for (y = 0; y < S3_TILE_SIZE; y++) + { + switch (pScreenPriv->screen->fb[fb].bitsPerPixel) { + case 8: + dst8 = dstLine; + for (x = 0; x < S3_TILE_SIZE; x++) + *dst8++ = s3FetchPatternPixel (pPattern, x, y); + DRAW_DEBUG ((DEBUG_PATTERN, "%c%c%c%c%c%c%c%c", + dstLine[0] ? 'X' : ' ', + dstLine[1] ? 'X' : ' ', + dstLine[2] ? 'X' : ' ', + dstLine[3] ? 'X' : ' ', + dstLine[4] ? 'X' : ' ', + dstLine[5] ? 'X' : ' ', + dstLine[6] ? 'X' : ' ', + dstLine[7] ? 'X' : ' ')); + break; + case 16: + dst16 = (CARD16 *) dstLine; + for (x = 0; x < S3_TILE_SIZE; x++) + *dst16++ = s3FetchPatternPixel (pPattern, x, y); + break; + case 32: + dst32 = (CARD32 *) dstLine; + for (x = 0; x < S3_TILE_SIZE; x++) + *dst32++ = s3FetchPatternPixel (pPattern, x, y); + break; + } + dstLine += pScreenPriv->screen->fb[fb].byteStride; + } +} + +/* + * Load a stipple to off-screen memory; done with S3 locked + */ +void +_s3LoadPattern (ScreenPtr pScreen, int ma, s3PatternPtr pPattern) +{ + SetupS3(pScreen); + s3ScreenInfo(pScreenPriv); + S3PatternCache *cache; + + DRAW_DEBUG((DEBUG_PATTERN, + "s3LoadPattern 0x%x id %d cache 0x%x cacheid %d", + pPattern, pPattern->id, pPattern->cache, + pPattern->cache ? pPattern->cache->id : -1)); + /* + * Check to see if its still loaded + */ + cache = pPattern->cache; + if (cache && cache->id == pPattern->id) + return; + /* + * Lame replacement strategy; assume we'll have plenty of room. + */ + cache = &s3s->fb[ma].patterns.cache[s3s->fb[ma].patterns.last_used]; + if (++s3s->fb[ma].patterns.last_used == s3s->fb[ma].patterns.ncache) + s3s->fb[ma].patterns.last_used = 0; + cache->id = ++s3s->fb[ma].patterns.last_id; + pPattern->id = cache->id; + pPattern->cache = cache; + _s3PutPattern (pScreen, ma, pPattern); +} + +void +s3DestroyGC (GCPtr pGC) +{ + s3PrivGCPtr s3Priv = s3GetGCPrivate (pGC); + + if (s3Priv->pPattern) + xfree (s3Priv->pPattern); + miDestroyGC (pGC); +} + +GCFuncs s3GCFuncs = { + s3ValidateGC, + miChangeGC, + miCopyGC, + s3DestroyGC, + miChangeClip, + miDestroyClip, + miCopyClip +}; + +int +s3CreateGC (GCPtr pGC) +{ + KdScreenPriv(pGC->pScreen); + s3ScreenInfo(pScreenPriv); + s3PrivGCPtr s3Priv; + + if (!fbCreateGC (pGC)) + return FALSE; + + if (pGC->depth != 1) + pGC->funcs = &s3GCFuncs; + + s3Priv = s3GetGCPrivate(pGC); + s3Priv->type = DRAWABLE_PIXMAP; + s3Priv->pPattern = 0; +#ifndef S3_TRIO + if (pGC->depth == s3s->primary_depth) + s3Priv->ma = 0; + else + s3Priv->ma = 1; +#endif + return TRUE; +} + +Bool +s3CreateWindow (WindowPtr pWin) +{ + KdScreenPriv(pWin->drawable.pScreen); + s3ScreenInfo(pScreenPriv); + + dixSetPrivate(&pWin->devPrivates, s3WindowPrivateKey, NULL); + return KdCreateWindow (pWin); +} + +Bool +s3DestroyWindow (WindowPtr pWin) +{ + s3PatternPtr pPattern; + if (pPattern = s3GetWindowPrivate(pWin)) + xfree (pPattern); + return fbDestroyWindow (pWin); +} + +Bool +s3ChangeWindowAttributes (WindowPtr pWin, Mask mask) +{ + KdScreenPriv(pWin->drawable.pScreen); + Bool ret; + s3PatternPtr pPattern; + PixmapPtr pPixmap; + int fillStyle; + + ret = fbChangeWindowAttributes (pWin, mask); + if (mask & CWBackPixmap) + { + if (pWin->backgroundState == BackgroundPixmap) + { + pPixmap = pWin->background.pixmap; + fillStyle = FillTiled; + } + else + { + pPixmap = 0; + fillStyle = FillSolid; + } + pPattern = s3GetWindowPrivate(pWin); + s3AllocPattern (pWin->drawable.pScreen, + s3DrawMap (&pWin->drawable), + pPixmap, + pWin->drawable.x, pWin->drawable.y, + fillStyle, 0, 0, &pPattern); + DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "Background pattern 0x%x pixmap 0x%x style %d", + pPattern, pPixmap, fillStyle)); + s3SetWindowPrivate (pWin, pPattern); + } + return ret; +} + + +#ifndef S3_TRIO +void +s3PaintKey (DrawablePtr pDrawable, + RegionPtr pRegion, + CARD32 pixel, + int fb) +{ + SetupS3 (pDrawable->pScreen); + s3ScreenInfo (pScreenPriv); + int nBox = REGION_NUM_RECTS(pRegion); + BoxPtr pBox = REGION_RECTS(pRegion); + int ma; + + if (!nBox) + return; + + for (ma = 0; s3s->fbmap[ma] >= 0; ma++) + if (s3s->fbmap[ma] == fb) + break; + s3SetGlobalBitmap (pDrawable->pScreen, ma); + _s3SetSolidFill (s3, pixel, GXcopy, 0xffffffff); + while (nBox--) + { + _s3SolidRect(s3,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1); + pBox++; + } + MarkSyncS3 (pDrawable->pScreen); +} +#endif + +void +s3CopyWindowProc (DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pboxOrig, + int nboxOrig, + int dx, + int dy, + Bool reverse, + Bool upsidedown, + Pixel bitplane, + void *closure) +{ + SetupS3(pDstDrawable->pScreen); + s3ScreenInfo(pScreenPriv); + KdScreenInfo *screen = pScreenPriv->screen; + int srcX, srcY, dstX, dstY; + int x1, x2; + int w, h; + int flags; + int fb = (int) closure; + int ma; + BoxPtr pbox; + int nbox; + int bitsPerPixel; + +#ifdef S3_TRIO + ma = 0; +#else + for (ma = 0; s3s->fbmap[ma] >= 0; ma++) + if (s3s->fbmap[ma] == fb) + break; +#endif + bitsPerPixel = screen->fb[fb].bitsPerPixel; + if (bitsPerPixel == 24) + dx *= 3; + nbox = nboxOrig; + pbox = pboxOrig; + s3SetGlobalBitmap (pDstDrawable->pScreen, ma); + _s3SetBlt(s3,GXcopy,~0); + while (nbox--) + { + x1 = pbox->x1; + x2 = pbox->x2; + if (bitsPerPixel == 24) + { + x1 *= 3; + x2 *= 3; + } + + w = x2 - x1; + h = pbox->y2 - pbox->y1; + flags = 0; + if (reverse) + { + dstX = x2 - 1; + } + else + { + dstX = x1; + flags |= INC_X; + } + srcX = dstX + dx; + + if (upsidedown) + { + dstY = pbox->y2 - 1; + } + else + { + dstY = pbox->y1; + flags |= INC_Y; + } + srcY = dstY + dy; + + _s3Blt (s3, srcX, srcY, dstX, dstY, w, h, flags); + pbox++; + } + MarkSyncS3 (pDstDrawable->pScreen); +} + +void +s3CopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + KdScreenPriv (pScreen); + s3ScreenInfo (pScreenPriv); + KdScreenInfo *screen = pScreenPriv->screen; + RegionRec rgnDst; + int dx, dy; + WindowPtr pwinRoot; + + pwinRoot = WindowTable[pWin->drawable.pScreen->myNum]; + + dx = ptOldOrg.x - pWin->drawable.x; + dy = ptOldOrg.y - pWin->drawable.y; + + REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy); + + REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0); + + REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, + &pWin->borderClip, prgnSrc); + + fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, + 0, + &rgnDst, dx, dy, s3CopyWindowProc, 0, 0); + + REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); +} + +void +s3_24FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, + unsigned long pixel, int alu, unsigned long planemask) +{ + SetupS3(pDrawable->pScreen); + register int r; + int x1, x2; + + s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable)); + _s3SetSolidFill(s3,pixel,alu,planemask); + + while (nBox--) { + x1 = pBox->x1 * 3; + x2 = pBox->x2 * 3; + _s3SolidRect(s3,x1,pBox->y1,x2-x1,pBox->y2-pBox->y1); + pBox++; + } + MarkSyncS3 (pDrawable->pScreen); +} + +#define ok24(p) (((p) & 0xffffff) == ((((p) & 0xff) << 16) | (((p) >> 8) & 0xffff))) + +void +s3_24FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n, + DDXPointPtr ppt, int *pwidth, int fSorted) +{ + SetupS3(pDrawable->pScreen); + int x, y, x1, y1, x2, y2; + int width; + /* next three parameters are post-clip */ + int nTmp; + int *pwidthFree;/* copies of the pointers to free */ + DDXPointPtr pptFree; + BoxPtr extents; + RegionPtr pClip = fbGetCompositeClip (pGC); + + if (pGC->fillStyle != FillSolid || !ok24 (pGC->fgPixel) || !ok24(pGC->planemask)) + { + KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted); + return; + } + + s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC)); + if (REGION_NUM_RECTS(pClip) == 1) + { + extents = REGION_RECTS(pClip); + x1 = extents->x1; + x2 = extents->x2; + y1 = extents->y1; + y2 = extents->y2; + _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask); + while (n--) + { + y = ppt->y; + if (y1 <= y && y < y2) + { + x = ppt->x; + width = *pwidth; + if (x < x1) + { + width -= (x1 - x); + x = x1; + } + if (x2 < x + width) + width = x2 - x; + if (width > 0) + { + _s3SolidRect(s3,x*3,y,width*3,1); + } + } + ppt++; + pwidth++; + } + } + else + { + nTmp = n * miFindMaxBand(pClip); + pwidthFree = (int *)xalloc(nTmp * sizeof(int)); + pptFree = (DDXPointRec *)xalloc(nTmp * sizeof(DDXPointRec)); + if(!pptFree || !pwidthFree) + { + if (pptFree) xfree(pptFree); + if (pwidthFree) xfree(pwidthFree); + return; + } + n = miClipSpans(fbGetCompositeClip(pGC), + ppt, pwidth, n, + pptFree, pwidthFree, fSorted); + pwidth = pwidthFree; + ppt = pptFree; + _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask); + while (n--) + { + x = ppt->x; + y = ppt->y; + ppt++; + width = *pwidth++; + if (width) + { + _s3SolidRect(s3,x*3,y,width*3,1); + } + } + xfree(pptFree); + xfree(pwidthFree); + } + MarkSyncS3 (pDrawable->pScreen); +} + +void +s3_24CopyNtoN (DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GCPtr pGC, + BoxPtr pbox, + int nbox, + int dx, + int dy, + Bool reverse, + Bool upsidedown, + Pixel bitplane, + void *closure) +{ + SetupS3(pDstDrawable->pScreen); + int srcX, srcY, dstX, dstY; + int w, h; + int flags; + int x1, x2; + + if (sourceInvarient (pGC->alu)) + { + s3_24FillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu, pGC->planemask); + return; + } + + s3SetGlobalBitmap (pDstDrawable->pScreen, s3GCMap (pGC)); + _s3SetBlt(s3,pGC->alu,pGC->planemask); + DRAW_DEBUG ((DEBUG_RENDER, "s3CopyNtoN alu %d planemask 0x%x", + pGC->alu, pGC->planemask)); + dx *= 3; + while (nbox--) + { + x1 = pbox->x1 * 3; + x2 = pbox->x2 * 3; + w = x2 - x1; + h = pbox->y2 - pbox->y1; + flags = 0; + if (reverse) + { + dstX = x2 - 1; + } + else + { + dstX = x1; + flags |= INC_X; + } + srcX = dstX + dx; + + if (upsidedown) + { + dstY = pbox->y2 - 1; + } + else + { + dstY = pbox->y1; + flags |= INC_Y; + } + srcY = dstY + dy; + + _s3Blt (s3, srcX, srcY, dstX, dstY, w, h, flags); + pbox++; + } + MarkSyncS3 (pSrcDrawable->pScreen); +} + +RegionPtr +s3_24CopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, + int srcx, int srcy, int width, int height, int dstx, int dsty) +{ + SetupS3(pDstDrawable->pScreen); + + if (pSrcDrawable->type == DRAWABLE_WINDOW && + pDstDrawable->type == DRAWABLE_WINDOW && + ok24(pGC->planemask)) + { + return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, + dstx, dsty, s3_24CopyNtoN, 0, 0); + } + return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC, + srcx, srcy, width, height, dstx, dsty); +} + + +#define NUM_STACK_RECTS 1024 + +void +s3_24PolyFillRect (DrawablePtr pDrawable, GCPtr pGC, + int nrectFill, xRectangle *prectInit) +{ + s3GCPrivate(pGC); + xRectangle *prect; + RegionPtr prgnClip; + register BoxPtr pbox; + register BoxPtr pboxClipped; + BoxPtr pboxClippedBase; + BoxPtr pextent; + BoxRec stackRects[NUM_STACK_RECTS]; + int numRects; + int n; + int xorg, yorg; + int x, y; + + if (pGC->fillStyle != FillSolid || !ok24 (pGC->fgPixel) || !ok24(pGC->planemask)) + { + KdCheckPolyFillRect (pDrawable, pGC, nrectFill, prectInit); + return; + } + + prgnClip = fbGetCompositeClip(pGC); + xorg = pDrawable->x; + yorg = pDrawable->y; + + if (xorg || yorg) + { + prect = prectInit; + n = nrectFill; + while(n--) + { + prect->x += xorg; + prect->y += yorg; + prect++; + } + } + + prect = prectInit; + + numRects = REGION_NUM_RECTS(prgnClip) * nrectFill; + if (numRects > NUM_STACK_RECTS) + { + pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec)); + if (!pboxClippedBase) + return; + } + else + pboxClippedBase = stackRects; + + pboxClipped = pboxClippedBase; + + if (REGION_NUM_RECTS(prgnClip) == 1) + { + int x1, y1, x2, y2, bx2, by2; + + pextent = REGION_RECTS(prgnClip); + x1 = pextent->x1; + y1 = pextent->y1; + x2 = pextent->x2; + y2 = pextent->y2; + while (nrectFill--) + { + if ((pboxClipped->x1 = prect->x) < x1) + pboxClipped->x1 = x1; + + if ((pboxClipped->y1 = prect->y) < y1) + pboxClipped->y1 = y1; + + bx2 = (int) prect->x + (int) prect->width; + if (bx2 > x2) + bx2 = x2; + pboxClipped->x2 = bx2; + + by2 = (int) prect->y + (int) prect->height; + if (by2 > y2) + by2 = y2; + pboxClipped->y2 = by2; + + prect++; + if ((pboxClipped->x1 < pboxClipped->x2) && + (pboxClipped->y1 < pboxClipped->y2)) + { + pboxClipped++; + } + } + } + else + { + int x1, y1, x2, y2, bx2, by2; + + pextent = REGION_EXTENTS(pGC->pScreen, prgnClip); + x1 = pextent->x1; + y1 = pextent->y1; + x2 = pextent->x2; + y2 = pextent->y2; + while (nrectFill--) + { + BoxRec box; + + if ((box.x1 = prect->x) < x1) + box.x1 = x1; + + if ((box.y1 = prect->y) < y1) + box.y1 = y1; + + bx2 = (int) prect->x + (int) prect->width; + if (bx2 > x2) + bx2 = x2; + box.x2 = bx2; + + by2 = (int) prect->y + (int) prect->height; + if (by2 > y2) + by2 = y2; + box.y2 = by2; + + prect++; + + if ((box.x1 >= box.x2) || (box.y1 >= box.y2)) + continue; + + n = REGION_NUM_RECTS (prgnClip); + pbox = REGION_RECTS(prgnClip); + + /* clip the rectangle to each box in the clip region + this is logically equivalent to calling Intersect() + */ + while(n--) + { + pboxClipped->x1 = max(box.x1, pbox->x1); + pboxClipped->y1 = max(box.y1, pbox->y1); + pboxClipped->x2 = min(box.x2, pbox->x2); + pboxClipped->y2 = min(box.y2, pbox->y2); + pbox++; + + /* see if clipping left anything */ + if(pboxClipped->x1 < pboxClipped->x2 && + pboxClipped->y1 < pboxClipped->y2) + { + pboxClipped++; + } + } + } + } + if (pboxClipped != pboxClippedBase) + { + s3_24FillBoxSolid(pDrawable, + pboxClipped-pboxClippedBase, pboxClippedBase, + pGC->fgPixel, pGC->alu, pGC->planemask); + } + if (pboxClippedBase != stackRects) + xfree(pboxClippedBase); +} + +void +s3_24SolidBoxClipped (DrawablePtr pDrawable, + RegionPtr pClip, + int x1, + int y1, + int x2, + int y2, + FbBits fg) +{ + SetupS3 (pDrawable->pScreen); + BoxPtr pbox; + int nbox; + int partX1, partX2, partY1, partY2; + + s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable)); + _s3SetSolidFill(s3,fg,GXcopy,~0); + + for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip); + nbox--; + pbox++) + { + partX1 = pbox->x1; + if (partX1 < x1) + partX1 = x1; + + partX2 = pbox->x2; + if (partX2 > x2) + partX2 = x2; + + if (partX2 <= partX1) + continue; + + partY1 = pbox->y1; + if (partY1 < y1) + partY1 = y1; + + partY2 = pbox->y2; + if (partY2 > y2) + partY2 = y2; + + if (partY2 <= partY1) + continue; + + partX1 *= 3; + partX2 *= 3; + _s3SolidRect(s3,partX1, partY1, partX2-partX1, partY2-partY1); + } + MarkSyncS3(pDrawable->pScreen); +} + +void +s3_24ImageGlyphBlt (DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppciInit, + pointer pglyphBase) +{ + FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); + CharInfoPtr *ppci; + CharInfoPtr pci; + unsigned char *pglyph; /* pointer bits in glyph */ + int gWidth, gHeight; /* width and height of glyph */ + FbStride gStride; /* stride of glyph */ + Bool opaque; + int n; + int gx, gy; + FbBits *dst; + FbStride dstStride; + int dstBpp; + int dstXoff, dstYoff; + FbBits depthMask; + int xBack, widthBack; + int yBack, heightBack; + + depthMask = FbFullMask(pDrawable->depth); + if (!ok24 (pGC->fgPixel) || + !ok24(pGC->bgPixel) || + !ok24(pGC->planemask)) + { + KdCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase); + return; + } + fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); + + x += pDrawable->x; + y += pDrawable->y; + + ppci = ppciInit; + n = nglyph; + widthBack = 0; + while (n--) + widthBack += (*ppci++)->metrics.characterWidth; + + xBack = x; + if (widthBack < 0) + { + xBack += widthBack; + widthBack = -widthBack; + } + yBack = y - FONTASCENT(pGC->font); + heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); + s3_24SolidBoxClipped (pDrawable, + fbGetCompositeClip(pGC), + xBack, + yBack, + xBack + widthBack, + yBack + heightBack, + pPriv->bg); + + KdCheckSync (pDrawable->pScreen); + + ppci = ppciInit; + while (nglyph--) + { + pci = *ppci++; + pglyph = FONTGLYPHBITS(pglyphBase, pci); + gWidth = GLYPHWIDTHPIXELS(pci); + gHeight = GLYPHHEIGHTPIXELS(pci); + if (gWidth && gHeight) + { + gx = x + pci->metrics.leftSideBearing; + gy = y - pci->metrics.ascent; + if (gWidth <= sizeof (FbStip) * 8 && + fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight)) + { + fbGlyph24 (dst + (gy - dstYoff) * dstStride, + dstStride, + dstBpp, + (FbStip *) pglyph, + pPriv->fg, + gx - dstXoff, + gHeight); + } + else + { + gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip); + fbPutXYImage (pDrawable, + fbGetCompositeClip(pGC), + pPriv->fg, + pPriv->bg, + pPriv->pm, + GXcopy, + FALSE, + + gx, + gy, + gWidth, gHeight, + + (FbStip *) pglyph, + gStride, + 0); + } + } + x += pci->metrics.characterWidth; + } +} + +static const GCOps s3_24GCOps = { + s3_24FillSpans, + KdCheckSetSpans, + KdCheckPutImage, + KdCheckCopyArea, + KdCheckCopyPlane, + KdCheckPolyPoint, + KdCheckPolylines, + KdCheckPolySegment, + KdCheckPolyRectangle, + KdCheckPolyArc, + KdCheckFillPolygon, + s3_24PolyFillRect, + KdCheckPolyFillArc, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + s3_24ImageGlyphBlt, + KdCheckPolyGlyphBlt, + KdCheckPushPixels, +}; + +void +s3_24ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) +{ + if (pDrawable->type != DRAWABLE_WINDOW) + pGC->ops = (GCOps *) &kdAsyncPixmapGCOps; + else + pGC->ops = (GCOps *) &s3_24GCOps; + fbValidateGC (pGC, changes, pDrawable); +} + +GCFuncs s3_24GCFuncs = { + s3_24ValidateGC, + miChangeGC, + miCopyGC, + miDestroyGC, + miChangeClip, + miDestroyClip, + miCopyClip +}; + +Bool +s3_24CreateGC (GCPtr pGC) +{ + if (!fbCreateGC (pGC)) + return FALSE; + + if (pGC->depth != 1) + pGC->funcs = &s3_24GCFuncs; + + return TRUE; +} + +Bool +s3_24CreateWindow(WindowPtr pWin) +{ + return fbCreateWindow (pWin); +} + + +Bool +s3DrawInit (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + s3ScreenInfo(pScreenPriv); + int ncache_w, ncache_h, ncache; + int px, py; + S3PatternCache *cache; + Bool dumb = FALSE; + int ma; + + switch (pScreenPriv->screen->fb[0].bitsPerPixel) { + case 8: + case 16: + case 32: + break; + case 24: + dumb = TRUE; + break; + default: + return FALSE; + } + /* + * Hook up asynchronous drawing + */ + RegisterSync (pScreen); + /* + * Replace various fb screen functions + */ + if (dumb) + { + pScreen->CreateGC = s3_24CreateGC; + pScreen->CreateWindow = s3_24CreateWindow; + pScreen->CopyWindow = s3CopyWindow; + } + else + { + if (!dixRequestPrivate(s3GCPrivateKey, sizeof (s3PrivGCRec))) + return FALSE; + pScreen->CreateGC = s3CreateGC; + pScreen->CreateWindow = s3CreateWindow; + pScreen->ChangeWindowAttributes = s3ChangeWindowAttributes; + pScreen->DestroyWindow = s3DestroyWindow; +#ifndef S3_TRIO + if (pScreenPriv->screen->fb[1].depth) + { + FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen); + + pScrPriv->PaintKey = s3PaintKey; + pScrPriv->CopyWindow = s3CopyWindowProc; + pScreen->CopyWindow = fbOverlayCopyWindow; + } + else +#endif + pScreen->CopyWindow = s3CopyWindow; + + /* + * Initialize patterns + */ +#ifdef S3_TRIO + ma = 0; +#else + for (ma = 0; s3s->fbmap[ma] >= 0; ma++) +#endif + { + ncache_w = s3s->fb[ma].offscreen_width / S3_TILE_SIZE; + ncache_h = s3s->fb[ma].offscreen_height / S3_TILE_SIZE; + ncache = ncache_w * ncache_h; + if (ncache > 64) + ncache = 64; + DRAW_DEBUG ((DEBUG_S3INIT, "ncache_w %d ncache_h %d ncache %d", + ncache_w, ncache_h, ncache)); + s3s->fb[ma].patterns.cache = (S3PatternCache *) xalloc (ncache * sizeof (S3PatternCache)); + if (s3s->fb[ma].patterns.cache) + { + DRAW_DEBUG ((DEBUG_S3INIT, "Have pattern cache")); + s3s->fb[ma].patterns.ncache = ncache; + s3s->fb[ma].patterns.last_used = 0; + s3s->fb[ma].patterns.last_id = 0; + cache = s3s->fb[ma].patterns.cache; + for (py = 0; py < ncache_h && ncache; py++) + for (px = 0; px < ncache_w && ncache; px++) + { + cache->id = 0; + cache->x = s3s->fb[ma].offscreen_x + px * S3_TILE_SIZE; + cache->y = s3s->fb[ma].offscreen_y + py * S3_TILE_SIZE; + cache++; + ncache--; + } + } + } + } + return TRUE; +} + +void +s3DrawEnable (ScreenPtr pScreen) +{ + SetupS3(pScreen); + s3ScreenInfo(pScreenPriv); + int c; + int ma; + + s3SetGlobalBitmap (pScreen, 0); + _s3WaitIdleEmpty (s3); + if (pScreenPriv->screen->fb[0].bitsPerPixel == 24) + { + _s3SetScissorsTl(s3, 0, 0); + _s3SetScissorsBr(s3, pScreenPriv->screen->width*3 - 1, pScreenPriv->screen->height - 1); + _s3SetSolidFill(s3, pScreen->whitePixel, GXcopy, ~0); + _s3SolidRect (s3, 0, 0, pScreenPriv->screen->width*3, pScreenPriv->screen->height); + } + else + { + /* + * Flush pattern cache + */ +#ifdef S3_TRIO + ma = 0; +#else + for (ma = 0; s3s->fbmap[ma] >= 0; ma++) +#endif + { + for (c = 0; c < s3s->fb[ma].patterns.ncache; c++) + s3s->fb[ma].patterns.cache[c].id = 0; + } + + _s3SetScissorsTl(s3, 0, 0); + _s3SetScissorsBr(s3, pScreenPriv->screen->width - 1, pScreenPriv->screen->height - 1); + _s3SetSolidFill(s3, pScreen->blackPixel, GXcopy, ~0); + _s3SolidRect (s3, 0, 0, pScreenPriv->screen->width, pScreenPriv->screen->height); + } + MarkSyncS3 (pScreen); +} + +void +s3DrawDisable (ScreenPtr pScreen) +{ + SetupS3 (pScreen); + _s3WaitIdleEmpty (s3); +} + +void +s3DrawFini (ScreenPtr pScreen) +{ + SetupS3(pScreen); + s3ScreenInfo(pScreenPriv); + int ma; + +#ifdef S3_TRIO + ma = 0; +#else + for (ma = 0; s3s->fbmap[ma] >= 0; ma++) +#endif + { + if (s3s->fb[ma].patterns.cache) + { + xfree (s3s->fb[ma].patterns.cache); + s3s->fb[ma].patterns.cache = 0; + s3s->fb[ma].patterns.ncache = 0; + } + } +} + +void +s3DrawSync (ScreenPtr pScreen) +{ + SetupS3(pScreen); + + _s3WaitIdleEmpty(s3c->s3); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3.h +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3.h @@ -0,0 +1,533 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifndef _S3_H_ +#define _S3_H_ + +#include "kdrive.h" +#include "s3reg.h" + +/* VESA Approved Register Definitions */ + +/* + * Linear Addressing 000 0000 - 0ff ffff (16m) + * Image data transfer 100 0000 - 100 7fff (32k) + * PCI config 100 8000 - 100 8043 + * Packed enhanced regs 100 8100 - 100 814a + * Streams regs 100 8180 - 100 81ff + * Current Y pos 100 82e8 + * CRT VGA 3b? regs 100 83b0 - 100 83bf + * CRT VGA 3c? regs 100 83c0 - 100 83cf + * CRT VGA 3d? regs 100 83d0 - 100 83df + * Subsystem status (42e8h) 100 8504 + * Advanced function (42e8h) 100 850c + * Enhanced regs 100 86e8 - 100 eeea + * Local peripheral bus 100 ff00 - 100 ff5c + * + * We don't care about the image transfer or PCI regs, so + * this structure starts at the packed enhanced regs + */ + +typedef volatile CARD32 VOL32; +typedef volatile CARD16 VOL16; +typedef volatile CARD8 VOL8; + +typedef volatile struct _s3 { + VOL32 alt_curxy; /* 8100 */ + VOL32 _pad0; /* 8104 */ + VOL32 alt_step; /* 8108 */ + VOL32 _pad1; /* 810c */ + VOL32 err_term; /* 8110 */ + VOL32 _pad2; /* 8114 */ + VOL32 cmd_gp_stat; /* 8118 */ + VOL32 short_stroke; /* 811c */ + VOL32 bg; /* 8120 */ + VOL32 fg; /* 8124 */ + VOL32 write_mask; /* 8128 */ + VOL32 read_mask; /* 812c */ + VOL32 color_cmp; /* 8130 */ + VOL32 alt_mix; /* 8134 */ + VOL32 scissors_tl; /* 8138 */ + VOL32 scissors_br; /* 813c */ +#if 0 + VOL16 pix_cntl; /* 8140 */ + VOL16 mult_misc2; /* 8142 */ +#else + VOL32 pix_cntl_mult_misc2; /* 8140 */ +#endif + VOL32 mult_misc_read_sel; /* 8144 */ + VOL32 alt_pcnt; /* 8148 min_axis_pcnt, maj_axis_pcnt */ + VOL8 _pad3a[0x1c]; /* 814c */ + VOL32 global_bitmap_1; /* 8168 */ + VOL32 global_bitmap_2; /* 816c */ + VOL32 primary_bitmap_1; /* 8170 */ + VOL32 primary_bitmap_2; /* 8174 */ + VOL32 secondary_bitmap_1; /* 8178 */ + VOL32 secondary_bitmap_2; /* 817c */ + VOL32 primary_stream_control; /* 8180 */ + VOL32 chroma_key_control; /* 8184 */ + VOL32 genlocking_control; /* 8188 */ + VOL8 _pad3b[0x4]; /* 818c */ + VOL32 secondary_stream_control; /* 8190 */ + VOL32 chroma_key_upper_bound; /* 8194 */ + VOL32 secondary_stream_h_scale; /* 8198 */ + VOL32 color_adjustment; /* 819c */ + VOL32 blend_control; /* 81a0 */ + VOL8 _pad3c[0x1c]; /* 81a4 */ + VOL32 primary_stream_addr_0; /* 81c0 */ + VOL32 primary_stream_addr_1; /* 81c4 */ + VOL32 primary_stream_stride; /* 81c8 */ + VOL32 secondary_stream_mbuf; /* 81cc */ + VOL32 secondary_stream_addr_0;/* 81d0 */ + VOL32 secondary_stream_addr_1;/* 81d4 */ + VOL32 secondary_stream_stride;/* 81d8 */ + VOL8 _pad81dc[4]; /* 81dc */ + VOL32 secondary_stream_vscale;/* 81e0 */ + VOL32 secondary_stream_vinit; /* 81e4 */ + VOL32 secondary_stream_scount;/* 81e8 */ + VOL32 streams_fifo; /* 81ec */ + VOL32 primary_stream_xy; /* 81f0 */ + VOL32 primary_stream_size; /* 81f4 */ + VOL32 secondary_stream_xy; /* 81f8 */ + VOL32 secondary_stream_size; /* 81fc */ + VOL8 _pad8200[0xe8]; /* 8200 */ + VOL32 cur_y; /* 82e8 */ + VOL8 _pad4[0x14]; /* 82ec */ + VOL32 primary_stream_mem; /* 8300 */ + VOL32 secondary_stream_mem; /* 8304 */ + VOL8 _pad8308[0xD2]; /* 8308 */ + VOL8 input_status_1; /* 83da */ + VOL8 _pad83db[0x131]; /* 83db */ + VOL32 adv_func_cntl; /* 850c */ + VOL8 _pad8510[0x5dd8]; /* 8510 */ + VOL32 pix_trans; /* e2e8 */ + VOL8 _pade2ec[0x3a92c]; /* e2ec */ + VOL32 cmd_overflow_buf_ptr; /* 48c18 */ + VOL8 _pad48c1c[0x8]; /* 48c1c */ + VOL32 bci_power_management; /* 48c24 */ + VOL8 _pad48c28[0x38]; /* 48c28 */ + VOL32 alt_status_0; /* 48c60 */ + VOL32 alt_status_1; /* 48c64 */ +} S3, *S3Ptr; + +#define VGA_STATUS_1_DTM 0x01 +#define VGA_STATUS_1_VSY 0x08 + +#define DAC_MASK 0x03c6 +#define DAC_R_INDEX 0x03c7 +#define DAC_W_INDEX 0x03c8 +#define DAC_DATA 0x03c9 +#define DISP_STAT 0x02e8 +#define H_TOTAL 0x02e8 +#define H_DISP 0x06e8 +#define H_SYNC_STRT 0x0ae8 +#define H_SYNC_WID 0x0ee8 +#define V_TOTAL 0x12e8 +#define V_DISP 0x16e8 +#define V_SYNC_STRT 0x1ae8 +#define V_SYNC_WID 0x1ee8 +#define DISP_CNTL 0x22e8 +#define ADVFUNC_CNTL 0x4ae8 +#define SUBSYS_STAT 0x42e8 +#define SUBSYS_CNTL 0x42e8 +#define ROM_PAGE_SEL 0x46e8 +#define CUR_Y 0x82e8 +#define CUR_X 0x86e8 +#define DESTY_AXSTP 0x8ae8 +#define DESTX_DIASTP 0x8ee8 +#define ERR_TERM 0x92e8 +#define MAJ_AXIS_PCNT 0x96e8 +#define GP_STAT 0x9ae8 +#define CMD 0x9ae8 +#define SHORT_STROKE 0x9ee8 +#define BKGD_COLOR 0xa2e8 +#define FRGD_COLOR 0xa6e8 +#define WRT_MASK 0xaae8 +#define RD_MASK 0xaee8 +#define COLOR_CMP 0xb2e8 +#define BKGD_MIX 0xb6e8 +#define FRGD_MIX 0xbae8 +#define MULTIFUNC_CNTL 0xbee8 +#define MIN_AXIS_PCNT 0x0000 +#define SCISSORS_T 0x1000 +#define SCISSORS_L 0x2000 +#define SCISSORS_B 0x3000 +#define SCISSORS_R 0x4000 +#define MEM_CNTL 0x5000 +#define PATTERN_L 0x8000 +#define PATTERN_H 0x9000 +#define PIX_CNTL 0xa000 +#define CONTROL_MISC2 0xd000 +#define PIX_TRANS 0xe2e8 + +/* Advanced Function Control Regsiter */ +#define CLKSEL 0x0004 +#define DISABPASSTHRU 0x0001 + +/* Graphics Processor Status Register */ + +#define GPNSLOT 13 + +#define GPBUSY_1 0x0080 +#define GPBUSY_2 0x0040 +#define GPBUSY_3 0x0020 +#define GPBUSY_4 0x0010 +#define GPBUSY_5 0x0008 +#define GPBUSY_6 0x0004 +#define GPBUSY_7 0x0002 +#define GPBUSY_8 0x0001 +#define GPBUSY_9 0x8000 +#define GPBUSY_10 0x4000 +#define GPBUSY_11 0x2000 +#define GPBUSY_12 0x1000 +#define GPBUSY_13 0x0800 + +#define GPEMPTY 0x0400 +#define GPBUSY 0x0200 +#define DATDRDY 0x0100 + +/* Command Register */ +#define CMD_NOP 0x0000 +#define CMD_LINE 0x2000 +#define CMD_RECT 0x4000 +#define CMD_RECTV1 0x6000 +#define CMD_RECTV2 0x8000 +#define CMD_LINEAF 0xa000 +#define CMD_BITBLT 0xc000 +#define CMD_PATBLT 0xe000 +#define CMD_OP_MSK 0xe000 +#define BYTSEQ 0x1000 +#define _32BITNOPAD 0x0600 +#define _32BIT 0x0400 +#define _16BIT 0x0200 +#define _8BIT 0x0000 +#define PCDATA 0x0100 +#define INC_Y 0x0080 +#define YMAJAXIS 0x0040 +#define INC_X 0x0020 +#define DRAW 0x0010 +#define LINETYPE 0x0008 +#define LASTPIX 0x0004 /* Draw last pixel in line */ +#define PLANAR 0x0002 +#define WRTDATA 0x0001 + +/* Background Mix Register */ +#define BSS_BKGDCOL 0x0000 +#define BSS_FRGDCOL 0x0020 +#define BSS_PCDATA 0x0040 +#define BSS_BITBLT 0x0060 + +/* Foreground Mix Register */ +#define FSS_BKGDCOL 0x0000 +#define FSS_FRGDCOL 0x0020 +#define FSS_PCDATA 0x0040 +#define FSS_BITBLT 0x0060 + +/* The Mixes */ +#define MIX_MASK 0x001f + +#define MIX_NOT_DST 0x0000 +#define MIX_0 0x0001 +#define MIX_1 0x0002 +#define MIX_DST 0x0003 +#define MIX_NOT_SRC 0x0004 +#define MIX_XOR 0x0005 +#define MIX_XNOR 0x0006 +#define MIX_SRC 0x0007 +#define MIX_NAND 0x0008 +#define MIX_NOT_SRC_OR_DST 0x0009 +#define MIX_SRC_OR_NOT_DST 0x000a +#define MIX_OR 0x000b +#define MIX_AND 0x000c +#define MIX_SRC_AND_NOT_DST 0x000d +#define MIX_NOT_SRC_AND_DST 0x000e +#define MIX_NOR 0x000f + +#define MIX_MIN 0x0010 +#define MIX_DST_MINUS_SRC 0x0011 +#define MIX_SRC_MINUS_DST 0x0012 +#define MIX_PLUS 0x0013 +#define MIX_MAX 0x0014 +#define MIX_HALF__DST_MINUS_SRC 0x0015 +#define MIX_HALF__SRC_MINUS_DST 0x0016 +#define MIX_AVERAGE 0x0017 +#define MIX_DST_MINUS_SRC_SAT 0x0018 +#define MIX_SRC_MINUS_DST_SAT 0x001a +#define MIX_HALF__DST_MINUS_SRC_SAT 0x001c +#define MIX_HALF__SRC_MINUS_DST_SAT 0x001e +#define MIX_AVERAGE_SAT 0x001f + +/* Pixel Control Register */ +#define MIXSEL_FRGDMIX 0x0000 +#define MIXSEL_PATT 0x0040 +#define MIXSEL_EXPPC 0x0080 +#define MIXSEL_EXPBLT 0x00c0 +#define COLCMPOP_F 0x0000 +#define COLCMPOP_T 0x0008 +#define COLCMPOP_GE 0x0010 +#define COLCMPOP_LT 0x0018 +#define COLCMPOP_NE 0x0020 +#define COLCMPOP_EQ 0x0028 +#define COLCMPOP_LE 0x0030 +#define COLCMPOP_GT 0x0038 +#define PLANEMODE 0x0004 + +/* Multifunction Control Misc 8144 */ +#define MISC_DST_BA_0 (0x0 << 0) +#define MISC_DST_BA_1 (0x1 << 0) +#define MISC_DST_BA_2 (0x2 << 0) +#define MISC_DST_BA_3 (0x3 << 0) +#define MISC_SRC_BA_0 (0x0 << 2) +#define MISC_SRC_BA_1 (0x1 << 2) +#define MISC_SRC_BA_2 (0x2 << 2) +#define MISC_SRC_BA_3 (0x3 << 2) +#define MISC_RSF (1 << 4) +#define MISC_EXT_CLIP (1 << 5) +#define MISC_SRC_NE (1 << 7) +#define MISC_ENB_CMP (1 << 8) +#define MISC_32B (1 << 9) +#define MISC_DC (1 << 11) +#define MISC_INDEX_E (0xe << 12) + +#define S3_SAVAGE4_SLOTS 0x0001ffff +#define S3_SAVAGE4_2DI 0x00800000 + +#define _s3WaitLoop(s3,mask,value){ \ + int __loop = 1000000; \ + while (((s3)->alt_status_0 & (mask)) != (value)) \ + if (--__loop == 0) { \ + ErrorF ("savage wait loop failed 0x%x\n", s3->alt_status_0); \ + break; \ + } \ +} + +#define S3_SAVAGE4_ROOM 10 + +#define _s3WaitSlots(s3,n) { \ + int __loop = 1000000; \ + while (((s3)->alt_status_0 & S3_SAVAGE4_SLOTS) >= S3_SAVAGE4_ROOM-(n)) \ + if (--__loop == 0) { \ + ErrorF ("savage wait loop failed 0x%x\n", s3->alt_status_0); \ + break; \ + } \ +} + +#define _s3WaitEmpty(s3) _s3WaitLoop(s3,S3_SAVAGE4_SLOTS, 0) +#define _s3WaitIdleEmpty(s3) _s3WaitLoop(s3,S3_SAVAGE4_SLOTS|S3_SAVAGE4_2DI, S3_SAVAGE4_2DI) +#define _s3WaitIdle(s3) _s3WaitLoop(s3,S3_SAVAGE4_2DI, S3_SAVAGE4_2DI) + +typedef struct _s3Cursor { + int width, height; + int xhot, yhot; + Bool has_cursor; + CursorPtr pCursor; + Pixel source, mask; +} S3Cursor; + +typedef struct _s3PatternCache { + int id; + int x, y; +} S3PatternCache; + +typedef struct _s3Patterns { + S3PatternCache *cache; + int ncache; + int last_used; + int last_id; +} S3Patterns; + +#define S3_CLOCK_REF 14318 /* KHz */ + +#define S3_CLOCK(m,n,r) ((S3_CLOCK_REF * ((m) + 2)) / (((n) + 2) * (1 << (r)))) + +#define S3_MAX_CLOCK 150000 /* KHz */ + +typedef struct _s3Timing { + /* label */ + int horizontal; + int vertical; + int rate; + /* horizontal timing */ + int hfp; /* front porch */ + int hbp; /* back porch */ + int hblank; /* blanking */ + /* vertical timing */ + int vfp; /* front porch */ + int vbp; /* back porch */ + int vblank; /* blanking */ + /* clock values */ + int dac_m; + int dac_n; + int dac_r; +} S3Timing; + +#define S3_TEXT_SAVE (64*1024) + +typedef struct _s3Save { + CARD8 cursor_fg; + CARD8 cursor_bg; + CARD8 lock1; + CARD8 lock2; + CARD8 locksrtc; + CARD8 clock_mode; + CARD32 alt_mix; + CARD32 write_mask; + CARD32 fg; + CARD32 bg; + CARD32 global_bitmap_1; + CARD32 global_bitmap_2; + CARD32 adv_func_cntl; + CARD32 primary_bitmap_1; + CARD32 primary_bitmap_2; + CARD32 secondary_bitmap_1; + CARD32 secondary_bitmap_2; + CARD32 primary_stream_control; + CARD32 blend_control; + CARD32 primary_stream_addr_0; + CARD32 primary_stream_addr_1; + CARD32 primary_stream_stride; + CARD32 primary_stream_xy; + CARD32 primary_stream_size; + CARD32 primary_stream_mem; + CARD32 secondary_stream_xy; + CARD32 secondary_stream_size; + CARD32 streams_fifo; + CARD8 text_save[S3_TEXT_SAVE]; +} S3Save; + +typedef struct _s3CardInfo { + S3Ptr s3; /* pointer to register structure */ + int memory; /* amount of memory */ + CARD8 *frameBuffer; /* pointer to frame buffer */ + CARD8 *registers; /* pointer to register map */ + S3Vga s3vga; + S3Save save; + Bool need_sync; + Bool bios_initialized; /* whether the bios has been run */ +} S3CardInfo; + +typedef struct _s3FbInfo { + CARD8 *offscreen; /* pointer to offscreen area */ + int offscreen_y; /* top y coordinate of offscreen area */ + int offscreen_x; /* top x coordinate of offscreen area */ + int offscreen_width; /* width of offscreen area */ + int offscreen_height; /* height of offscreen area */ + S3Patterns patterns; + CARD32 bitmap_offset; + int accel_stride; + int accel_bpp; + CARD32 chroma_key; +} S3FBInfo; + +typedef struct _s3ScreenInfo { + CARD8 *cursor_base; /* pointer to cursor area */ + S3Cursor cursor; + Bool managing_border; + Bool use_streams; + int primary_depth; + int current_ma; + CARD32 border_pixel; + S3FBInfo fb[KD_MAX_FB]; + RegionRec region[KD_MAX_FB]; + int fbmap[KD_MAX_FB+1]; /* map from fb to stream */ +} S3ScreenInfo; + +#define getS3CardInfo(kd) ((S3CardInfo *) ((kd)->card->driver)) +#define s3CardInfo(kd) S3CardInfo *s3c = getS3CardInfo(kd) + +#define getS3ScreenInfo(kd) ((S3ScreenInfo *) ((kd)->screen->driver)) +#define s3ScreenInfo(kd) S3ScreenInfo *s3s = getS3ScreenInfo(kd) + +Bool s3CardInit (KdCardInfo *); +Bool s3ScreenInit (KdScreenInfo *); +Bool s3Enable (ScreenPtr pScreen); +void s3Disable (ScreenPtr pScreen); +void s3Fini (ScreenPtr pScreen); + +Bool s3CursorInit (ScreenPtr pScreen); +void s3CursorEnable (ScreenPtr pScreen); +void s3CursorDisable (ScreenPtr pScreen); +void s3CursorFini (ScreenPtr pScreen); +void s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs); + +void s3DumbCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc); + +Bool s3DrawInit (ScreenPtr pScreen); +void s3DrawEnable (ScreenPtr pScreen); +void s3DrawSync (ScreenPtr pScreen); +void s3DrawDisable (ScreenPtr pScreen); +void s3DrawFini (ScreenPtr pScreen); + +void s3GetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); +void s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs); + +void S3InitCard (KdCardAttr *attr); + +void s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR, int minVco); + +extern KdCardFuncs s3Funcs; + +/* + * Wait for the begining of the retrace interval + */ + +#define S3_RETRACE_LOOP_CHECK if (++_loop_count > 300000) {\ + DRAW_DEBUG ((DEBUG_FAILURE, "S3 wait loop failed at %s:%d", \ + __FILE__, __LINE__)); \ + break; \ +} + +#define DRAW_DEBUG(a) + +#define _s3WaitVRetrace(s3vga) { \ + int _loop_count; \ + _loop_count = 0; \ + while (s3GetImm(s3vga, s3_vertical_sync_active) != 0) S3_RETRACE_LOOP_CHECK; \ + _loop_count = 0; \ + while (s3GetImm(s3vga, s3_vertical_sync_active) == 0) S3_RETRACE_LOOP_CHECK; \ +} +#define _s3WaitVRetraceFast(s3) { \ + int _loop_count; \ + _loop_count = 0; \ + while (s3->input_status_1 & 8) S3_RETRACE_LOOP_CHECK; \ + _loop_count = 0; \ + while ((s3->input_status_1 & 8) == 0) S3_RETRACE_LOOP_CHECK; \ +} +/* + * Wait for the begining of the retrace interval + */ +#define _s3WaitVRetraceEnd(s3vga) { \ + int _loop_count; \ + _loop_count = 0; \ + while (s3GetImm(s3vga, s3_vertical_sync_active) == 0) S3_RETRACE_LOOP_CHECK; \ + _loop_count = 0; \ + while (s3GetImm(s3vga, s3_vertical_sync_active) != 0) S3_RETRACE_LOOP_CHECK; \ +} + +#define S3_CURSOR_WIDTH 64 +#define S3_CURSOR_HEIGHT 64 +#define S3_CURSOR_SIZE ((S3_CURSOR_WIDTH * S3_CURSOR_HEIGHT + 7) / 8) + +#define S3_TILE_SIZE 8 + +#endif /* _S3_H_ */ --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3gc.c +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3gc.c @@ -0,0 +1,299 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "s3.h" +#include "s3draw.h" + +#include "Xmd.h" +#include "gcstruct.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "regionstr.h" +#include "mistruct.h" +#include "fontstruct.h" +#include "dixfontstr.h" +#include "migc.h" + +/* + * Common op groups. Common assumptions: + * + * lineWidth 0 + * lineStyle LineSolid + * fillStyle FillSolid + * rop GXcopy + * font <= 32 pixels wide + */ + +/* TE font */ +static const GCOps s3TEOps = { + s3FillSpans, + KdCheckSetSpans, + KdCheckPutImage, + s3CopyArea, + s3CopyPlane, + KdCheckPolyPoint, + s3Polylines, + s3PolySegment, + KdCheckPolyRectangle, + KdCheckPolyArc, + s3FillPoly, + s3PolyFillRect, + s3PolyFillArcSolid, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + s3ImageTEGlyphBlt, + s3PolyTEGlyphBlt, + s3PushPixels +}; + +/* Non TE font */ +static const GCOps s3NonTEOps = { + s3FillSpans, + KdCheckSetSpans, + KdCheckPutImage, + s3CopyArea, + s3CopyPlane, + KdCheckPolyPoint, + s3Polylines, + s3PolySegment, + KdCheckPolyRectangle, + KdCheckPolyArc, + s3FillPoly, + s3PolyFillRect, + s3PolyFillArcSolid, + miPolyText8, + miPolyText16, + miImageText8, + miImageText16, + s3ImageGlyphBlt, + s3PolyGlyphBlt, + s3PushPixels +}; + +static GCOps * +s3MatchCommon (DrawablePtr pDraw, GCPtr pGC, FbGCPrivPtr fbPriv) +{ + KdScreenPriv (pDraw->pScreen); + + if (!REGION_NOTEMPTY(pDraw->pScreen,fbGetCompositeClip(pGC))) + { + DRAW_DEBUG ((DEBUG_CLIP, "Empty composite clip, clipping all ops")); + return &kdNoopOps; + } + + if (pDraw->type != DRAWABLE_WINDOW) + return (GCOps *) &kdAsyncPixmapGCOps; + + if (pGC->lineWidth != 0) + return 0; + if (pGC->lineStyle != LineSolid) + return 0; + if (pGC->fillStyle != FillSolid) + return 0; + if (fbPriv->and != 0) + return 0; + if (pGC->font) + { + if (TERMINALFONT(pGC->font)) + return (GCOps *) &s3TEOps; + else + return (GCOps *) &s3NonTEOps; + } + return 0; +} + +void +s3ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) +{ + int new_type; /* drawable type has changed */ + int new_origin; + + /* flags for changing the proc vector */ + FbGCPrivPtr fbPriv; + s3PrivGCPtr s3Priv; + int oneRect; + GCOps *newops; + + fbPriv = fbGetGCPrivate(pGC); + s3Priv = s3GetGCPrivate(pGC); + + new_type = FALSE; + new_origin = FALSE; + + /* + * If the type of drawable has changed, fix up accelerated functions + */ + if (s3Priv->type != pDrawable->type) + { + new_type = TRUE; + s3Priv->type = pDrawable->type; + } + + /* + * Check tile/stipple origin + */ + if (pGC->lastWinOrg.x != pDrawable->x || pGC->lastWinOrg.y != pDrawable->y) + new_origin = TRUE; + + /* + * Call down to FB to set clip list and rrop values + */ + + fbValidateGC (pGC, changes, pDrawable); + + /* + * Check accelerated pattern if necessary + */ + if (changes & (GCFillStyle|GCStipple|GCTile)) + s3CheckGCFill (pGC); + else if (s3Priv->pPattern && + (new_origin || changes & (GCTileStipXOrigin|GCTileStipYOrigin))) + s3MoveGCFill (pGC); + + /* + * Try to match common vector + */ + + if (newops = s3MatchCommon (pDrawable, pGC, fbPriv)) + { + if (pGC->ops->devPrivate.val) + miDestroyGCOps (pGC->ops); + pGC->ops = newops; + return; + } + + /* + * No common vector matched, create private ops vector and + * fill it in + */ + if (!pGC->ops->devPrivate.val) + { + /* + * Switch from noop vector by first switching to fb + * vector and fixing it up + */ + if (pGC->ops == &kdNoopOps) + { + pGC->ops = (GCOps *) &kdAsyncPixmapGCOps; + new_type = TRUE; + } + pGC->ops = miCreateGCOps (pGC->ops); + pGC->ops->devPrivate.val = 1; + } + + /* + * Fills + */ + if (new_type || (changes & (GCFillStyle|GCTile|GCStipple))) + { + pGC->ops->FillSpans = KdCheckFillSpans; + pGC->ops->PolyFillRect = KdCheckPolyFillRect; + if (s3Priv->type == DRAWABLE_WINDOW && + (pGC->fillStyle != FillTiled || s3Priv->pPattern)) + { + pGC->ops->FillSpans = s3FillSpans; + pGC->ops->PolyFillRect = s3PolyFillRect; + } + } + + /* + * Blt + */ + if (new_type) + { + pGC->ops->CopyArea = s3CopyArea; + pGC->ops->CopyPlane = s3CopyPlane; + pGC->ops->PushPixels = s3PushPixels; + } + + /* + * Lines + */ + if (new_type || (changes & (GCLineStyle|GCLineWidth|GCFillStyle))) + { + pGC->ops->Polylines = KdCheckPolylines; + pGC->ops->PolySegment = KdCheckPolySegment; + if (pGC->lineStyle == LineSolid && + pGC->lineWidth == 0 && + pGC->fillStyle == FillSolid && + s3Priv->type == DRAWABLE_WINDOW) + { + pGC->ops->Polylines = s3Polylines; + pGC->ops->PolySegment = s3PolySegment; + } + } + + /* + * Polygons + */ + if (new_type || (changes & (GCFillStyle))) + { + pGC->ops->FillPolygon = KdCheckFillPolygon; + if (s3Priv->type == DRAWABLE_WINDOW && + pGC->fillStyle == FillSolid) + { + pGC->ops->FillPolygon = s3FillPoly; + } + } + + /* + * Filled arcs + */ + if (new_type || (changes & GCFillStyle)) + { + pGC->ops->PolyFillArc = KdCheckPolyFillArc; + if (s3Priv->type == DRAWABLE_WINDOW && + pGC->fillStyle == FillSolid) + { + pGC->ops->PolyFillArc = s3PolyFillArcSolid; + } + } + + /* + * Text + */ + if (new_type || (changes & (GCFont|GCFillStyle))) + { + pGC->ops->PolyGlyphBlt = KdCheckPolyGlyphBlt; + pGC->ops->ImageGlyphBlt = KdCheckImageGlyphBlt; + if (s3Priv->type == DRAWABLE_WINDOW && pGC->font) + { + if (pGC->fillStyle == FillSolid) + { + if (TERMINALFONT(pGC->font)) + pGC->ops->PolyGlyphBlt = s3PolyTEGlyphBlt; + else + pGC->ops->PolyGlyphBlt = s3PolyGlyphBlt; + } + if (TERMINALFONT(pGC->font)) + pGC->ops->ImageGlyphBlt = s3ImageTEGlyphBlt; + else + pGC->ops->ImageGlyphBlt = s3ImageGlyphBlt; + } + } +} --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3clock.c +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3clock.c @@ -0,0 +1,84 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "s3.h" + +/* + * Clock synthesis: + * + * f_out = f_ref * ((M + 2) / ((N + 2) * (1 << R))) + * + * Constraints: + * + * 1. 135MHz <= f_ref * ((M + 2) / (N + 2)) <= 270 MHz + * 2. N >= 1 + * + * Vertical refresh rate = clock / ((hsize + hblank) * (vsize + vblank)) + * Horizontal refresh rate = clock / (hsize + hblank) + */ + +/* all in kHz */ + +void +s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR, int minVco) +{ + int M, N, R, bestM, bestN; + int f_vco, f_out; + int err, abserr, besterr; + + /* + * Compute correct R value to keep VCO in range + */ + for (R = 0; R <= maxR; R++) + { + f_vco = target * (1 << R); + if (f_vco >= minVco) + break; + } + + /* M = f_out / f_ref * ((N + 2) * (1 << R)); */ + besterr = target; + for (N = 1; N <= maxN; N++) + { + M = ((target * (N + 2) * (1 << R) + (S3_CLOCK_REF/2)) + S3_CLOCK_REF/2) / S3_CLOCK_REF - 2; + if (0 <= M && M <= maxM) + { + f_out = S3_CLOCK(M,N,R); + err = target - f_out; + if (err < 0) + err = -err; + if (err < besterr) + { + besterr = err; + bestM = M; + bestN = N; + } + } + } + *Mp = bestM; + *Np = bestN; + *Rp = R; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3cmap.c +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3cmap.c @@ -0,0 +1,122 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "s3.h" + +void +s3GetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) +{ + KdScreenPriv(pScreen); + s3CardInfo(pScreenPriv); + S3Vga *s3vga = &s3c->s3vga; + + while (ndef--) + { + s3SetImm (s3vga, s3_dac_read_index, pdefs->pixel); + pdefs->red = s3GetImm (s3vga, s3_dac_data) << 8; + pdefs->green = s3GetImm (s3vga, s3_dac_data) << 8; + pdefs->blue = s3GetImm (s3vga, s3_dac_data) << 8; + pdefs++; + } +} + +#ifndef S3_TRIO +#define Shift(v,d) ((d) < 0 ? ((v) >> (-d)) : ((v) << (d))) + +void +s3SetTrueChromaKey (ScreenPtr pScreen, int pfb, xColorItem *pdef) +{ + FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen); + KdScreenPriv(pScreen); + s3ScreenInfo(pScreenPriv); + int fb, ma; + CARD32 key; + int r, g, b; + + for (ma = 0; s3s->fbmap[ma] >= 0; ma++) + { + fb = s3s->fbmap[ma]; + if (fb != pfb && pScreenPriv->screen->fb[fb].redMask) + { + r = KdComputeCmapShift (pScreenPriv->screen->fb[fb].redMask); + g = KdComputeCmapShift (pScreenPriv->screen->fb[fb].greenMask); + b = KdComputeCmapShift (pScreenPriv->screen->fb[fb].blueMask); + key = ((Shift(pdef->red,r) & pScreenPriv->screen->fb[fb].redMask) | + (Shift(pdef->green,g) & pScreenPriv->screen->fb[fb].greenMask) | + (Shift(pdef->blue,b) & pScreenPriv->screen->fb[fb].blueMask)); + if (pScrPriv->layer[fb].key != key) + { + pScrPriv->layer[fb].key = key; + (*pScrPriv->PaintKey) (&pScrPriv->layer[fb].u.run.pixmap->drawable, + &pScrPriv->layer[pfb].u.run.region, + pScrPriv->layer[fb].key, fb); + } + } + } +} +#endif + +void +s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) +{ + KdScreenPriv(pScreen); + s3CardInfo(pScreenPriv); + s3ScreenInfo(pScreenPriv); + S3Vga *s3vga = &s3c->s3vga; + xColorItem *chroma = 0; + CARD32 key; + +#if 0 + _s3WaitVRetrace (s3vga); +#else + S3Ptr s3 = s3c->s3; + _s3WaitVRetraceFast(s3); +#endif +#ifndef S3_TRIO + if (pScreenPriv->screen->fb[1].depth) + { + FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen); + key = pScrPriv->layer[fb].key; + } +#endif + else + key = ~0; + while (ndef--) + { + if (pdefs->pixel == key) + chroma = pdefs; + s3SetImm (s3vga, s3_dac_write_index, pdefs->pixel); + s3SetImm (s3vga, s3_dac_data, pdefs->red >> 8); + s3SetImm (s3vga, s3_dac_data, pdefs->green >> 8); + s3SetImm (s3vga, s3_dac_data, pdefs->blue >> 8); + pdefs++; + } +#ifndef S3_TRIO + if (chroma && !pScreenPriv->closed) + s3SetTrueChromaKey (pScreen, fb, chroma); +#endif +} + --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3rtst.c +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3rtst.c @@ -0,0 +1,141 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include "s3reg.h" + +typedef struct { + VgaReg *reg; + char *name; +} NamedVgaReg; + +NamedVgaReg s3VRegs[] = { + s3_h_total, "h_total", + s3_h_display_end, "h_display_end", + s3_h_blank_start, "h_blank_start", + s3_h_blank_end, "h_blank_end", + s3_display_skew, "display_skew", + s3_h_sync_start, "h_sync_start", + s3_h_sync_end, "h_sync_end", + s3_h_skew, "h_skew", + s3_v_total, "v_total", + s3_preset_row_scan, "preset_row_scan", + s3_max_scan_line, "max_scan_line", + s3_start_address, "start_address", + s3_v_retrace_start, "v_retrace_start", + s3_v_retrace_end, "v_retrace_end", + s3_clear_v_retrace_int, "clear_v_retrace_int", + s3_disable_v_retrace_int, "disable_v_retrace_int", + s3_lock_crtc, "lock_crtc", + s3_v_display_end, "v_display_end", + s3_screen_offset, "screen_offset", + s3_count_by_4_mode, "count_by_4_mode", + s3_doubleword_mode, "doubleword_mode", + s3_v_blank_start, "v_blank_start", + s3_v_blank_end, "v_blank_end", + s3_v_total_double, "v_total_double", + s3_word_mode, "word_mode", + s3_byte_mode, "byte_mode", + s3_line_compare, "line_compare", + s3_device_id, "device_id", + s3_revision, "revision", + s3_lock_vert, "lock_vert", + s3_lock_horz, "lock_horz", + s3_io_disable, "io_disable", + s3_mem_size, "mem_size", + s3_register_lock_1 , "register_lock_1 ", + s3_register_lock_2 , "register_lock_2 ", + s3_refresh_control, "refresh_control", + s3_enable_256, "enable_256", + s3_enable_pci_read_bursts, "enable_pci_read_bursts", + s3_h_start_fifo_fetch, "h_start_fifo_fetch", + s3_interlace, "interlace", + s3_old_screen_off_8, "old_screen_off_8", + s3_h_counter_double_mode, "h_counter_double_mode", + s3_hardware_cursor_enable, "hardware_cursor_enable", + s3_hardware_cursor_right, "hardware_cursor_right", + s3_hardware_cursor_x, "hardware_cursor_x", + s3_hardware_cursor_y, "hardware_cursor_y", + s3_hardware_cursor_fg, "hardware_cursor_fg", + s3_cursor_address, "cursor_address", + s3_cursor_start_x, "cursor_start_x", + s3_cursor_start_y, "cursor_start_y", + s3_ge_screen_width, "ge_screen_width", + s3_pixel_length, "pixel_length", + s3_big_endian_linear, "big_endian_linear", + s3_mmio_select, "mmio_select", + s3_mmio_window, "mmio_window", + s3_swap_nibbles, "swap_nibbles", + s3_hardware_cursor_ms_x11, "hardware_cursor_ms_x11", + s3_h_blank_extend, "h_blank_extend", + s3_h_sync_extend, "h_sync_extend", + s3_enable_2d_3d, "enable_2d_3d", + s3_pci_disconnect_enable, "pci_disconnect_enable", + s3_pci_retry_enable, "pci_retry_enable", + s3_color_mode, "color_mode", + s3_screen_off, "screen_off", + s3_unlock_extended_sequencer, "unlock_extended_sequencer", + s3_disable_io_ports, "disable_io_ports", + s3_hsync_control, "hsync_control", + s3_vsync_control, "vsync_control", + s3_mclk_n, "mclk_n", + s3_mclk_r, "mclk_r", + s3_mclk_m, "mclk_m", + s3_dclk_n, "dclk_n", + s3_dclk_r, "dclk_r", + s3_dclk_m, "dclk_m", + s3_mclk_load, "mclk_load", + s3_dclk_load, "dclk_load", + s3_dclk_over_2, "dclk_over_2", + s3_clock_load_imm, "clock_load_imm", + s3_dclk_invert, "dclk_invert", + s3_enable_clock_double, "enable_clock_double", + s3_dclk_double_15_16_invert, "dclk_double_15_16_invert", + s3_enable_gamma_correction, "enable_gamma_correction", + s3_enable_8_bit_luts, "enable_8_bit_luts", + s3_dclk_control, "dclk_control", + s3_vga_dclk_n, "vga_dclk_n", + s3_vga_dclk_r, "vga_dclk_r", + s3_vga_dclk_m1, "vga_dclk_m1", + s3_vga_dclk_m2, "vga_dclk_m2", + s3_vga_clk_select, "vga_clk_select", + s3_clock_select, "clock_select", +}; + +#define NUM_S3_VREGS (sizeof (s3VRegs)/ sizeof (s3VRegs[0])) + +main (int argc, char **argv) +{ + int i; + + iopl(3); + s3SetImm(s3_register_lock_1, 0x48); + s3SetImm(s3_register_lock_2, 0xa0); + s3SetImm(s3_unlock_extended_sequencer, 0x06); + for (i = 0; i < NUM_S3_VREGS; i++) + printf ("%-20.20s %8x\n", s3VRegs[i].name, s3Get (s3VRegs[i].reg)); + s3Restore (); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3curs.c +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3curs.c @@ -0,0 +1,422 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "s3.h" +#include "s3draw.h" +#include "cursorstr.h" + +#define SetupCursor(s) KdScreenPriv(s); \ + s3CardInfo(pScreenPriv); \ + s3ScreenInfo(pScreenPriv); \ + S3Ptr s3 = s3c->s3; \ + S3Vga *s3vga = &s3c->s3vga; \ + S3Cursor *pCurPriv = &s3s->cursor + +static void +_s3MoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CARD8 xlow, xhigh, ylow, yhigh; + CARD8 xoff, yoff; + + DRAW_DEBUG ((DEBUG_CURSOR, "s3MoveCursor %d %d", x, y)); + + x -= pCurPriv->xhot; + xoff = 0; + if (x < 0) + { + xoff = -x; + x = 0; + } + y -= pCurPriv->yhot; + yoff = 0; + if (y < 0) + { + yoff = -y; + y = 0; + } + xlow = (CARD8) x; + xhigh = (CARD8) (x >> 8); + ylow = (CARD8) y; + yhigh = (CARD8) (y >> 8); + + + /* This is the recommended order to move the cursor */ + + s3SetImm (s3vga, s3_cursor_xhigh, xhigh); + s3SetImm (s3vga, s3_cursor_xlow, xlow); + s3SetImm (s3vga, s3_cursor_ylow, ylow); + s3SetImm (s3vga, s3_cursor_xoff, xoff); + s3SetImm (s3vga, s3_cursor_yoff, yoff); + s3SetImm (s3vga, s3_cursor_yhigh, yhigh); + + DRAW_DEBUG ((DEBUG_CURSOR, "s3MoveCursor done")); +} + +static void +s3MoveCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor (pScreen); + + if (!pCurPriv->has_cursor) + return; + + if (!pScreenPriv->enabled) + return; + + _s3MoveCursor (pScreen, x, y); +} + +#define S3Trunc(c) (((c) >> 8) & 0xff) + +#define S3CursColor(r,g,b) ((S3Trunc(r) << 16) | \ + (S3Trunc(g) << 8) | \ + (S3Trunc(b))) + +static void +s3AllocCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + + if (s3s->use_streams) + { + pCurPriv->source = S3CursColor(pCursor->foreRed, + pCursor->foreGreen, + pCursor->foreBlue); + pCurPriv->mask = S3CursColor(pCursor->backRed, + pCursor->backGreen, + pCursor->backBlue); + } + else + { + KdAllocateCursorPixels (pScreen, 0, pCursor, + &pCurPriv->source, &pCurPriv->mask); + switch (pScreenPriv->screen->fb[0].bitsPerPixel) { + case 4: + pCurPriv->source |= pCurPriv->source << 4; + pCurPriv->mask |= pCurPriv->mask << 4; + case 8: + pCurPriv->source |= pCurPriv->source << 8; + pCurPriv->mask |= pCurPriv->mask << 8; + case 16: + pCurPriv->source |= pCurPriv->source << 16; + pCurPriv->mask |= pCurPriv->mask << 16; + } + } +} + +static void +_s3SetCursorColors (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + /* set foreground */ + /* Reset cursor color stack pointers */ + (void) s3GetImm (s3vga, s3_cursor_enable); + s3SetImm (s3vga, s3_cursor_fg, pCurPriv->source); + s3SetImm (s3vga, s3_cursor_fg, pCurPriv->source >> 8); + s3SetImm (s3vga, s3_cursor_fg, pCurPriv->source >> 16); + + /* set background */ + /* Reset cursor color stack pointers */ + (void) s3GetImm (s3vga, s3_cursor_enable); + s3SetImm (s3vga, s3_cursor_bg, pCurPriv->mask); + s3SetImm (s3vga, s3_cursor_bg, pCurPriv->mask >> 8); + s3SetImm (s3vga, s3_cursor_bg, pCurPriv->mask >> 16); +} + +void +s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef) +{ + SetupCursor (pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + xColorItem sourceColor, maskColor; + + if (!pCurPriv->has_cursor || !pCursor) + return; + + if (!pScreenPriv->enabled) + return; + + if (pdef) + { + while (ndef) + { + if (pdef->pixel == pCurPriv->source || + pdef->pixel == pCurPriv->mask) + break; + ndef--; + } + if (!ndef) + return; + } + s3AllocCursorColors (pScreen); + _s3SetCursorColors (pScreen); +} + +static void +s3LoadCursor (ScreenPtr pScreen, int x, int y) +{ + SetupCursor(pScreen); + CursorPtr pCursor = pCurPriv->pCursor; + CursorBitsPtr bits = pCursor->bits; + int w, h; + unsigned char r[2], g[2], b[2]; + unsigned long *ram; + unsigned long *msk, *mskLine, *src, *srcLine; + unsigned long and, xor; + int i, j; + int cursor_address; + int wsrc; + unsigned char ramdac_control_; + + /* + * Allocate new colors + */ + s3AllocCursorColors (pScreen); + + pCurPriv->pCursor = pCursor; + pCurPriv->xhot = pCursor->bits->xhot; + pCurPriv->yhot = pCursor->bits->yhot; + + /* + * Stick new image into cursor memory + */ + ram = (unsigned long *) s3s->cursor_base; + mskLine = (unsigned long *) bits->mask; + srcLine = (unsigned long *) bits->source; + + h = bits->height; + if (h > S3_CURSOR_HEIGHT) + h = S3_CURSOR_HEIGHT; + + wsrc = BitmapBytePad(bits->width) / 4; /* ulongs per line */ + + for (i = 0; i < S3_CURSOR_HEIGHT; i++) { + msk = mskLine; + src = srcLine; + mskLine += wsrc; + srcLine += wsrc; + for (j = 0; j < S3_CURSOR_WIDTH / 32; j++) { + + unsigned long m, s; + + if (i < h && j < wsrc) + { + m = *msk++; + s = *src++; + xor = m & s; + and = ~m; + } + else + { + and = 0xffffffff; + xor = 0x00000000; + } + + S3AdjustBits32(and); + S3AdjustBits32(xor); +#define S3SwapNibbles(x) ((x) = (((x) & 0x0f0f0f0f) << 4 | \ + ((x) >> 4) & 0x0f0f0f0f)) + if (s3s->use_streams) + { + S3SwapNibbles(and); + S3SwapNibbles(xor); + } + *ram++ = (and & 0xffff) | (xor << 16); + *ram++ = (and >> 16) | (xor & 0xffff0000); + } + } + + _s3WaitIdle (s3); + + /* Set new color */ + _s3SetCursorColors (pScreen); + + /* Enable the cursor */ + s3SetImm (s3vga, s3_cursor_ms_x11, 0); + s3SetImm (s3vga, s3_cursor_enable, 1); + + /* Wait for VRetrace to make sure the position is read */ + _s3WaitVRetrace (s3vga); + + /* Move to new position */ + _s3MoveCursor (pScreen, x, y); +} + +static void +s3UnloadCursor (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + /* Disable cursor */ + s3SetImm (s3vga, s3_cursor_enable, 0); +} + +static Bool +s3RealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + SetupCursor(pScreen); + + if (!pScreenPriv->enabled) + return TRUE; + + /* miRecolorCursor does this */ + if (pCurPriv->pCursor == pCursor) + { + if (pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + s3LoadCursor (pScreen, x, y); + } + } + return TRUE; +} + +static Bool +s3UnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) +{ + return TRUE; +} + +static void +s3SetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) +{ + SetupCursor(pScreen); + + pCurPriv->pCursor = pCursor; + + if (!pScreenPriv->enabled) + return; + + if (pCursor) + s3LoadCursor (pScreen, x, y); + else + s3UnloadCursor (pScreen); +} + +miPointerSpriteFuncRec s3PointerSpriteFuncs = { + s3RealizeCursor, + s3UnrealizeCursor, + s3SetCursor, + s3MoveCursor, +}; + +static void +s3QueryBestSize (int class, + unsigned short *pwidth, unsigned short *pheight, + ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + switch (class) + { + case CursorShape: + if (*pwidth > pCurPriv->width) + *pwidth = pCurPriv->width; + if (*pheight > pCurPriv->height) + *pheight = pCurPriv->height; + if (*pwidth > pScreen->width) + *pwidth = pScreen->width; + if (*pheight > pScreen->height) + *pheight = pScreen->height; + break; + default: + fbQueryBestSize (class, pwidth, pheight, pScreen); + break; + } +} + +Bool +s3CursorInit (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!s3s->cursor_base) + { + DRAW_DEBUG ((DEBUG_CURSOR,"Not enough screen memory for cursor %d", s3d->memory)); + pCurPriv->has_cursor = FALSE; + return FALSE; + } + + pCurPriv->width = S3_CURSOR_WIDTH; + pCurPriv->height= S3_CURSOR_HEIGHT; + pScreen->QueryBestSize = s3QueryBestSize; + miPointerInitialize (pScreen, + &s3PointerSpriteFuncs, + &kdPointerScreenFuncs, + FALSE); + pCurPriv->has_cursor = TRUE; + pCurPriv->pCursor = NULL; + return TRUE; +} + +void +s3CursorEnable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + DRAW_DEBUG ((DEBUG_INIT, "s3CursorEnable")); + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + int x, y; + + miPointerPosition (&x, &y); + s3LoadCursor (pScreen, x, y); + } + else + s3UnloadCursor (pScreen); + } +} + +void +s3CursorDisable (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + if (!pScreenPriv->enabled) + return; + + if (pCurPriv->has_cursor) + { + if (pCurPriv->pCursor) + { + s3UnloadCursor (pScreen); + } + } +} + +void +s3CursorFini (ScreenPtr pScreen) +{ + SetupCursor (pScreen); + + pCurPriv->pCursor = NULL; +} --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3reg.c +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3reg.c @@ -0,0 +1,1301 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "s3reg.h" + +#define CR00 S3_CR+0x00 +#define CR01 S3_CR+0x01 +#define CR02 S3_CR+0x02 +#define CR03 S3_CR+0x03 +#define CR04 S3_CR+0x04 +#define CR05 S3_CR+0x05 +#define CR06 S3_CR+0x06 +#define CR07 S3_CR+0x07 +#define CR08 S3_CR+0x08 +#define CR09 S3_CR+0x09 +#define CR0A S3_CR+0x0A +#define CR0B S3_CR+0x0B +#define CR0C S3_CR+0x0C +#define CR0D S3_CR+0x0D +#define CR0E S3_CR+0x0E +#define CR0F S3_CR+0x0F +#define CR10 S3_CR+0x10 +#define CR11 S3_CR+0x11 +#define CR12 S3_CR+0x12 +#define CR13 S3_CR+0x13 +#define CR14 S3_CR+0x14 +#define CR15 S3_CR+0x15 +#define CR16 S3_CR+0x16 +#define CR17 S3_CR+0x17 +#define CR18 S3_CR+0x18 +#define CR19 S3_CR+0x19 +#define CR1A S3_CR+0x1A +#define CR1B S3_CR+0x1B +#define CR1C S3_CR+0x1C +#define CR1D S3_CR+0x1D +#define CR1E S3_CR+0x1E +#define CR1F S3_CR+0x1F +#define CR20 S3_CR+0x20 +#define CR21 S3_CR+0x21 +#define CR22 S3_CR+0x22 +#define CR23 S3_CR+0x23 +#define CR24 S3_CR+0x24 +#define CR25 S3_CR+0x25 +#define CR26 S3_CR+0x26 +#define CR27 S3_CR+0x27 +#define CR28 S3_CR+0x28 +#define CR29 S3_CR+0x29 +#define CR2A S3_CR+0x2A +#define CR2B S3_CR+0x2B +#define CR2C S3_CR+0x2C +#define CR2D S3_CR+0x2D +#define CR2E S3_CR+0x2E +#define CR2F S3_CR+0x2F +#define CR30 S3_CR+0x30 +#define CR31 S3_CR+0x31 +#define CR32 S3_CR+0x32 +#define CR33 S3_CR+0x33 +#define CR34 S3_CR+0x34 +#define CR35 S3_CR+0x35 +#define CR36 S3_CR+0x36 +#define CR37 S3_CR+0x37 +#define CR38 S3_CR+0x38 +#define CR39 S3_CR+0x39 +#define CR3A S3_CR+0x3A +#define CR3B S3_CR+0x3B +#define CR3C S3_CR+0x3C +#define CR3D S3_CR+0x3D +#define CR3E S3_CR+0x3E +#define CR3F S3_CR+0x3F +#define CR40 S3_CR+0x40 +#define CR41 S3_CR+0x41 +#define CR42 S3_CR+0x42 +#define CR43 S3_CR+0x43 +#define CR44 S3_CR+0x44 +#define CR45 S3_CR+0x45 +#define CR46 S3_CR+0x46 +#define CR47 S3_CR+0x47 +#define CR48 S3_CR+0x48 +#define CR49 S3_CR+0x49 +#define CR4A S3_CR+0x4A +#define CR4B S3_CR+0x4B +#define CR4C S3_CR+0x4C +#define CR4D S3_CR+0x4D +#define CR4E S3_CR+0x4E +#define CR4F S3_CR+0x4F +#define CR50 S3_CR+0x50 +#define CR51 S3_CR+0x51 +#define CR52 S3_CR+0x52 +#define CR53 S3_CR+0x53 +#define CR54 S3_CR+0x54 +#define CR55 S3_CR+0x55 +#define CR56 S3_CR+0x56 +#define CR57 S3_CR+0x57 +#define CR58 S3_CR+0x58 +#define CR59 S3_CR+0x59 +#define CR5A S3_CR+0x5A +#define CR5B S3_CR+0x5B +#define CR5C S3_CR+0x5C +#define CR5D S3_CR+0x5D +#define CR5E S3_CR+0x5E +#define CR5F S3_CR+0x5F +#define CR60 S3_CR+0x60 +#define CR61 S3_CR+0x61 +#define CR62 S3_CR+0x62 +#define CR63 S3_CR+0x63 +#define CR64 S3_CR+0x64 +#define CR65 S3_CR+0x65 +#define CR66 S3_CR+0x66 +#define CR67 S3_CR+0x67 +#define CR68 S3_CR+0x68 +#define CR69 S3_CR+0x69 +#define CR6A S3_CR+0x6A +#define CR6B S3_CR+0x6B +#define CR6C S3_CR+0x6C +#define CR6D S3_CR+0x6D +#define CR6E S3_CR+0x6E +#define CR6F S3_CR+0x6F +#define CR70 S3_CR+0x70 +#define CR71 S3_CR+0x71 +#define CR72 S3_CR+0x72 +#define CR73 S3_CR+0x73 +#define CR74 S3_CR+0x74 +#define CR75 S3_CR+0x75 +#define CR76 S3_CR+0x76 +#define CR77 S3_CR+0x77 +#define CR78 S3_CR+0x78 +#define CR79 S3_CR+0x79 +#define CR7A S3_CR+0x7A +#define CR7B S3_CR+0x7B +#define CR7C S3_CR+0x7C +#define CR7D S3_CR+0x7D +#define CR7E S3_CR+0x7E +#define CR7F S3_CR+0x7F +#define CR80 S3_CR+0x80 +#define CR81 S3_CR+0x81 +#define CR82 S3_CR+0x82 +#define CR83 S3_CR+0x83 +#define CR84 S3_CR+0x84 +#define CR85 S3_CR+0x85 +#define CR86 S3_CR+0x86 +#define CR87 S3_CR+0x87 +#define CR88 S3_CR+0x88 +#define CR89 S3_CR+0x89 +#define CR8A S3_CR+0x8A +#define CR8B S3_CR+0x8B +#define CR8C S3_CR+0x8C +#define CR8D S3_CR+0x8D +#define CR8E S3_CR+0x8E +#define CR8F S3_CR+0x8F +#define CR90 S3_CR+0x90 +#define CR91 S3_CR+0x91 +#define CR92 S3_CR+0x92 +#define CR93 S3_CR+0x93 +#define CR94 S3_CR+0x94 +#define CR95 S3_CR+0x95 +#define CR96 S3_CR+0x96 +#define CR97 S3_CR+0x97 +#define CR98 S3_CR+0x98 +#define CR99 S3_CR+0x99 +#define CR9A S3_CR+0x9A +#define CR9B S3_CR+0x9B +#define CR9C S3_CR+0x9C +#define CR9D S3_CR+0x9D +#define CR9E S3_CR+0x9E +#define CR9F S3_CR+0x9F +#define CRA0 S3_CR+0xA0 +#define CRA1 S3_CR+0xA1 +#define CRA2 S3_CR+0xA2 +#define CRA3 S3_CR+0xA3 +#define CRA4 S3_CR+0xA4 +#define CRA5 S3_CR+0xA5 +#define CRA6 S3_CR+0xA6 +#define CRA7 S3_CR+0xA7 +#define CRA8 S3_CR+0xA8 +#define CRA9 S3_CR+0xA9 +#define CRAA S3_CR+0xAA +#define CRAB S3_CR+0xAB +#define CRAC S3_CR+0xAC +#define CRAD S3_CR+0xAD +#define CRAE S3_CR+0xAE +#define CRAF S3_CR+0xAF +#define CRB0 S3_CR+0xB0 +#define CRB1 S3_CR+0xB1 +#define CRB2 S3_CR+0xB2 +#define CRB3 S3_CR+0xB3 +#define CRB4 S3_CR+0xB4 +#define CRB5 S3_CR+0xB5 +#define CRB6 S3_CR+0xB6 +#define CRB7 S3_CR+0xB7 +#define CRB8 S3_CR+0xB8 +#define CRB9 S3_CR+0xB9 +#define CRBA S3_CR+0xBA +#define CRBB S3_CR+0xBB +#define CRBC S3_CR+0xBC +#define CRBD S3_CR+0xBD +#define CRBE S3_CR+0xBE +#define CRBF S3_CR+0xBF + +#define CR_FIRST CR00 + +VgaReg s3_h_total[] = { + CR00, 0, 8, + CR5D, 0, 1, + CR5F, 0, 2, + VGA_REG_END +}; + +VgaReg s3_h_display_end[] = { + CR01, 0, 8, + CR5D, 1, 1, + CR5F, 2, 2, + VGA_REG_END +}; + +VgaReg s3_h_blank_start[] = { + CR02, 0, 8, + CR5D, 2, 1, + CR5F, 4, 2, + VGA_REG_END +}; + +VgaReg s3_h_blank_end[] = { + CR03, 0, 5, + CR05, 7, 1, + VGA_REG_END +}; + +VgaReg s3_display_skew[] = { + CR03, 5, 2, + VGA_REG_END +}; + +VgaReg s3_h_sync_start[] = { + CR04, 0, 8, + CR5D, 4, 1, + CR5F, 6, 2, + VGA_REG_END +}; + +VgaReg s3_h_sync_end[] = { + CR05, 0, 5, + VGA_REG_END +}; + +VgaReg s3_h_skew[] = { + CR05, 5, 2, + VGA_REG_END +}; + +VgaReg s3_v_total[] = { + CR06, 0, 8, + CR07, 0, 1, + CR07, 5, 1, + CR5E, 0, 1, + VGA_REG_END +}; + +VgaReg s3_preset_row_scan[] = { + CR08, 0, 8, + VGA_REG_END +}; + +VgaReg s3_max_scan_line[] = { + CR09, 0, 5, + VGA_REG_END +}; + +VgaReg s3_start_address[] = { + CR0D, 0, 8, + CR0C, 0, 8, + CR69, 0, 7, + VGA_REG_END +}; + +VgaReg s3_v_retrace_start[] = { + CR10, 0, 8, + CR07, 2, 1, + CR07, 7, 1, + CR5E, 4, 1, + VGA_REG_END +}; + +VgaReg s3_v_retrace_end[] = { + CR11, 0, 4, + VGA_REG_END +}; + +VgaReg s3_clear_v_retrace_int[] = { + CR11, 4, 1, + VGA_REG_END +}; + +VgaReg s3_disable_v_retrace_int[] = { + CR11, 5, 1, + VGA_REG_END +}; + +VgaReg s3_lock_crtc[] = { + CR11, 7, 1, + VGA_REG_END +}; + +VgaReg s3_v_display_end[] = { + CR12, 0, 8, + CR07, 1, 1, + CR07, 6, 1, + CR5E, 1, 1, + VGA_REG_END +}; + +VgaReg s3_screen_offset[] = { + CR13, 0, 8, + CR51, 4, 2, + VGA_REG_END +}; + +VgaReg s3_count_by_4_mode[] = { + CR14, 5, 1, + VGA_REG_END +}; + +VgaReg s3_doubleword_mode[] = { + CR14, 6, 1, + VGA_REG_END +}; + +VgaReg s3_v_blank_start[] = { + CR15, 0, 8, + CR07, 3, 1, + CR09, 5, 1, + CR5E, 2, 1, + VGA_REG_END +}; + +VgaReg s3_v_blank_end[] = { + CR16, 0, 8, + VGA_REG_END +}; + +VgaReg s3_2bk_cga[] = { + CR17, 0, 1, + VGA_REG_END +}; + +VgaReg s3_4bk_hga[] = { + CR17, 1, 1, + VGA_REG_END +}; + +VgaReg s3_v_total_double[] = { + CR17, 2, 1, + VGA_REG_END +}; + +VgaReg s3_word_mode[] = { + CR17, 3, 1, + VGA_REG_END +}; + +VgaReg s3_address_16k_wrap[] = { + CR17, 5, 1, + VGA_REG_END +}; + +VgaReg s3_byte_mode[] = { + CR17, 6, 1, + VGA_REG_END +}; + +VgaReg s3_hardware_reset[] = { + CR17, 7, 1, + VGA_REG_END +}; + +VgaReg s3_line_compare[] = { + CR18, 0, 8, + CR07, 4, 1, + CR09, 6, 1, + CR5E, 6, 1, + VGA_REG_END +}; + +VgaReg s3_delay_primary_load[] = { + CR21, 1, 1, + VGA_REG_END +}; + +VgaReg s3_device_id[] = { + CR2E, 0, 8, + CR2D, 0, 8, + VGA_REG_END +}; + +VgaReg s3_revision[] = { + CR2F, 0, 8, + VGA_REG_END +}; + +VgaReg s3_enable_vga_16bit[] = { + CR31, 2, 1, + VGA_REG_END +}; + +VgaReg s3_enhanced_memory_mapping[] = { + CR31, 3, 1, + VGA_REG_END +}; + +VgaReg s3_lock_dac_writes[] = { + CR33, 4, 1, + VGA_REG_END +}; + +VgaReg s3_border_select[] = { + CR33, 5, 1, + VGA_REG_END +}; + +VgaReg s3_lock_palette[] = { + CR33, 6, 1, + VGA_REG_END +}; + +VgaReg s3_enable_sff[] = { + CR34, 4, 1, + VGA_REG_END +}; + +VgaReg s3_lock_vert[] = { + CR35, 4, 1, + VGA_REG_END +}; + +VgaReg s3_lock_horz[] = { + CR35, 5, 1, + VGA_REG_END +}; + +VgaReg s3_io_disable[] = { + CR36, 4, 1, + VGA_REG_END +}; + +VgaReg s3_mem_size[] = { + CR36, 5, 3, + VGA_REG_END +}; + +VgaReg s3_register_lock_1 [] = { + CR38, 0, 8, /* load with 0x48 */ + VGA_REG_END +}; + +VgaReg s3_register_lock_2 [] = { + CR39, 0, 8, /* load with 0xa0 */ + VGA_REG_END +}; + +VgaReg s3_refresh_control[] = { + CR3A, 0, 2, + VGA_REG_END +}; + +VgaReg s3_enable_256[] = { + CR3A, 4, 1, + VGA_REG_END +}; + +VgaReg s3_disable_pci_read_bursts[] = { + CR3A, 7, 1, + VGA_REG_END +}; + +VgaReg s3_h_start_fifo_fetch[] = { + CR3B, 0, 8, + CR5D, 6, 1, + CR5B, 2, 2, + VGA_REG_END +}; + +VgaReg s3_enable_2d_access[] = { + CR40, 0, 1, + VGA_REG_END +}; + +VgaReg s3_interlace[] = { + CR42, 5, 1, + VGA_REG_END +}; + +VgaReg s3_old_screen_off_8[] = { + CR43, 2, 1, + VGA_REG_END +}; + +VgaReg s3_h_counter_double_mode[] = { + CR43, 7, 1, + VGA_REG_END +}; + +VgaReg s3_cursor_enable[] = { + CR45, 0, 1, + VGA_REG_END +}; + +VgaReg s3_cursor_right[] = { + CR45, 4, 1, + VGA_REG_END +}; + +VgaReg s3_cursor_xhigh[] = { + CR46, 0, 3, + VGA_REG_END +}; + +VgaReg s3_cursor_xlow[] = { + CR47, 0, 8, + VGA_REG_END +}; + +VgaReg s3_cursor_yhigh[] = { + CR48, 0, 3, + VGA_REG_END +}; + +VgaReg s3_cursor_ylow[] = { + CR49, 0, 8, + VGA_REG_END +}; + +VgaReg s3_cursor_fg[] = { + CR4A, 0, 8, + VGA_REG_END +}; + +VgaReg s3_cursor_bg[] = { + CR4B, 0, 8, + VGA_REG_END +}; + +VgaReg s3_cursor_address[] = { + CR4D, 0, 8, + CR4C, 0, 8, + VGA_REG_END +}; + +VgaReg s3_cursor_xoff[] = { + CR4E, 0, 6, + VGA_REG_END +}; + +VgaReg s3_cursor_yoff[] = { + CR4F, 0, 6, + VGA_REG_END +}; + +VgaReg s3_ge_screen_width[] = { + CR50, 6, 2, + CR50, 0, 1, + VGA_REG_END +}; + +VgaReg s3_pixel_length[] = { + CR50, 4, 2, + VGA_REG_END +}; + +VgaReg s3_big_endian_linear[] = { + CR53, 1, 2, + VGA_REG_END +}; + +VgaReg s3_mmio_select[] = { + CR53, 3, 2, + VGA_REG_END +}; + +VgaReg s3_mmio_window[] = { + CR53, 5, 1, + VGA_REG_END +}; + +VgaReg s3_swap_nibbles[] = { + CR53, 6, 1, + VGA_REG_END +}; + +VgaReg s3_cursor_ms_x11[] = { + CR55, 4, 1, + VGA_REG_END +}; + +VgaReg s3_linear_window_size[] = { + CR58, 0, 2, + VGA_REG_END +}; + +VgaReg s3_enable_linear[] = { + CR58, 4, 1, + VGA_REG_END +}; + +VgaReg s3_h_blank_extend[] = { + CR5D, 3, 1, + VGA_REG_END +}; + +VgaReg s3_h_sync_extend[] = { + CR5D, 5, 1, + VGA_REG_END +}; + +VgaReg s3_sdclk_skew[] = { + CR60, 0, 4, + VGA_REG_END +}; + +VgaReg s3_delay_blank[] = { + CR65, 3, 2, + VGA_REG_END +}; + +VgaReg s3_delay_h_enable[] = { + CR65, 6, 2, + CR65, 0, 1, + VGA_REG_END +}; + +VgaReg s3_enable_2d_3d[] = { + CR66, 0, 1, + VGA_REG_END +}; + +VgaReg s3_pci_disconnect_enable[] = { + CR66, 3, 1, + VGA_REG_END +}; + +VgaReg s3_primary_load_control[] = { + CR66, 4, 1, + VGA_REG_END +}; + +VgaReg s3_secondary_load_control[] = { + CR66, 5, 1, + VGA_REG_END +}; + +VgaReg s3_pci_retry_enable[] = { + CR66, 7, 1, + VGA_REG_END +}; + +VgaReg s3_streams_mode[] = { + CR67, 2, 2, + VGA_REG_END +}; + +VgaReg s3_color_mode[] = { + CR67, 4, 4, + VGA_REG_END +}; + +VgaReg s3_primary_stream_definition[] = { + CR69, 7, 1, + VGA_REG_END +}; + +VgaReg s3_primary_stream_timeout[] = { + CR71, 0, 8, + VGA_REG_END +}; + +VgaReg s3_master_control_unit_timeout[] = { + CR74, 0, 8, + VGA_REG_END +}; + +VgaReg s3_command_buffer_timeout[] = { + CR75, 0, 8, + VGA_REG_END +}; + +VgaReg s3_lpb_timeout[] = { + CR76, 0, 8, + VGA_REG_END +}; + +VgaReg s3_cpu_timeout[] = { + CR78, 0, 8, + VGA_REG_END +}; + +VgaReg s3_2d_graphics_engine_timeout[] = { + CR79, 0, 8, + VGA_REG_END +}; + +VgaReg s3_fifo_drain_delay[] = { + CR85, 0, 3, + VGA_REG_END +}; + +VgaReg s3_fifo_fetch_timing[] = { + CR85, 4, 1, + VGA_REG_END +}; + +VgaReg s3_dac_power_up_time[] = { + CR86, 0, 7, + VGA_REG_END +}; + +VgaReg s3_dac_power_saving_disable[] = { + CR86, 7, 1, + VGA_REG_END +}; + +VgaReg s3_flat_panel_output_control_1[] = { + CR90, 3, 1, + VGA_REG_END +}; + +VgaReg s3_streams_fifo_delay[] = { + CR90, 4, 2, + VGA_REG_END +}; + +VgaReg s3_flat_panel_output_control_2[] = { + CR90, 6, 1, + VGA_REG_END +}; + +VgaReg s3_enable_l1_parameter[] = { + CR90, 7, 1, + VGA_REG_END +}; + +VgaReg s3_primary_stream_l1[] = { + CR91, 0, 8, + CR90, 0, 3, + VGA_REG_END +}; + +#define CR_LAST CR91 + +#define SR00 S3_SR+0x00 +#define SR01 S3_SR+0x01 +#define SR02 S3_SR+0x02 +#define SR03 S3_SR+0x03 +#define SR04 S3_SR+0x04 +#define SR05 S3_SR+0x05 +#define SR06 S3_SR+0x06 +#define SR07 S3_SR+0x07 +#define SR08 S3_SR+0x08 +#define SR09 S3_SR+0x09 +#define SR0A S3_SR+0x0A +#define SR0B S3_SR+0x0B +#define SR0C S3_SR+0x0C +#define SR0D S3_SR+0x0D +#define SR0E S3_SR+0x0E +#define SR0F S3_SR+0x0F +#define SR10 S3_SR+0x10 +#define SR11 S3_SR+0x11 +#define SR12 S3_SR+0x12 +#define SR13 S3_SR+0x13 +#define SR14 S3_SR+0x14 +#define SR15 S3_SR+0x15 +#define SR16 S3_SR+0x16 +#define SR17 S3_SR+0x17 +#define SR18 S3_SR+0x18 +#define SR19 S3_SR+0x19 +#define SR1A S3_SR+0x1A +#define SR1B S3_SR+0x1B +#define SR1C S3_SR+0x1C +#define SR1D S3_SR+0x1D +#define SR1E S3_SR+0x1E +#define SR1F S3_SR+0x1F +#define SR20 S3_SR+0x20 +#define SR21 S3_SR+0x21 +#define SR22 S3_SR+0x22 +#define SR23 S3_SR+0x23 +#define SR24 S3_SR+0x24 +#define SR25 S3_SR+0x25 +#define SR26 S3_SR+0x26 +#define SR27 S3_SR+0x27 +#define SR28 S3_SR+0x28 +#define SR29 S3_SR+0x29 +#define SR2A S3_SR+0x2A +#define SR2B S3_SR+0x2B +#define SR2C S3_SR+0x2C +#define SR2D S3_SR+0x2D +#define SR2E S3_SR+0x2E +#define SR2F S3_SR+0x2F +#define SR30 S3_SR+0x30 +#define SR31 S3_SR+0x31 +#define SR32 S3_SR+0x32 +#define SR33 S3_SR+0x33 +#define SR34 S3_SR+0x34 +#define SR35 S3_SR+0x35 +#define SR36 S3_SR+0x36 +#define SR37 S3_SR+0x37 +#define SR38 S3_SR+0x38 +#define SR39 S3_SR+0x39 +#define SR3A S3_SR+0x3A +#define SR3B S3_SR+0x3B +#define SR3C S3_SR+0x3C +#define SR3D S3_SR+0x3D +#define SR3E S3_SR+0x3E +#define SR3F S3_SR+0x3F +#define SR40 S3_SR+0x40 +#define SR41 S3_SR+0x41 +#define SR42 S3_SR+0x42 +#define SR43 S3_SR+0x43 +#define SR44 S3_SR+0x44 +#define SR45 S3_SR+0x45 +#define SR46 S3_SR+0x46 +#define SR47 S3_SR+0x47 +#define SR48 S3_SR+0x48 +#define SR49 S3_SR+0x49 +#define SR4A S3_SR+0x4A +#define SR4B S3_SR+0x4B +#define SR4C S3_SR+0x4C +#define SR4D S3_SR+0x4D +#define SR4E S3_SR+0x4E +#define SR4F S3_SR+0x4F +#define SR50 S3_SR+0x50 +#define SR51 S3_SR+0x51 +#define SR52 S3_SR+0x52 +#define SR53 S3_SR+0x53 +#define SR54 S3_SR+0x54 +#define SR55 S3_SR+0x55 +#define SR56 S3_SR+0x56 +#define SR57 S3_SR+0x57 +#define SR58 S3_SR+0x58 +#define SR59 S3_SR+0x59 +#define SR5A S3_SR+0x5A +#define SR5B S3_SR+0x5B +#define SR5C S3_SR+0x5C +#define SR5D S3_SR+0x5D +#define SR5E S3_SR+0x5E +#define SR5F S3_SR+0x5F +#define SR60 S3_SR+0x60 +#define SR61 S3_SR+0x61 +#define SR62 S3_SR+0x62 +#define SR63 S3_SR+0x63 +#define SR64 S3_SR+0x64 +#define SR65 S3_SR+0x65 +#define SR66 S3_SR+0x66 +#define SR67 S3_SR+0x67 +#define SR68 S3_SR+0x68 +#define SR69 S3_SR+0x69 +#define SR6A S3_SR+0x6A +#define SR6B S3_SR+0x6B +#define SR6C S3_SR+0x6C +#define SR6D S3_SR+0x6D +#define SR6E S3_SR+0x6E +#define SR6F S3_SR+0x6F + +#define SR_FIRST SR02 + +VgaReg s3_dot_clock_8[] = { + SR01, 0, 1, + VGA_REG_END +}; + +VgaReg s3_screen_off[] = { + SR01, 5, 1, + VGA_REG_END +}; + +VgaReg s3_enable_write_plane[] = { + SR02, 0, 4, + VGA_REG_END +}; + +VgaReg s3_extended_memory_access[] = { + SR04, 1, 1, + VGA_REG_END +}; + +VgaReg s3_sequential_addressing_mode[] = { + SR04, 2, 1, + VGA_REG_END +}; + +VgaReg s3_select_chain_4_mode[] = { + SR04, 3, 1, + VGA_REG_END +}; + +VgaReg s3_unlock_extended_sequencer[] = { + SR08, 0, 8, /* write 0x06 */ + VGA_REG_END +}; + +VgaReg s3_linear_addressing_control[] = { + SR09, 0, 1, + VGA_REG_END +}; + +VgaReg s3_disable_io_ports[] = { + SR09, 7, 1, + VGA_REG_END +}; + +VgaReg s3_hsync_control[] = { + SR0D, 4, 2, + VGA_REG_END +}; + +VgaReg s3_vsync_control[] = { + SR0D, 6, 2, + VGA_REG_END +}; + +VgaReg s3_mclk_n[] = { + SR10, 0, 5, + VGA_REG_END +}; + +VgaReg s3_mclk_r[] = { + SR10, 5, 2, + VGA_REG_END +}; + +VgaReg s3_mclk_m[] = { + SR11, 0, 7, + VGA_REG_END +}; + +VgaReg s3_dclk_n[] = { + SR12, 0, 6, + SR29, 4, 1, + VGA_REG_END +}; + +VgaReg s3_dclk_r[] = { + SR12, 6, 2, + SR29, 2, 1, + VGA_REG_END +}; + +VgaReg s3_dclk_m[] = { + SR13, 0, 8, + SR29, 3, 1, + VGA_REG_END +}; + +VgaReg s3_mclk_load[] = { + SR15, 0, 1, + VGA_REG_END +}; + +VgaReg s3_dclk_load[] = { + SR15, 1, 1, + VGA_REG_END +}; + +VgaReg s3_dclk_over_2[] = { + SR15, 4, 1, + VGA_REG_END +}; + +VgaReg s3_clock_load_imm[] = { + SR15, 5, 1, + VGA_REG_END +}; + +VgaReg s3_dclk_invert[] = { + SR15, 6, 1, + VGA_REG_END +}; + +VgaReg s3_enable_clock_double[] = { + SR18, 7, 1, + VGA_REG_END +}; + +VgaReg s3_dclk_double_15_16_invert[] = { + SR1A, 0, 1, + VGA_REG_END +}; + +VgaReg s3_enable_gamma_correction[] = { + SR1B, 3, 1, + VGA_REG_END +}; + +VgaReg s3_enable_8_bit_luts[] = { + SR1B, 4, 1, + VGA_REG_END +}; + +VgaReg s3_dclk_control[] = { + SR1B, 7, 1, + VGA_REG_END +}; + +VgaReg s3_eclk_n[] = { + SR32, 0, 5, + VGA_REG_END +}; + +VgaReg s3_eclk_r[] = { + SR32, 5, 2, + VGA_REG_END +}; + +VgaReg s3_eclk_m[] = { + SR32, 0, 5, + VGA_REG_END +}; + +VgaReg s3_vga_dclk_n[] = { + SR36, 0, 6, + SR39, 4, 1, + VGA_REG_END +}; + +VgaReg s3_vga_dclk_r[] = { + SR36, 6, 2, + SR39, 2, 1, + VGA_REG_END +}; + +VgaReg s3_vga_dclk_m1[] = { + SR37, 0, 8, + SR39, 3, 1, + VGA_REG_END +}; + +VgaReg s3_vga_dclk_m2[] = { + SR38, 0, 8, + SR39, 3, 1, + VGA_REG_END +}; + +VgaReg s3_vga_clk_select[] = { + SR39, 0, 1, + VGA_REG_END +}; + +#define SR_LAST SR39 + +#define AR00 (S3_AR+0x00) +#define AR10 (S3_AR+0x10) +#define AR11 (S3_AR+0x11) +#define AR12 (S3_AR+0x12) +#define AR13 (S3_AR+0x13) +#define AR14 (S3_AR+0x14) + +#define AR_FIRST AR00 + +VgaReg s3_select_graphics_mode[] = { + AR10, 0, 1, + VGA_REG_END +}; + +VgaReg s3_enable_blinking[] = { + AR10, 3, 1, + VGA_REG_END +}; + +VgaReg s3_border_color[] = { + AR11, 0, 8, + VGA_REG_END +}; + +#define AR_LAST AR11 + +VgaReg s3_io_addr_select[] = { + S3_MISC_OUT, 0, 1, + VGA_REG_END +}; + +VgaReg s3_enable_ram[] = { + S3_MISC_OUT, 1, 1, + VGA_REG_END +}; + +VgaReg s3_clock_select[] = { + S3_MISC_OUT, 2, 2, + VGA_REG_END +}; + +VgaReg s3_horz_sync_neg[] = { + S3_MISC_OUT, 6, 1, + VGA_REG_END +}; + +VgaReg s3_vert_sync_neg[] = { + S3_MISC_OUT, 7, 1, + VGA_REG_END +}; + +VgaReg s3_display_mode_inactive[] = { + S3_INPUT_STATUS_1, 0, 1, + VGA_REG_END +}; + +VgaReg s3_vertical_sync_active[] = { + S3_INPUT_STATUS_1, 3, 1, + VGA_REG_END +}; + +VgaReg s3_dac_mask[] = { + S3_DAC + 0, 0, 8, + VGA_REG_END +}; + +VgaReg s3_dac_read_index[] = { + S3_DAC + 1, 0, 8, + VGA_REG_END +}; + +VgaReg s3_dac_write_index[] = { + S3_DAC + 2, 0, 8, + VGA_REG_END +}; + +VgaReg s3_dac_data[] = { + S3_DAC + 3, 0, 8, + VGA_REG_END +}; + +VGA8 +_s3Inb (VgaCard *card, VGA16 port) +{ + VGAVOL8 *reg; + + if (card->closure) + return VgaReadMemb ((VGA32) card->closure + port); + else + return VgaInb (port); +} + +void +_s3Outb (VgaCard *card, VGA8 value, VGA16 port) +{ + if (card->closure) + VgaWriteMemb (value, (VGA32) card->closure + port); + else + VgaOutb (value, port); +} + +void +_s3RegMap (VgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write) +{ + + if (reg < S3_SR + S3_NSR) + { + map->access = VgaAccessIndIo; + map->port = 0x3c4; + map->addr = 0; + map->value = 1; + map->index = reg - S3_SR; + } + else if (reg < S3_GR + S3_NGR) + { + map->access = VgaAccessIndIo; + map->port = 0x3ce; + map->addr = 0; + map->value = 1; + map->index = reg - S3_GR; + } + else if (reg < S3_AR + S3_NAR) + { + reg -= S3_AR; + map->access = VgaAccessDone; + /* reset AFF to index */ + (void) _s3Inb (card, 0x3da); + if (reg >= 16) + reg |= 0x20; + _s3Outb (card, reg, 0x3c0); + if (write) + _s3Outb (card, map->value, 0x3c0); + else + map->value = _s3Inb (card, 0x3c1); + if (!(reg & 0x20)) + { + /* enable video display again */ + (void) _s3Inb (card, 0x3da); + _s3Outb (card, 0x20, 0x3c0); + } + return; + } + else if (reg < S3_CR + S3_NCR) + { + map->access = VgaAccessIndIo; + map->port = 0x3d4; + map->addr = 0; + map->value = 1; + map->index = reg - S3_CR; + } + else if (reg < S3_DAC + S3_NDAC) + { + map->access = VgaAccessIo; + map->port = 0x3c6 + reg - S3_DAC; + } + else switch (reg) { + case S3_MISC_OUT: + map->access = VgaAccessIo; + if (write) + map->port = 0x3c2; + else + map->port = 0x3cc; + break; + case S3_INPUT_STATUS_1: + map->access = VgaAccessIo; + map->port = 0x3da; + break; + } + if (card->closure) + { + map->port = map->port + (VGA32) card->closure; + if (map->access == VgaAccessIo) + map->access = VgaAccessMem; + if (map->access == VgaAccessIndIo) + map->access = VgaAccessIndMem; + } +} + +VgaSave s3Saves[] = { + CR_FIRST, CR18, + CR31, CR_LAST, + SR_FIRST, SR15, + SR18, SR_LAST, + AR_FIRST, AR_LAST, + S3_MISC_OUT, S3_MISC_OUT, + VGA_SAVE_END +}; + +void +s3RegInit (S3Vga *s3vga, VGAVOL8 *mmio) +{ + s3vga->card.map = _s3RegMap; + s3vga->card.closure = (void *) mmio; + s3vga->card.max = S3_NREG; + s3vga->card.values = s3vga->values; + s3vga->card.saves = s3Saves; +} + +void +s3Save (S3Vga *s3vga) +{ + s3vga->save_lock_crtc = s3Get(s3vga, s3_lock_crtc); + s3SetImm (s3vga, s3_lock_crtc, 0); + s3vga->save_register_lock_1 = s3Get (s3vga, s3_register_lock_1); + s3SetImm (s3vga, s3_register_lock_1, 0x48); + s3vga->save_register_lock_2 = s3Get (s3vga, s3_register_lock_2); + s3SetImm (s3vga, s3_register_lock_2, 0xa5); + s3vga->save_unlock_extended_sequencer = s3Get (s3vga, s3_unlock_extended_sequencer); + s3SetImm (s3vga, s3_unlock_extended_sequencer, 0x06); + s3vga->save_lock_horz = s3Get (s3vga, s3_lock_horz); + s3SetImm (s3vga, s3_lock_horz, 0); + s3vga->save_lock_vert = s3Get (s3vga, s3_lock_vert); + s3SetImm (s3vga, s3_lock_vert, 0); + s3vga->save_dot_clock_8 = s3Get (s3vga, s3_dot_clock_8); + VgaPreserve (&s3vga->card); +} + +void +s3Reset (S3Vga *s3vga) +{ + VgaRestore (&s3vga->card); + s3SetImm (s3vga, s3_clock_load_imm, 1); + s3SetImm (s3vga, s3_clock_load_imm, 0); + s3SetImm (s3vga, s3_dot_clock_8, s3vga->save_dot_clock_8); + s3SetImm (s3vga, s3_lock_vert, s3vga->save_lock_vert); + s3SetImm (s3vga, s3_lock_horz, s3vga->save_lock_horz); + s3SetImm (s3vga, s3_lock_dac_writes, s3vga->save_lock_dac_writes); + s3SetImm (s3vga, s3_unlock_extended_sequencer, s3vga->save_unlock_extended_sequencer); + s3SetImm (s3vga, s3_register_lock_2, s3vga->save_register_lock_2); + s3SetImm (s3vga, s3_register_lock_1, s3vga->save_register_lock_1); + s3SetImm (s3vga, s3_lock_crtc, s3vga->save_lock_crtc); + VgaFinish (&s3vga->card); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3.nick +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3.nick @@ -0,0 +1,41 @@ +/* $RCSId: $ */ + +global f_ref = 14318000; + +function s3_clock (m, n, r) +{ + return f_ref * (m + 2) / ((n + 2) * (2 ^ r)); +} + +function s3_near (f1, f2) +{ + return abs (f1 - f2) < f1 / 10; +} + +function s3_clocks (f) +{ + auto m, n, r, ft; + auto dist, min_dist; + auto min_m, min_n, min_r; + + min_dist = f / 5; + for (r = 0; r <= 3; r++) + for (n = 0; n <= 31; n++) + for (m = 0; m <= 127; m++) + { + ft = s3_clock (m, n, r); + if (s3_near (ft, f)) + printf ("m %d n %d r %d = %d\n", + m, n, r, ft); + dist = abs (f - ft); + if (dist < min_dist) + { + min_dist = dist; + min_m = m; + min_n = n; + min_r = r; + } + } + printf ("m %d n %d r %d f %d dist %d\n", + min_m, min_n, min_r, s3_clock(min_m, min_n, min_r), min_dist); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3stub.c +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3stub.c @@ -0,0 +1,93 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "s3.h" + +void +InitCard (char *name) +{ + KdCardAttr attr; +#ifdef VXWORKS + attr.naddr = 2; + attr.io = 0; + attr.address[0] = 0xbc000000; /* registers */ + attr.address[1] = 0xba000000; /* frame buffer */ + KdCardInfoAdd (&s3Funcs, &attr, 0); +#else + CARD32 count; + + count = 0; + while (LinuxFindPci (0x5333, 0x8a22, count, &attr)) + { + KdCardInfoAdd (&s3Funcs, &attr, 0); + count++; + } +#endif +} + +void +InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) +{ + KdInitOutput (pScreenInfo, argc, argv); +} + +void +InitInput (int argc, char **argv) +{ + KdOsAddInputDrivers (); + KdInitInput (); +} + +extern int s3CpuTimeout; +extern int s3AccelTimeout; + +void +ddxUseMsg (void) +{ + ErrorF("\nSavage Driver Options:\n"); + ErrorF("-cpu Sets CPU timout\n"); + ErrorF("-accel Sets acceleration timout\n"); + + KdUseMsg(); +} + +int +ddxProcessArgument (int argc, char **argv, int i) +{ + int ret; + + if (!strcmp (argv[i], "-cpu")) + { + s3CpuTimeout = strtol(argv[i+1], NULL, 0); + return 2; + } + if (!strcmp (argv[i], "-accel")) + { + s3AccelTimeout = strtol (argv[i+1], NULL, 0); + return 2; + } + return KdProcessArgument (argc, argv, i); +} --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3draw.h +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3draw.h @@ -0,0 +1,468 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifndef _S3DRAW_H_ +#define _S3DRAW_H_ + +extern DevPrivateKey s3GCPrivateKey; +extern DevPrivateKey s3WindowPrivateKey; + +typedef struct _s3Pattern { + S3PatternCache *cache; + int id; + PixmapPtr pPixmap; + int fillStyle; + int xrot, yrot; + unsigned int fore, back; +} s3PatternRec, *s3PatternPtr; + +typedef struct _s3PrivGC { + int type; /* type of drawable validated against */ + int ma; /* stream descriptor */ + s3PatternPtr pPattern; /* pattern */ +} s3PrivGCRec, *s3PrivGCPtr; + +#define s3GetGCPrivate(g) ((s3PrivGCPtr) \ + dixLookupPrivate(&(g)->devPrivates, s3GCPrivateKey)) + +#define s3GCPrivate(g) s3PrivGCPtr s3Priv = s3GetGCPrivate(g) + +#define s3GetWindowPrivate(w) ((s3PatternPtr) \ + dixLookupPrivate(&(w)->devPrivates, s3WindowPrivateKey)) + +#define s3SetWindowPrivate(w,p) \ + dixSetPrivate(&(w)->devPrivates, s3WindowPrivateKey, p) + +void _s3LoadPattern (ScreenPtr pScreen, int fb, s3PatternPtr pPattern); + +#define SetupS3(s) KdScreenPriv(s); \ + s3CardInfo(pScreenPriv); \ + S3Ptr s3 = s3c->s3 + +#ifdef S3_SYNC_DEBUG +#define SYNC_DEBUG() fprintf (stderr, "Sync at %s:%d\n", __FILE__,__LINE__) +#else +#define SYNC_DEBUG() +#endif + +#define S3_ASYNC +#ifdef S3_ASYNC +#define CheckSyncS3(s) KdCheckSync(s) +#define MarkSyncS3(s) KdMarkSync(s) +#define RegisterSync(screen) KdScreenInitAsync (screen) +#else +#define CheckSyncS3(s3c) +#define MarkSyncS3(s3c) _s3WaitIdleEmpty(s3c->s3) +#define RegisterSync(screen) +#endif + +#define WIDEN(x) ((unsigned long) (x)) +#define MERGE(a,b) ((WIDEN(a) << 16) | WIDEN(b)) + +#define s3BitmapDescriptor(_stream) ((_stream) + 1) + +#ifdef S3_TRIO +#define s3DrawMap(pDraw) 0 +#define s3SetGlobalBitmap(s,d) +#else +#define s3DrawMap(pDraw) ((pDraw)->depth == \ + getS3ScreenInfo(pScreenPriv)->primary_depth ? 0 : 1) +#endif + +#define s3GCMap(pGC) (s3GetGCPrivate(pGC)->ma) + +/* + * Ok, so the S3 is broken -- it expects bitmaps to come MSB bit order, + * but it's willing to take them in LSB byte order. These macros + * flip bits around without flipping bytes. Instead of using a table + * and burning memory bandwidth, do them in place with the CPU. + */ + +/* The MIPS compiler automatically places these constants in registers */ +#define S3InvertBits32(v) { \ + v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ + v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ + v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ +} + +#define S3InvertBits16(v) { \ + v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \ + v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \ + v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \ +} + +#define S3InvertBits8(v) { \ + v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \ + v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \ + v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \ +} + +#define S3ByteSwap32(x) ((x) = (((x) >> 24) | \ + (((x) >> 8) & 0xff00) | \ + (((x) << 8) & 0xff0000) | \ + ((x) << 24))) + +#define S3ByteSwap16(x) ((x) = ((x) << 8) | ((x) >> 8)) + +#if BITMAP_BIT_ORDER == LSBFirst +#define S3AdjustBits32(x) S3InvertBits32(x) +#define S3AdjustBits16(x) S3InvertBits16(x) +#else +#define S3AdjustBits32(x) S3ByteSwap32(x) +#define S3AdjustBits16(x) S3ByteSwap16(x) +#endif + +#define _s3WaitSlot(s3) _s3WaitSlots(s3,1) + +#define _s3SetFg(s3,_fg) { \ + DRAW_DEBUG ((DEBUG_REGISTERS, " fg <- 0x%x", _fg));\ + s3->fg = (_fg); \ +} + +#define _s3SetBg(s3,_bg) { \ + DRAW_DEBUG ((DEBUG_REGISTERS, " bg <- 0x%x", _bg));\ + s3->bg = (_bg); \ +} + +#define _s3SetWriteMask(s3,_mask) {\ + DRAW_DEBUG((DEBUG_REGISTERS," write_mask <- 0x%x", _mask)); \ + s3->write_mask = (_mask); \ +} + +#define _s3SetReadMask(s3,_mask) {\ + DRAW_DEBUG((DEBUG_REGISTERS," read_mask <- 0x%x", _mask)); \ + s3->read_mask = (_mask); \ +} + +#define _s3SetPixelControl(s3,_ctl) { \ + DRAW_DEBUG((DEBUG_REGISTERS, " pix_cntl <- 0x%x", PIX_CNTL | (_ctl))); \ + s3->pix_cntl_mult_misc2 = MERGE (CONTROL_MISC2, PIX_CNTL | (_ctl)); \ +} + +#define _s3SetFgMix(s3,_mix) { \ + DRAW_DEBUG((DEBUG_REGISTERS, " fg_mix <- 0x%x", _mix)); \ + s3->enh_fg_mix = (_mix); \ +} + +#define _s3SetBgMix(s3,_mix) { \ + DRAW_DEBUG((DEBUG_REGISTERS, " bg_mix <- 0x%x", _mix)); \ + s3->enh_bg_mix = (_mix); \ +} + +#define _s3SetMix(s3,fg_mix,bg_mix) { \ + DRAW_DEBUG((DEBUG_REGISTERS, " alt_mix <- 0x%x", MERGE(fg_mix,bg_mix))); \ + s3->alt_mix = MERGE(fg_mix,bg_mix); \ +} + +#define _s3SetCur(s3,_x,_y) { \ + DRAW_DEBUG ((DEBUG_REGISTERS, " alt_curxy <- 0x%x", MERGE(_x,_y))); \ + s3->alt_curxy = MERGE(_x,_y); \ +} + +#define _s3SetStep(s3,_x,_y) { \ + DRAW_DEBUG ((DEBUG_REGISTERS, " alt_step <- 0x%x", MERGE(_x,_y))); \ + s3->alt_step = MERGE(_x,_y); \ +} + +#define _s3SetErr(s3,_e) { \ + DRAW_DEBUG ((DEBUG_REGISTERS, " err_term <- 0x%x", _e)); \ + s3->err_term = (_e); \ +} + +#define _s3SetPcnt(s3,_x,_y) { \ + DRAW_DEBUG ((DEBUG_REGISTERS, " alt_pcnt <- 0x%x", MERGE(_x,_y))); \ + s3->alt_pcnt = MERGE(_x,_y); \ +} + +#define _s3SetScissorsTl(s3,t,l) {\ + DRAW_DEBUG ((DEBUG_REGISTERS, " scissors_tl <- 0x%x", MERGE(t,l))); \ + s3->scissors_tl = MERGE(t,l); \ +} + +#define _s3SetScissorsBr(s3,b,r) {\ + DRAW_DEBUG ((DEBUG_REGISTERS, " scissors_br <- 0x%x", MERGE(b,r))); \ + s3->scissors_br = MERGE(b,r); \ +} + +#define _s3CmdWait(s3) + +#define _s3SetCmd(s3,_cmd) { \ + DRAW_DEBUG((DEBUG_REGISTERS, " cmd <- 0x%x", _cmd)); \ + _s3CmdWait(s3); \ + s3->cmd_gp_stat = (_cmd); \ + /* { CARD32 __junk__; __junk__ = s3->cmd_gp_stat; } */ \ +} + +#define _s3SetSolidFill(s3,pix,alu,mask) { \ + DRAW_DEBUG((DEBUG_SET,"set fill 0x%x %d 0x%x",pix,alu,mask)); \ + _s3WaitSlots(s3,4); \ + _s3SetFg (s3, pix); \ + _s3SetWriteMask(s3,mask); \ + _s3SetMix (s3, FSS_FRGDCOL | s3alu[alu], BSS_BKGDCOL | MIX_SRC); \ + _s3SetPixelControl (s3, MIXSEL_FRGDMIX); \ + DRAW_DEBUG((DEBUG_SET," done")); \ +} + +#define _s3SolidRect(s3,x,y,w,h) {\ + DRAW_DEBUG((DEBUG_RENDER,"solid rect %d,%d %dx%d",x,y,w,h)); \ + _s3WaitSlots(s3,3); \ + _s3SetCur(s3, x, y); \ + _s3SetPcnt (s3, (w)-1, (h)-1); \ + _s3SetCmd (s3, CMD_RECT|INC_X|INC_Y|DRAW|WRTDATA); \ + DRAW_DEBUG((DEBUG_RENDER," done")); \ +} + +#define _s3SolidLine(s3,maj,min,len,cmd) { \ + DRAW_DEBUG ((DEBUG_RENDER, "solid line 0x%x 0x%x 0x%x", maj, min, cmd)); \ + _s3WaitSlots(s3,4); \ + _s3SetPcnt(s3, (len), 0); \ + _s3SetStep(s3, 2*((min) - (maj)), 2*(min)); \ + _s3SetErr(s3, 2*(min) - (maj)); \ + _s3SetCmd (s3, CMD_LINE | (cmd) | DRAW | WRTDATA); \ +} + +#define _s3ClipLine(s3,cmd,e1,e2,e,len) {\ + DRAW_DEBUG ((DEBUG_RENDER, "clip line 0x%x 0x%x 0x%x 0x%x 0x%x", cmd,e1,e2,e,len)); \ + _s3WaitSlots(s3, 4); \ + _s3SetPcnt (s3, (len), 0); \ + _s3SetStep (s3, e2, e1); \ + _s3SetErr (s3, e); \ + _s3SetCmd (s3, CMD_LINE | (cmd) | DRAW | WRTDATA); \ +} + +#define _s3SetTile(s3,alu,mask) { \ + DRAW_DEBUG ((DEBUG_SET,"set tile %d 0x%x", alu, mask)); \ + _s3WaitSlots(s3,3); \ + _s3SetWriteMask(s3, mask); \ + _s3SetMix(s3, FSS_BITBLT | s3alu[alu], BSS_BITBLT|s3alu[alu]); \ + _s3SetPixelControl (s3, MIXSEL_FRGDMIX); \ + DRAW_DEBUG((DEBUG_SET," done")); \ +} + +/* + * For some reason, MIX_DST doesn't work in this mode; use MIX_OR with + * an explicit 0 pixel value + */ +#define _s3SetStipple(s3,alu,mask,_fg) {\ + DRAW_DEBUG ((DEBUG_SET,"set stipple 0x%x %d 0x%x", _fg, alu, mask)); \ + _s3WaitSlots(s3,5); \ + _s3SetFg (s3, _fg); \ + _s3SetBg (s3, 0); \ + _s3SetWriteMask(s3,mask); \ + _s3SetMix (s3, FSS_FRGDCOL | s3alu[alu], BSS_BKGDCOL|MIX_OR); \ + _s3SetPixelControl (s3, MIXSEL_EXPBLT); \ + DRAW_DEBUG((DEBUG_SET," done")); \ +} + +#define _s3SetOpaqueStipple(s3,alu,mask,_fg,_bg) {\ + DRAW_DEBUG ((DEBUG_SET,"set opaque stipple 0x%x 0x%x %d 0x%x", _fg, _bg, alu, mask)); \ + _s3WaitSlots(s3,5); \ + _s3SetFg (s3, _fg); \ + _s3SetBg (s3, _bg); \ + _s3SetWriteMask(s3,mask); \ + _s3SetMix (s3, FSS_FRGDCOL | s3alu[alu], BSS_BKGDCOL|s3alu[alu]); \ + _s3SetPixelControl (s3, MIXSEL_EXPBLT); \ + DRAW_DEBUG((DEBUG_SET," done")); \ +} + +#define _s3PatRect(s3,px,py,x,y,w,h) {\ + DRAW_DEBUG ((DEBUG_RENDER, "pat rect %d,%d %dx%d", x,y,w,h)); \ + _s3WaitSlots(s3, 4); \ + _s3SetCur (s3, px, py); \ + _s3SetStep (s3, x, y); \ + _s3SetPcnt (s3, (w)-1, (h)-1); \ + _s3SetCmd (s3, CMD_PATBLT|INC_X|INC_Y|DRAW|PLANAR|WRTDATA); \ + DRAW_DEBUG((DEBUG_RENDER," done")); \ +} + +#define _s3SetBlt(s3,alu,mask) { \ + DRAW_DEBUG ((DEBUG_SET,"set blt %d 0x%x", alu, mask)); \ + _s3WaitSlots(s3,3); \ + _s3SetPixelControl (s3, MIXSEL_FRGDMIX); \ + _s3SetMix(s3, FSS_BITBLT | s3alu[alu], BSS_BITBLT | s3alu[alu]); \ + _s3SetWriteMask(s3, mask); \ + DRAW_DEBUG((DEBUG_SET," done")); \ +} + +#define _s3Blt(s3,_sx,_sy,_dx,_dy,_w,_h,_dir) { \ + DRAW_DEBUG ((DEBUG_RENDER, "blt %d,%d -> %d,%d %dx%d 0x%x", \ + _sx,_sy,_dx,_dy,_w,_h,_dir)); \ + _s3WaitSlots(s3,4); \ + _s3SetCur(s3,_sx,_sy); \ + _s3SetStep(s3,_dx,_dy); \ + _s3SetPcnt(s3,(_w)-1,(_h)-1); \ + _s3SetCmd (s3, CMD_BITBLT | (_dir) | DRAW | WRTDATA); \ + DRAW_DEBUG((DEBUG_RENDER," done")); \ +} + +#define _s3SetOpaquePlaneBlt(s3,alu,mask,_fg,_bg) {\ + DRAW_DEBUG ((DEBUG_SET,"set opaque plane blt 0x%x 0x%x %d 0x%x", \ + _fg, _bg, alu, mask)); \ + /* _s3WaitSlots(s3, 5); */ \ + _s3WaitIdleEmpty (s3); \ + _s3SetFg(s3,_fg); \ + _s3SetBg(s3,_bg); \ + _s3SetWriteMask(s3,mask); \ + _s3SetMix(s3,FSS_FRGDCOL|s3alu[alu], BSS_BKGDCOL|s3alu[alu]); \ + _s3SetPixelControl(s3,MIXSEL_EXPPC); \ + DRAW_DEBUG((DEBUG_SET," done")); \ +} + +#define _s3SetTransparentPlaneBlt(s3,alu,mask,_fg) {\ + DRAW_DEBUG ((DEBUG_SET,"set transparent plane blt 0x%x %d 0x%x", \ + _fg, alu, mask)); \ + /*_s3WaitSlots(s3, 4); */ \ + _s3WaitIdleEmpty (s3); \ + _s3SetFg(s3,_fg); \ + _s3SetWriteMask(s3,mask); \ + _s3SetMix(s3,FSS_FRGDCOL|s3alu[alu], BSS_BKGDCOL|MIX_DST); \ + _s3SetPixelControl(s3,MIXSEL_EXPPC); \ + DRAW_DEBUG((DEBUG_SET," done")); \ +} + +/* Across the plane blt */ +#define _s3PlaneBlt(s3,x,y,w,h) {\ + DRAW_DEBUG ((DEBUG_RENDER, "plane blt %d,%d %dx%d", x,y,w,h)); \ + _s3WaitSlots(s3, 4); \ + _s3SetPixelControl(s3,MIXSEL_EXPPC); \ + _s3SetCur(s3, x, y); \ + _s3SetPcnt (s3, (w)-1, (h)-1); \ + _s3SetCmd (s3, \ + CMD_RECT| /* Fill rectangle */ \ + BYTSEQ| /* LSB byte order */ \ + _32BIT| /* 32 bit data on 32 bit boundaries */ \ + PCDATA| /* Data from CPU */ \ + INC_X|INC_Y| /* X and Y both increasing */ \ + DRAW| /* Draw, not move */ \ + PLANAR| /* multi pixel */ \ + WRTDATA); \ + DRAW_DEBUG((DEBUG_RENDER," done")); \ +} + +#define _s3SetClip(s3,pbox) {\ + DRAW_DEBUG ((DEBUG_SET, "set clip %dx%d -> %dx%d ", \ + pbox->x1, pbox->y1, pbox->x2, pbox->y2)); \ + _s3WaitSlots(s3, 2); \ + _s3SetScissorsTl(s3,(pbox)->x1, (pbox)->y1); \ + _s3SetScissorsBr(s3,(pbox)->x2 - 1, (pbox)->y2 - 1); \ + DRAW_DEBUG((DEBUG_SET," done")); \ +} + +#define _s3ResetClip(s3,pScreen) { \ + DRAW_DEBUG ((DEBUG_SET, "reset clip")); \ + _s3WaitSlots(s3, 2); \ + _s3SetScissorsTl(s3,0,0); \ + _s3SetScissorsBr(s3,pScreen->width - 1, pScreen->height - 1); \ + DRAW_DEBUG((DEBUG_SET," done")); \ +} + +RegionPtr +s3CopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, + int srcx, int srcy, int width, int height, int dstx, int dsty); + +RegionPtr +s3CopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, + int srcx, int srcy, int width, int height, + int dstx, int dsty, unsigned long bitPlane); + +void +s3PushPixels (GCPtr pGC, PixmapPtr pBitmap, + DrawablePtr pDrawable, + int w, int h, int x, int y); + +void +s3FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, + unsigned long pixel, int alu, unsigned long planemask); + +void +s3FillBoxPattern (DrawablePtr pDrawable, int nBox, BoxPtr pBox, + int alu, unsigned long planemask, s3PatternPtr pPattern); + +void +s3PolyFillRect (DrawablePtr pDrawable, GCPtr pGC, + int nrectFill, xRectangle *prectInit); + +void +s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n, + DDXPointPtr ppt, int *pwidth, int fSorted); + +void +s3PolyFillArcSolid (DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs); + +void +s3FillPoly (DrawablePtr pDrawable, GCPtr pGC, int shape, + int mode, int count, DDXPointPtr ptsIn); + +void +s3PolyGlyphBlt (DrawablePtr pDrawable, + GCPtr pGC, + int xInit, int y, + unsigned int nglyphInit, + CharInfoPtr *ppciInit, + pointer pglyphBase); + +void +s3ImageGlyphBlt (DrawablePtr pDrawable, + GCPtr pGC, + int x, int y, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase); + +void +s3ImageTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, + int xInit, int y, + unsigned int nglyphInit, + CharInfoPtr *ppciInit, + pointer pglyphBase); + +void +s3PolyTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, + int x, int y, + unsigned int nglyph, CharInfoPtr *ppci, + pointer pglyphBase); + +void +s3Polylines (DrawablePtr pDrawable, GCPtr pGC, + int mode, int nptInit, DDXPointPtr pptInit); + +void +s3PolySegment (DrawablePtr pDrawable, GCPtr pGC, + int nsegInit, xSegment *pSegInit); + +void +s3FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, + unsigned long pixel, int alu, unsigned long planemask); + +void s3ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable); + +void +s3CheckGCFill (GCPtr pGC); + +void +s3MoveGCFill (GCPtr pGC); + +void +s3SyncProc (DrawablePtr pDrawable); + +#endif --- xorg-server-1.4.99.906.orig/hw/kdrive/savage/s3.c +++ xorg-server-1.4.99.906/hw/kdrive/savage/s3.c @@ -0,0 +1,1835 @@ +/* + * Copyright 1999 SuSE, Inc. + * + * 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 SuSE not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. SuSE makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE + * 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. + * + * Author: Keith Packard, SuSE, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "s3.h" + +#define REGISTERS_OFFSET (0x1000000) +#define PACKED_OFFSET (0x8100) +#define IOMAP_OFFSET (0x8000) + +#define S3_MIN_CLOCK 250000 + +static void +_s3SetBlank (S3Ptr s3, S3Vga *s3vga, Bool blank) +{ + CARD8 clock_mode; + + s3SetImm(s3vga, s3_screen_off, blank ? 1 : 0); +} + +Bool +s3CardInit (KdCardInfo *card) +{ + S3CardInfo *s3c; + S3Ptr s3; + S3Vga *s3vga; + int size; + CARD8 *registers; + CARD32 s3FrameBuffer; + CARD32 s3Registers; + CARD8 *temp_buffer; + CARD32 max_memory; + VGA32 save_linear_window_size; + VGA32 save_enable_linear; + VGA32 save_register_lock_2; + VGA32 save_misc_output; + + s3c = (S3CardInfo *) xalloc (sizeof (S3CardInfo)); + if (!s3c) + { + goto bail0; + } + + memset (s3c, '\0', sizeof (S3CardInfo)); + + card->driver = s3c; + +#ifdef VXWORKS + s3c->bios_initialized = 0; +#else + s3c->bios_initialized = 1; +#endif + + if (card->attr.naddr > 1 && card->attr.address[1]) + { + s3FrameBuffer = card->attr.address[1]; + s3Registers = card->attr.address[0]; + max_memory = 32 * 1024 * 1024; + } + else + { + s3FrameBuffer = card->attr.address[0]; + s3Registers = s3FrameBuffer + REGISTERS_OFFSET; + max_memory = 16 * 1024 * 1024; + } + +#ifdef DEBUG + fprintf (stderr, "S3 at 0x%x/0x%x\n", s3Registers, s3FrameBuffer); +#endif + registers = KdMapDevice (s3Registers, + sizeof (S3) + PACKED_OFFSET); + if (!registers) + { + ErrorF ("Can't map s3 device\n"); + goto bail2; + } + s3 = (S3Ptr) (registers + PACKED_OFFSET); + s3c->registers = registers; + s3c->s3 = s3; + + s3vga = &s3c->s3vga; + s3RegInit (s3vga, (VGAVOL8 *) (registers + IOMAP_OFFSET)); + + if (!s3c->bios_initialized) + { + volatile CARD32 *wakeup; + + wakeup = (volatile CARD32 *) (registers + 0x8510); + ErrorF ("Wakeup S3 chip at 0x%x\n", wakeup); + ErrorF ("Wakeup was 0x%x\n", *wakeup); + /* wakeup the chip */ + *(volatile CARD32 *) (registers + 0x8510) = 1; + ErrorF ("Wakeup is 0x%x\n", *wakeup); + } + s3Set (s3vga, s3_io_addr_select, 1); + s3Set (s3vga, s3_enable_ram, 1); + VgaFlush (&s3vga->card); + + save_register_lock_2 = s3Get (s3vga, s3_register_lock_2); + s3SetImm (s3vga, s3_register_lock_2, 0xa0); + save_linear_window_size = s3Get (s3vga, s3_linear_window_size); + save_enable_linear = s3Get (s3vga, s3_enable_linear); + s3Set (s3vga, s3_linear_window_size, 3); + s3Set (s3vga, s3_enable_linear, 1); + VgaFlush (&s3vga->card); + VgaFinish (&s3vga->card); + + /* + * Can't trust S3 register value for frame buffer amount, must compute + */ + temp_buffer = KdMapDevice (s3FrameBuffer, max_memory); + + s3c->memory = KdFrameBufferSize (temp_buffer, max_memory); + + s3Set (s3vga, s3_linear_window_size, save_linear_window_size); + s3Set (s3vga, s3_enable_linear, save_enable_linear); + VgaFlush (&s3vga->card); + s3SetImm (s3vga, s3_register_lock_2, save_register_lock_2); + VgaFinish (&s3vga->card); +#ifdef DEBUG + fprintf (stderr, "Frame buffer 0x%x\n", s3c->memory); +#endif + KdUnmapDevice (temp_buffer, max_memory); + + if (!s3c->memory) + { + ErrorF ("Can't detect s3 frame buffer at 0x%x\n", s3FrameBuffer); + goto bail3; + } + + s3c->frameBuffer = KdMapDevice (s3FrameBuffer, s3c->memory); + if (!s3c->frameBuffer) + { + ErrorF ("Can't map s3 frame buffer\n"); + goto bail3; + } + + card->driver = s3c; + + return TRUE; +bail3: + KdUnmapDevice ((void *) s3, sizeof (S3)); +bail2: +bail1: + xfree (s3c); +bail0: + return FALSE; +} + +Bool +s3ModeSupported (KdScreenInfo *screen, + const KdMonitorTiming *t) +{ + if (screen->fb[1].depth) + { + /* + * Must have at least one true color stream + */ + if (screen->fb[0].depth <= 8 && + screen->fb[1].depth <= 8) + return FALSE; + } + /* make sure the clock isn't too fast */ + if (t->clock > S3_MAX_CLOCK * 2) + return FALSE; + /* width must be a multiple of 16 */ + if (t->horizontal & 0xf) + return FALSE; + return TRUE; +} + +Bool +s3ModeUsable (KdScreenInfo *screen) +{ + KdCardInfo *card = screen->card; + S3CardInfo *s3c = (S3CardInfo *) card->driver; + int screen_size; + int pixel_width; + int byte_width; + int fb; + + screen_size = 0; + for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++) + { + if (screen->fb[fb].depth >= 24) + { + screen->fb[fb].depth = 24; + if (screen->fb[fb].bitsPerPixel != 24) + screen->fb[fb].bitsPerPixel = 32; + } + else if (screen->fb[fb].depth >= 16) + { + screen->fb[fb].depth = 16; + screen->fb[fb].bitsPerPixel = 16; + } + else if (screen->fb[fb].depth >= 15) + { + screen->fb[fb].depth = 15; + screen->fb[fb].bitsPerPixel = 16; + } + else + { + screen->fb[fb].depth = 8; + screen->fb[fb].bitsPerPixel = 8; + } + + /* + * SGRAM requires stride % 64 == 0 + */ + screen->fb[fb].pixelStride = (screen->width + 63) & ~63; + screen->fb[fb].byteStride = screen->fb[fb].pixelStride * (screen->fb[fb].bitsPerPixel >> 3); + screen_size += screen->fb[fb].byteStride * screen->height; + } + + return screen_size <= s3c->memory; +} + +Bool +s3ScreenInit (KdScreenInfo *screen) +{ + KdCardInfo *card = screen->card; + S3CardInfo *s3c = (S3CardInfo *) card->driver; + S3ScreenInfo *s3s; + int memory; + int requested_memory; + int v_total, h_total; + int m, n, r; + int i; + const KdMonitorTiming *t; + int screen_size; + int fb; + int ma; + + s3s = (S3ScreenInfo *) xalloc (sizeof (S3ScreenInfo)); + if (!s3s) + return FALSE; + + memset (s3s, '\0', sizeof (S3ScreenInfo)); + +#ifdef PHOENIX + screen->width = 1152; + screen->height = 900; + screen->rate = 85; + screen->depth = 32; +#endif + if (!screen->width || !screen->height) + { + screen->width = 800; + screen->height = 600; + screen->rate = 72; + } + if (!screen->fb[0].depth) + screen->fb[0].depth = 8; + + t = KdFindMode (screen, s3ModeSupported); + screen->rate = t->rate; + screen->width = t->horizontal; + screen->height = t->vertical; + s3GetClock (t->clock, &m, &n, &r, 511, 127, 4, 250000); +#ifdef DEBUG + fprintf (stderr, "computed %d,%d,%d (%d)\n", + m, n, r, S3_CLOCK(m,n,r)); +#endif +#if 0 + /* + * Can only operate in pixel-doubled mode at 8 or 16 bits per pixel + */ + if (screen->depth > 16 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK) + screen->depth = 16; +#endif + + if (!KdTuneMode (screen, s3ModeUsable, s3ModeSupported)) + { + xfree (s3s); + return FALSE; + } + + s3s->fbmap[2] = -1; + if (screen->fb[1].depth) + { + if (screen->fb[0].bitsPerPixel >= 16) + { + s3s->fbmap[0] = 1; + s3s->fbmap[1] = 0; + } + else + { + s3s->fbmap[0] = 0; + s3s->fbmap[1] = 1; + } + } + else + { + s3s->fbmap[0] = 0; + s3s->fbmap[1] = -1; + } + + screen_size = 0; + for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++) + screen_size += screen->fb[fb].byteStride * screen->height; + + memory = s3c->memory - screen_size; + + /* + * Stick cursor at end of memory + */ + if (memory >= 2048) + { + s3s->cursor_base = s3c->frameBuffer + (s3c->memory - 2048); + memory -= 2048; + } + else + s3s->cursor_base = 0; + + screen_size = 0; + for (ma = 0; s3s->fbmap[ma] >= 0; ma++) + { + fb = s3s->fbmap[ma]; + screen->fb[fb].frameBuffer = s3c->frameBuffer + screen_size; + screen_size += screen->fb[fb].byteStride * screen->height; + + REGION_INIT(pScreen, (&s3s->region[fb]), NullBox, 0); + if (screen->fb[fb].bitsPerPixel == 8) + s3s->fb[ma].chroma_key = 0xff; + else + s3s->fb[ma].chroma_key = 0; + + /* + * Use remaining memory for off-screen storage, but only use + * one piece (either right or bottom). + */ + if (memory >= screen->fb[fb].byteStride * S3_TILE_SIZE) + { + s3s->fb[ma].offscreen = screen->fb[fb].frameBuffer; + s3s->fb[ma].offscreen_x = 0; + s3s->fb[ma].offscreen_y = screen->height; + s3s->fb[ma].offscreen_width = screen->fb[fb].pixelStride; + s3s->fb[ma].offscreen_height = S3_TILE_SIZE; + memory -= s3s->fb[ma].offscreen_height * screen->fb[fb].byteStride; + screen_size += s3s->fb[ma].offscreen_height * screen->fb[fb].byteStride; + } + else + s3s->fb[ma].offscreen = 0; + + switch (screen->fb[fb].depth) { + case 8: + screen->fb[fb].visuals = ((1 << StaticGray) | + (1 << GrayScale) | + (1 << StaticColor) | + (1 << PseudoColor) | + (1 << TrueColor) | + (1 << DirectColor)); + screen->fb[fb].blueMask = 0x00; + screen->fb[fb].greenMask = 0x00; + screen->fb[fb].redMask = 0x00; + break; + case 15: + screen->fb[fb].visuals = (1 << TrueColor); + screen->fb[fb].blueMask = 0x001f; + screen->fb[fb].greenMask = 0x03e0; + screen->fb[fb].redMask = 0x7c00; + break; + case 16: + screen->fb[fb].visuals = (1 << TrueColor); + screen->fb[fb].blueMask = 0x001f; + screen->fb[fb].greenMask = 0x07e0; + screen->fb[fb].redMask = 0xf800; + break; + case 24: + screen->fb[fb].visuals = (1 << TrueColor); + screen->fb[fb].blueMask = 0x0000ff; + screen->fb[fb].greenMask = 0x00ff00; + screen->fb[fb].redMask = 0xff0000; + break; + } + } + + screen->driver = s3s; + + return TRUE; +} + +typedef struct _biosInit { + VGA16 reg; + VGA8 value; +} s3BiosInit; + +s3BiosInit s3BiosReg[] = { + S3_SR +0x15, 0x23, + S3_MISC_OUT, 0x2f, + 0xffff, 1, + S3_SR +0x15, 0x03, + + S3_SR + 0x0, 0x03, + S3_SR + 0x1, 0x00, + S3_SR + 0x2, 0x03, + S3_SR + 0x3, 0x00, + S3_SR + 0x4, 0x02, + S3_SR + 0x5, 0x05, + S3_SR + 0x6, 0x06, + S3_SR + 0x7, 0x07, +/* S3_SR + 0x8, 0x06, */ + S3_SR + 0x9, 0x00, + S3_SR + 0xa, 0x0a, + S3_SR + 0xb, 0x00, + S3_SR + 0xc, 0x0c, + S3_SR + 0xd, 0x00, + S3_SR + 0xe, 0x0e, + S3_SR + 0xf, 0x0f, + +/* S3_SR +0x10, 0x00, */ +/* S3_SR +0x11, 0x0c, */ + S3_SR +0x12, 0x01, + S3_SR +0x13, 0x52, + S3_SR +0x14, 0x00, + +/* S3_SR +0x15, 0x03, */ + + S3_SR +0x16, 0xc5, + S3_SR +0x17, 0xfc, + S3_SR +0x18, 0x40, + S3_SR +0x19, 0x00, + S3_SR +0x1a, 0x01, + S3_SR +0x1b, 0x02, + S3_SR +0x1c, 0x5d, + S3_SR +0x1d, 0x00, + S3_SR +0x1e, 0x00, + S3_SR +0x1f, 0x00, + S3_SR +0x20, 0x20, + S3_SR +0x21, 0x21, + S3_SR +0x22, 0x22, + S3_SR +0x23, 0x23, + S3_SR +0x24, 0x24, + S3_SR +0x25, 0x25, + S3_SR +0x26, 0x26, + S3_SR +0x27, 0x04, + S3_SR +0x28, 0xff, + S3_SR +0x29, 0x00, + S3_SR +0x2a, 0x2a, + S3_SR +0x2b, 0x2b, + S3_SR +0x2c, 0x2c, + S3_SR +0x2d, 0x2d, + S3_SR +0x2e, 0x2e, + S3_SR +0x2f, 0x2f, + S3_SR +0x30, 0x00, + S3_SR +0x31, 0x06, + S3_SR +0x32, 0x41, + S3_SR +0x33, 0x67, + S3_SR +0x34, 0x00, + S3_SR +0x35, 0x00, + S3_SR +0x36, 0x01, + S3_SR +0x37, 0x52, + S3_SR +0x38, 0x5d, + S3_SR +0x39, 0x05, + S3_SR +0x3a, 0x3a, + S3_SR +0x3b, 0x3b, + S3_SR +0x3c, 0x3c, + S3_SR +0x3d, 0x00, + S3_SR +0x3e, 0x3e, + S3_SR +0x3f, 0x00, + S3_SR +0x40, 0x40, + S3_SR +0x41, 0x41, + S3_SR +0x42, 0x42, + S3_SR +0x43, 0x43, + S3_SR +0x44, 0x44, + S3_SR +0x45, 0x45, + S3_SR +0x46, 0x46, + S3_SR +0x47, 0x47, + S3_SR +0x48, 0x48, + S3_SR +0x49, 0x49, + S3_SR +0x4a, 0x4a, + S3_SR +0x4b, 0x4b, + S3_SR +0x4c, 0x4c, + S3_SR +0x4d, 0x4d, + S3_SR +0x4e, 0x4e, + S3_SR +0x4f, 0x4f, + S3_SR +0x50, 0x00, + S3_SR +0x51, 0x00, + S3_SR +0x52, 0x00, + S3_SR +0x53, 0x00, + S3_SR +0x54, 0x00, + S3_SR +0x55, 0x00, + S3_SR +0x56, 0x00, + S3_SR +0x57, 0x00, + S3_SR +0x58, 0x00, + S3_SR +0x59, 0x70, + S3_SR +0x5a, 0x38, + S3_SR +0x5b, 0x08, + S3_SR +0x5c, 0x77, + S3_SR +0x5d, 0x77, + S3_SR +0x5e, 0x00, + S3_SR +0x5f, 0x00, + S3_SR +0x60, 0xff, + S3_SR +0x61, 0xbf, + S3_SR +0x62, 0xff, + S3_SR +0x63, 0xff, + S3_SR +0x64, 0xf7, + S3_SR +0x65, 0xff, + S3_SR +0x66, 0xff, + S3_SR +0x67, 0xff, + S3_SR +0x68, 0xff, + S3_SR +0x69, 0xff, + S3_SR +0x6a, 0xff, + S3_SR +0x6b, 0xff, + S3_SR +0x6c, 0xff, + S3_SR +0x6d, 0xff, + S3_SR +0x6e, 0x9b, + S3_SR +0x6f, 0xbf, + + S3_AR + 0x00, 0x00, + S3_AR + 0x01, 0x01, + S3_AR + 0x02, 0x02, + S3_AR + 0x03, 0x03, + S3_AR + 0x04, 0x04, + S3_AR + 0x05, 0x05, + S3_AR + 0x06, 0x06, + S3_AR + 0x07, 0x07, + S3_AR + 0x08, 0x08, + S3_AR + 0x09, 0x09, + S3_AR + 0x0a, 0x0a, + S3_AR + 0x0b, 0x0b, + S3_AR + 0x0c, 0x0c, + S3_AR + 0x0d, 0x0d, + S3_AR + 0x0e, 0x0e, + S3_AR + 0x0f, 0x0f, + S3_AR + 0x10, 0x05, + S3_AR + 0x11, 0x00, + S3_AR + 0x12, 0x0f, + S3_AR + 0x13, 0x08, + S3_AR + 0x14, 0x00, + + S3_GR + 0x00, 0x00, + S3_GR + 0x01, 0x00, + S3_GR + 0x02, 0x00, + S3_GR + 0x03, 0x00, + S3_GR + 0x04, 0x00, + S3_GR + 0x05, 0x10, + S3_GR + 0x06, 0x0e, + S3_GR + 0x07, 0x00, + + S3_CR + 0x00, 0x5f, + S3_CR + 0x01, 0x4f, + S3_CR + 0x02, 0x50, + S3_CR + 0x03, 0x82, + S3_CR + 0x04, 0x55, + S3_CR + 0x05, 0x81, + S3_CR + 0x06, 0xbf, + S3_CR + 0x07, 0x1f, + S3_CR + 0x08, 0x00, + S3_CR + 0x09, 0x4f, + S3_CR + 0x0a, 0x0d, + S3_CR + 0x0b, 0x0e, + S3_CR + 0x0c, 0x00, + S3_CR + 0x0d, 0x00, + S3_CR + 0x0e, 0x3f, + S3_CR + 0x0f, 0xff, + S3_CR + 0x10, 0x9c, + S3_CR + 0x11, 0x0e, + S3_CR + 0x12, 0x8f, + S3_CR + 0x13, 0x28, + S3_CR + 0x14, 0x1f, + S3_CR + 0x15, 0x96, + S3_CR + 0x16, 0xb9, + S3_CR + 0x17, 0xa3, + S3_CR + 0x18, 0xff, + S3_CR + 0x19, 0xdf, + S3_CR + 0x1a, 0xdf, + S3_CR + 0x1b, 0xdf, + S3_CR + 0x1c, 0xdf, + S3_CR + 0x1d, 0xdf, + S3_CR + 0x1e, 0xdf, + S3_CR + 0x1f, 0xdf, + S3_CR + 0x20, 0xdf, + S3_CR + 0x21, 0x00, +/* S3_CR + 0x22, 0x07, */ + S3_CR + 0x23, 0x00, + S3_CR + 0x24, 0xdf, + S3_CR + 0x25, 0xdf, + S3_CR + 0x26, 0x00, + S3_CR + 0x27, 0xdf, + S3_CR + 0x28, 0xdf, + S3_CR + 0x29, 0xdf, + S3_CR + 0x2a, 0xdf, + S3_CR + 0x2b, 0xdf, + S3_CR + 0x2c, 0xdf, + S3_CR + 0x2d, 0x8a, + S3_CR + 0x2e, 0x22, + S3_CR + 0x2f, 0x02, + S3_CR + 0x30, 0xe1, + S3_CR + 0x31, 0x05, + S3_CR + 0x32, 0x40, + S3_CR + 0x33, 0x08, + S3_CR + 0x34, 0x00, + S3_CR + 0x35, 0x00, + S3_CR + 0x36, 0xbf, + S3_CR + 0x37, 0x9b, +/* S3_CR + 0x38, 0x7b, */ +/* S3_CR + 0x39, 0xb8, */ + S3_CR + 0x3a, 0x45, + S3_CR + 0x3b, 0x5a, + S3_CR + 0x3c, 0x10, + S3_CR + 0x3d, 0x00, + S3_CR + 0x3e, 0xfd, + S3_CR + 0x3f, 0x00, + S3_CR + 0x40, 0x00, + S3_CR + 0x41, 0x92, + S3_CR + 0x42, 0xc0, + S3_CR + 0x43, 0x68, + S3_CR + 0x44, 0xff, + S3_CR + 0x45, 0xe8, + S3_CR + 0x46, 0xff, + S3_CR + 0x47, 0xff, + S3_CR + 0x48, 0xf8, + S3_CR + 0x49, 0xff, + S3_CR + 0x4a, 0xfe, + S3_CR + 0x4b, 0xff, + S3_CR + 0x4c, 0xff, + S3_CR + 0x4d, 0xff, + S3_CR + 0x4e, 0xff, + S3_CR + 0x4f, 0xff, + S3_CR + 0x50, 0x00, + S3_CR + 0x51, 0x00, + S3_CR + 0x52, 0x00, + S3_CR + 0x53, 0x00, + S3_CR + 0x54, 0x00, + S3_CR + 0x55, 0x00, + S3_CR + 0x56, 0x00, + S3_CR + 0x57, 0x00, +#if 0 + S3_CR + 0x58, 0x00, + S3_CR + 0x59, 0xf0, +#endif + S3_CR + 0x5a, 0x00, + S3_CR + 0x5b, 0x00, +#if 0 + S3_CR + 0x5c, 0x00, +#endif + S3_CR + 0x5d, 0x00, + S3_CR + 0x5e, 0x00, + S3_CR + 0x5f, 0x00, + S3_CR + 0x60, 0x09, + S3_CR + 0x61, 0x9d, + S3_CR + 0x62, 0xff, + S3_CR + 0x63, 0x00, + S3_CR + 0x64, 0xfd, + S3_CR + 0x65, 0x04, + S3_CR + 0x66, 0x88, + S3_CR + 0x67, 0x00, + S3_CR + 0x68, 0x7f, + S3_CR + 0x69, 0x00, + S3_CR + 0x6a, 0x00, + S3_CR + 0x6b, 0x00, + S3_CR + 0x6c, 0x00, + S3_CR + 0x6d, 0x11, + S3_CR + 0x6e, 0xff, + S3_CR + 0x6f, 0xfe, + + S3_CR + 0x70, 0x30, + S3_CR + 0x71, 0xc0, + S3_CR + 0x72, 0x07, + S3_CR + 0x73, 0x1f, + S3_CR + 0x74, 0x1f, + S3_CR + 0x75, 0x1f, + S3_CR + 0x76, 0x0f, + S3_CR + 0x77, 0x1f, + S3_CR + 0x78, 0x01, + S3_CR + 0x79, 0x01, + S3_CR + 0x7a, 0x1f, + S3_CR + 0x7b, 0x1f, + S3_CR + 0x7c, 0x17, + S3_CR + 0x7d, 0x17, + S3_CR + 0x7e, 0x17, + S3_CR + 0x7f, 0xfd, + S3_CR + 0x80, 0x00, + S3_CR + 0x81, 0x92, + S3_CR + 0x82, 0x10, + S3_CR + 0x83, 0x07, + S3_CR + 0x84, 0x42, + S3_CR + 0x85, 0x00, + S3_CR + 0x86, 0x00, + S3_CR + 0x87, 0x00, + S3_CR + 0x88, 0x10, + S3_CR + 0x89, 0xfd, + S3_CR + 0x8a, 0xfd, + S3_CR + 0x8b, 0xfd, + S3_CR + 0x8c, 0xfd, + S3_CR + 0x8d, 0xfd, + S3_CR + 0x8e, 0xfd, + S3_CR + 0x8f, 0xfd, + S3_CR + 0x90, 0x00, + S3_CR + 0x91, 0x4f, + S3_CR + 0x92, 0x10, + S3_CR + 0x93, 0x00, + S3_CR + 0x94, 0xfd, + S3_CR + 0x95, 0xfd, + S3_CR + 0x96, 0xfd, + S3_CR + 0x97, 0xfd, + S3_CR + 0x98, 0xfd, + S3_CR + 0x99, 0xff, + S3_CR + 0x9a, 0xfd, + S3_CR + 0x9b, 0xff, + S3_CR + 0x9c, 0xfd, + S3_CR + 0x9d, 0xfd, + S3_CR + 0x9e, 0xfd, + S3_CR + 0x9f, 0xff, + S3_CR + 0xa0, 0x0f, +#if 0 + S3_CR + 0xa1, 0x00, + S3_CR + 0xa2, 0x00, + S3_CR + 0xa3, 0x00, + S3_CR + 0xa4, 0x55, +#endif + S3_CR + 0xa5, 0x09, + S3_CR + 0xa6, 0x20, +#if 0 + S3_CR + 0xa7, 0x00, + S3_CR + 0xa8, 0x00, + S3_CR + 0xa9, 0x00, + S3_CR + 0xaa, 0x00, + S3_CR + 0xab, 0x00, + S3_CR + 0xac, 0x00, + S3_CR + 0xad, 0x00, + S3_CR + 0xae, 0x00, + S3_CR + 0xaf, 0x00, + S3_CR + 0xb0, 0xff, +#endif + S3_CR + 0xb1, 0x0e, +#if 0 + S3_CR + 0xb2, 0x55, + S3_CR + 0xb3, 0x00, + S3_CR + 0xb4, 0x55, + S3_CR + 0xb5, 0x00, + S3_CR + 0xb6, 0x00, +#endif + S3_CR + 0xb7, 0x84, +#if 0 + S3_CR + 0xb8, 0xff, + S3_CR + 0xb9, 0xff, + S3_CR + 0xba, 0xff, + S3_CR + 0xbb, 0xff, + S3_CR + 0xbc, 0xff, + S3_CR + 0xbd, 0xff, + S3_CR + 0xbe, 0xff, + S3_CR + 0xbf, 0xff, +#endif + + S3_SR +0x15, 0x23, + 0xffff, 1, + S3_SR +0x15, 0x03, + 0xffff, 1, +}; + +#define S3_NUM_BIOS_REG (sizeof (s3BiosReg) / sizeof (s3BiosReg[0])) + +typedef struct _bios32Init { + VGA16 offset; + VGA32 value; +} s3Bios32Init; + +s3Bios32Init s3Bios32Reg[] = { + 0x8168, 0x00000000, + 0x816c, 0x00000001, + 0x8170, 0x00000000, + 0x8174, 0x00000000, + 0x8178, 0x00000000, + 0x817c, 0x00000000, +#if 0 + 0x8180, 0x00140000, + 0x8184, 0x00000000, + 0x8188, 0x00000000, + 0x8190, 0x00000000, + 0x8194, 0x00000000, + 0x8198, 0x00000000, + 0x819c, 0x00000000, + 0x81a0, 0x00000000, +#endif + 0x81c0, 0x00000000, + 0x81c4, 0x01fbffff, + 0x81c8, 0x00f7ffbf, + 0x81cc, 0x00f7ff00, + 0x81d0, 0x11ffff7f, + 0x81d4, 0x7fffffdf, + 0x81d8, 0xfdfff9ff, + 0x81e0, 0xfd000000, + 0x81e4, 0x00000000, + 0x81e8, 0x00000000, + 0x81ec, 0x00010000, + 0x81f0, 0x07ff057f, + 0x81f4, 0x07ff07ff, + 0x81f8, 0x00000000, + 0x81fc, 0x00000000, + 0x8200, 0x00000000, + 0x8204, 0x00000000, + 0x8208, 0x33000000, + 0x820c, 0x7f000000, + 0x8210, 0x80000000, + 0x8214, 0x00000000, + 0x8218, 0xffffffff, + 0x8300, 0xff007fef, + 0x8304, 0xfffdf7bf, + 0x8308, 0xfdfffbff, +}; + +#define S3_NUM_BIOS32_REG (sizeof (s3Bios32Reg) / sizeof (s3Bios32Reg[0])) + +/* + * Initialize the card precisely as the bios does + */ +s3DoBiosInit (KdCardInfo *card) +{ + S3CardInfo *s3c = card->driver; + CARD32 *regs = (CARD32 *) s3c->registers; + S3Vga *s3vga = &s3c->s3vga; + int r; + + for (r = 0; r < S3_NUM_BIOS_REG; r++) + { + if (s3BiosReg[r].reg == 0xffff) + sleep (s3BiosReg[r].value); + else + VgaStore (&s3vga->card, s3BiosReg[r].reg, s3BiosReg[r].value); + } + VgaStore (&s3vga->card, S3_SR+0x10, 0x22); + VgaStore (&s3vga->card, S3_SR+0x11, 0x44); + VgaStore (&s3vga->card, S3_SR+0x15, 0x01); + sleep (1); + VgaStore (&s3vga->card, S3_SR+0x15, 0x03); + VgaStore (&s3vga->card, S3_CR+0x6f, 0xff); + VgaStore (&s3vga->card, S3_CR+0x3f, 0x3f); + sleep (1); + VgaStore (&s3vga->card, S3_CR+0x3f, 0x00); + VgaStore (&s3vga->card, S3_CR+0x6f, 0xfe); + VgaInvalidate (&s3vga->card); + for (r = 0; r < S3_NUM_BIOS32_REG; r++) + regs[s3Bios32Reg[r].offset/4] = s3Bios32Reg[r].value; +} + +void +s3Preserve (KdCardInfo *card) +{ + S3CardInfo *s3c = card->driver; + S3Ptr s3 = s3c->s3; + S3Vga *s3vga = &s3c->s3vga; + S3Save *save = &s3c->save; + CARD8 t1, t2; + CARD8 *cursor_base; + CARD8 streams_mode; + + s3Save (s3vga); + if (!s3c->bios_initialized) + s3DoBiosInit (card); + + _s3SetBlank (s3, s3vga, TRUE); + /* + * Preserve the first part of the frame buffer which holds + * the text mode fonts and data + */ + s3Set (s3vga, s3_linear_window_size, 3); + s3Set (s3vga, s3_enable_linear, 1); + VgaFlush (&s3vga->card); + memcpy (save->text_save, s3c->frameBuffer, S3_TEXT_SAVE); + /* + * Preserve graphics engine state + */ + save->alt_mix = s3->alt_mix; + save->write_mask = s3->write_mask; + save->fg = s3->fg; + save->bg = s3->bg; + /* + * Preserve streams processor state + */ + streams_mode = s3Get (s3vga, s3_streams_mode); + s3SetImm (s3vga, s3_streams_mode, 3); + save->global_bitmap_1 = s3->global_bitmap_1; + save->global_bitmap_2 = s3->global_bitmap_2; + save->adv_func_cntl = s3->adv_func_cntl; + save->primary_bitmap_1 = s3->primary_bitmap_1; + save->primary_bitmap_2 = s3->primary_bitmap_2; + save->secondary_bitmap_1 = s3->secondary_bitmap_1; + save->secondary_bitmap_2 = s3->secondary_bitmap_2; + save->primary_stream_control = s3->primary_stream_control; + save->blend_control = s3->blend_control; + save->primary_stream_addr_0 = s3->primary_stream_addr_0; + save->primary_stream_addr_1 = s3->primary_stream_addr_1; + save->primary_stream_stride = s3->primary_stream_stride; + save->primary_stream_xy = s3->primary_stream_xy; + save->primary_stream_size = s3->primary_stream_size; + save->primary_stream_mem = s3->primary_stream_mem; + save->secondary_stream_xy = s3->secondary_stream_xy; + save->secondary_stream_size = s3->secondary_stream_size; + save->streams_fifo = s3->streams_fifo; + s3SetImm (s3vga, s3_streams_mode, streams_mode); + _s3SetBlank (s3, s3vga, FALSE); +} + +/* + * Enable the card for rendering. Manipulate the initial settings + * of the card here. + */ +int s3CpuTimeout, s3AccelTimeout; + +void +s3SetGlobalBitmap (ScreenPtr pScreen, int ma) +{ + KdScreenPriv(pScreen); + s3ScreenInfo (pScreenPriv); + + if (s3s->current_ma != ma) + { + s3CardInfo (pScreenPriv); + S3Vga *s3vga = &s3c->s3vga; + S3Ptr s3 = s3c->s3; + CARD32 gb1, gb2; + int depth; + int length; + KdCheckSync (pScreen); + switch (s3s->fb[ma].accel_bpp) { + case 8: + case 24: + length = 0; + break; + case 16: + length = 1; + break; + case 32: + length = 3; + break; + } + s3SetImm (s3vga, s3_pixel_length, length); + gb1 = s3s->fb[ma].bitmap_offset; + gb2 = ((1 << 0) | + (0 << 2) | + (1 << 3) | + ((s3s->fb[ma].accel_stride >> 4) << 4) | + (s3s->fb[ma].accel_bpp << 16) | + (0 << 24) | + (1 << 28)); + s3->global_bitmap_1 = gb1; + s3->global_bitmap_2 = gb2; + s3->global_bitmap_2 = gb2; + s3s->current_ma = ma; + } +} + +Bool +s3Enable (ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + KdScreenInfo *screen = pScreenPriv->screen; + s3CardInfo (pScreenPriv); + s3ScreenInfo (pScreenPriv); + + S3Vga *s3vga = &s3c->s3vga; + S3Ptr s3 = s3c->s3; + int hactive, hblank, hfp, hbp; + int vactive, vblank, vfp, vbp; + int hsize; + + int h_total; + int h_display_end; + int h_blank_start; + int h_blank_end; + int h_sync_start; + int h_sync_end; + int h_screen_off; + int h_start_fifo_fetch; + + int primary_stream_l1[KD_MAX_FB]; + + int v_total; + int v_retrace_start; + int v_retrace_end; + int v_display_end; + int v_blank_start; + int v_blank_end; + int v_blank_start_adjust = 0; + int v_blank_end_adjust = 0; + + int h_blank_start_adjust = 0; + int h_blank_end_adjust = 0; + int h_sync_start_adjust = 0; + int h_sync_end_adjust = 0; + int h_start_fifo_fetch_adjust = 0; + int h_sync_extend; + int h_blank_extend; + int i; + CARD16 cursor_address; + const KdMonitorTiming *t; + int m, n, r; + Bool clock_double; + int cpu_timeout; + int accel_timeout; + int bytes_per_ms; + CARD32 control[2]; + int fb; + int ma; + + s3s->primary_depth = screen->fb[s3s->fbmap[0]].depth; + + s3s->use_streams = TRUE; + + t = KdFindMode (screen, s3ModeSupported); + + hfp = t->hfp; + hbp = t->hbp; + hblank = t->hblank; + hactive = t->horizontal; + + vfp = t->vfp; + vbp = t->vbp; + vblank = t->vblank; + vactive = t->vertical; + + + m = s3Get (s3vga, s3_dclk_m); + n = s3Get (s3vga, s3_dclk_n); + r = s3Get (s3vga, s3_dclk_r); +#define DEBUG_CLOCK +#ifdef DEBUG_CLOCK + fprintf (stderr, "old clock %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r)); +#endif + clock_double = FALSE; + s3GetClock (t->clock, &m, &n, &r, 511, 127, 4, 250000); + if (S3_CLOCK(m,n,r) > S3_MAX_CLOCK && !s3s->use_streams) + clock_double = TRUE; + s3Set (s3vga, s3_clock_select, 3); + s3Set (s3vga, s3_dclk_m, m); + s3Set (s3vga, s3_dclk_n, n); + s3Set (s3vga, s3_dclk_r, r); +#ifdef DEBUG_CLOCK + fprintf (stderr, "new clock %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r)); +#endif + + if (s3s->use_streams) + { + s3Set (s3vga, s3_streams_mode, 3); + s3Set (s3vga, s3_enable_l1_parameter, 1); + } + else + { + s3Set (s3vga, s3_streams_mode, 0); + s3Set (s3vga, s3_enable_l1_parameter, 0); + } + s3Set (s3vga, s3_flat_panel_output_control_1, 0); + s3Set (s3vga, s3_flat_panel_output_control_2, 0); + s3Set (s3vga, s3_select_graphics_mode, 1); + s3Set (s3vga, s3_enable_blinking, 0); + s3Set (s3vga, s3_enable_vga_16bit, 0); + s3Set (s3vga, s3_enhanced_memory_mapping, 1); + s3Set (s3vga, s3_enable_sff, 1); + s3Set (s3vga, s3_enable_2d_access, 1); + s3Set (s3vga, s3_2bk_cga, 1); + s3Set (s3vga, s3_4bk_hga, 1); + s3Set (s3vga, s3_v_total_double, 0); + s3Set (s3vga, s3_address_16k_wrap, 1); + s3Set (s3vga, s3_word_mode, 0); + s3Set (s3vga, s3_byte_mode, 1); + s3Set (s3vga, s3_hardware_reset, 1); + s3Set (s3vga, s3_max_scan_line, 0); + s3Set (s3vga, s3_linear_window_size, 3); + s3Set (s3vga, s3_enable_linear, 1); + s3Set (s3vga, s3_enable_2d_3d, 1); + s3Set (s3vga, s3_refresh_control, 1); + s3Set (s3vga, s3_disable_pci_read_bursts, 0); + s3Set (s3vga, s3_pci_disconnect_enable, 1); + s3Set (s3vga, s3_primary_load_control, 0); + s3Set (s3vga, s3_secondary_load_control, 0); + s3Set (s3vga, s3_pci_retry_enable, 1); + s3Set (s3vga, s3_enable_256, 1); + s3Set (s3vga, s3_border_select, 1); /* eliminate white border */ + s3SetImm (s3vga, s3_lock_palette, 0); /* unlock palette/border regs */ + s3Set (s3vga, s3_disable_v_retrace_int, 1); + if (t->hpol == KdSyncPositive) + s3Set (s3vga, s3_horz_sync_neg, 0); + else + s3Set (s3vga, s3_horz_sync_neg, 1); + if (t->vpol == KdSyncPositive) + s3Set (s3vga, s3_vert_sync_neg, 0); + else + s3Set (s3vga, s3_vert_sync_neg, 1); + + s3Set (s3vga, s3_dot_clock_8, 1); + s3Set (s3vga, s3_enable_write_plane, 0xf); + s3Set (s3vga, s3_extended_memory_access, 1); + s3Set (s3vga, s3_sequential_addressing_mode, 1); + s3Set (s3vga, s3_select_chain_4_mode, 1); + s3Set (s3vga, s3_linear_addressing_control, 1); + + s3Set (s3vga, s3_enable_gamma_correction, 0); + + s3Set (s3vga, s3_enable_8_bit_luts, 1); + + s3Set (s3vga, s3_dclk_invert, 0); + s3Set (s3vga, s3_enable_clock_double, 0); + s3Set (s3vga, s3_dclk_over_2, 0); + + s3Set (s3vga, s3_delay_h_enable, 0); + s3Set (s3vga, s3_sdclk_skew, 0); + + s3Set (s3vga, s3_dac_mask, 0xff); + +#if 0 +#ifdef DEBUG_CLOCK + m = s3Get (s3vga, s3_mclk_m); + n = s3Get (s3vga, s3_mclk_n); + r = s3Get (s3vga, s3_mclk_r); + fprintf (stderr, "old mclk %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r)); +#endif + + s3GetClock (125282, &m, &n, &r, 127, 31, 3, 250000); + +#ifdef DEBUG_CLOCK + fprintf (stderr, "new mclk %d, %d, %d (%d)\n", m, n, r,S3_CLOCK(m,n,r)); +#endif + + s3Set (s3vga, s3_mclk_m, m); + s3Set (s3vga, s3_mclk_n, n); + s3Set (s3vga, s3_mclk_r, r); + +#ifdef DEBUG_CLOCK + m = s3Get (s3vga, s3_eclk_m); + n = s3Get (s3vga, s3_eclk_n); + r = s3Get (s3vga, s3_eclk_r); + fprintf (stderr, "old eclk %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r)); +#endif + +#define S3_ECLK 125282 + + s3GetClock (S3_ECLK, &m, &n, &r, 127, 31, 3, 250000); + +#ifdef DEBUG_CLOCK + fprintf (stderr, "new eclk %d, %d, %d (%d)\n", m, n, r,S3_CLOCK(m,n,r)); +#endif + + s3Set (s3vga, s3_eclk_m, m); + s3Set (s3vga, s3_eclk_n, n); + s3Set (s3vga, s3_eclk_r, r); +#endif + + /* + * Compute character lengths for horizontal timing values + */ + hactive = screen->width / 8; + hblank /= 8; + hfp /= 8; + hbp /= 8; + /* + * Set pixel size, choose clock doubling mode + */ + + bytes_per_ms = 0; + + for (ma = 0; s3s->fbmap[ma] >= 0; ma++) + { + fb = s3s->fbmap[ma]; + s3s->fb[ma].accel_bpp = screen->fb[fb].bitsPerPixel; + s3s->fb[ma].accel_stride = screen->fb[fb].pixelStride; + s3s->fb[ma].bitmap_offset = screen->fb[fb].frameBuffer - s3c->frameBuffer; + switch (s3s->fb[ma].accel_bpp) { + case 8: + h_screen_off = hactive; + s3Set (s3vga, s3_pixel_length, 0); + s3Set (s3vga, s3_color_mode, 0); + control[ma] = 0; + /* + * Set up for double-pixel mode, switch color modes, + * divide the dclk and delay h blank by 2 dclks + */ + if (clock_double) + { + s3Set (s3vga, s3_color_mode, 1); + s3Set (s3vga, s3_dclk_over_2, 1); + s3Set (s3vga, s3_enable_clock_double, 1); + s3Set (s3vga, s3_h_skew, 1); + h_blank_start_adjust = -3; + h_blank_end_adjust = -4; + s3Set (s3vga, s3_border_select, 0); + } + break; + case 16: + h_screen_off = hactive * 2; + s3Set (s3vga, s3_pixel_length, 1); + if (screen->fb[fb].depth == 15) + control[ma] = 3 << 24; + else + control[ma] = 5 << 24; + if (clock_double) + { + if (screen->fb[fb].depth == 15) + s3Set (s3vga, s3_color_mode, 3); + else + s3Set (s3vga, s3_color_mode, 5); + s3Set (s3vga, s3_dclk_over_2, 1); + s3Set (s3vga, s3_enable_clock_double, 1); + s3Set (s3vga, s3_border_select, 0); + h_blank_start_adjust = 4; + h_blank_end_adjust = -4; + } + else + { + if (screen->fb[fb].depth == 15) + s3Set (s3vga, s3_color_mode, 2); + else + s3Set (s3vga, s3_color_mode, 4); + s3Set (s3vga, s3_dclk_over_2, 0); + s3Set (s3vga, s3_enable_clock_double, 0); + s3Set (s3vga, s3_delay_blank, 0); + } + break; + case 24: + control[ma] = 6 << 24; + h_screen_off = hactive * 3; + s3s->fb[ma].accel_bpp = 8; + s3s->fb[ma].accel_stride = screen->fb[fb].pixelStride * 3; + break; + case 32: + control[ma] = 7 << 24; + h_screen_off = hactive * 4; + s3Set (s3vga, s3_pixel_length, 3); + s3Set (s3vga, s3_color_mode, 0xd); + break; + } + bytes_per_ms += t->clock * (screen->fb[fb].bitsPerPixel / 8); + primary_stream_l1[ma] = (screen->width * screen->fb[fb].bitsPerPixel / (8 * 8)) - 1; + } + + /* + * X server starts frame buffer at top of memory + */ + s3Set (s3vga, s3_start_address, 0); + + /* + * Set various registers to avoid snow on the screen + */ + + fprintf (stderr, "bytes_per_ms %d\n", bytes_per_ms); + fprintf (stderr, "primary 0x%x master 0x%x command 0x%x lpb 0x%x cpu 0x%x 2d 0x%x\n", + s3Get (s3vga, s3_primary_stream_timeout), + s3Get (s3vga, s3_master_control_unit_timeout), + s3Get (s3vga, s3_command_buffer_timeout), + s3Get (s3vga, s3_lpb_timeout), + s3Get (s3vga, s3_cpu_timeout), + s3Get (s3vga, s3_2d_graphics_engine_timeout)); + + /* + * Test: + * accel x11perf -line500 + * cpu x11perf -circle500 + * + * cpu accel + * 1600x1200x32x85 (918000) 1 1 not enough + * 1600x1200x32x75 (810000) 3 2 + * 1600x1200x32x70 (756000) 4 3 + * 1600x1200x32x60 (648000) 6 5 + * + * 1280x1024x32x85 (630000) 6 4 + * 1280x1024x32x75 (540000) a 6 + * 1280x1024x32x60 (432000) 1f a + * + * 1152x900x32x85 (490000) a 6 + * 1152x900x32x75 (433000) 1f 8 + * 1152x900x32x70 (401000) 1f a + * 1152x900x32x66 (380000) 1f a + * + * 1024x768x32x85 (378000) 1f a + * 1024x768x32x75 (315000) 1f b + * 1024x768x32x70 (300000) 1f b + * 1024x768x32x60 (260000) 1f 12 + * + * 800x600x32x85 (225000) 1f 1a + * 800x600x32x72 (200000) 1f 1d + * 800x600x32x75 (198000) 1f 1d + * + * 1600x1200x16x85 (459000) 1f 8 + * 1600x1200x16x75 (405000) 1f a + * 1600x1200x16x70 (378000) 1f b + * 1600x1200x16x60 (324000) 1f f + * + * 1280x1024x16x85 (315000) 1f 12 + * 1280x1024x16x75 (270000) 1f 16 + * 1280x1024x16x60 (216000) 1f 1d + * + * 1600x1200x8x85 (229000) 1f 1f + * + */ + + if (s3CpuTimeout) + { + if (s3CpuTimeout < 0) + cpu_timeout = 0; + else + cpu_timeout = s3CpuTimeout; + if (s3AccelTimeout < 0) + accel_timeout = 0; + else if (s3AccelTimeout) + accel_timeout = s3AccelTimeout; + else + accel_timeout = s3CpuTimeout; + } + else if (bytes_per_ms >= 900000) + { + cpu_timeout = 0x01; + accel_timeout = 0x01; + } + else if (bytes_per_ms >= 800000) + { + cpu_timeout = 0x03; + accel_timeout = 0x02; + } + else if (bytes_per_ms >= 700000) + { + cpu_timeout = 0x04; + accel_timeout = 0x03; + } + else if (bytes_per_ms >= 600000) + { + cpu_timeout = 0x06; + accel_timeout = 0x04; + } + else if (bytes_per_ms >= 475000) + { + cpu_timeout = 0x0a; + accel_timeout = 0x06; + } + else if (bytes_per_ms >= 425000) + { + cpu_timeout = 0x1f; + accel_timeout = 0x8; + } + else if (bytes_per_ms >= 300000) + { + cpu_timeout = 0x1f; + accel_timeout = 0x0a; + } + else if (bytes_per_ms >= 250000) + { + cpu_timeout = 0x1f; + accel_timeout = 0x12; + } + else if (bytes_per_ms >= 200000) + { + cpu_timeout = 0x1f; + accel_timeout = 0x1a; + } + else + { + cpu_timeout = 0x1f; + accel_timeout = 0x1f; + } + + fprintf (stderr, "cpu 0x%x accel 0x%x\n", cpu_timeout, accel_timeout); + + s3Set (s3vga, s3_primary_stream_timeout, 0xc0); + s3Set (s3vga, s3_master_control_unit_timeout, 0xf); + s3Set (s3vga, s3_command_buffer_timeout, 0x1f); + s3Set (s3vga, s3_lpb_timeout, 0xf); + s3Set (s3vga, s3_2d_graphics_engine_timeout, accel_timeout); + s3Set (s3vga, s3_cpu_timeout, cpu_timeout); + + s3Set (s3vga, s3_fifo_fetch_timing, 1); + s3Set (s3vga, s3_fifo_drain_delay, 2); + + /* + * Compute horizontal register values from timings + */ + h_total = hactive + hblank - 5; + h_display_end = hactive - 1; + + h_sync_start = hactive + hfp + h_sync_start_adjust; + h_sync_end = hactive + hblank - hbp + h_sync_end_adjust; + /* + * pad the blank values narrow a bit and use the border_select to + * eliminate the remaining border; don't know why, but it doesn't + * work in the documented fashion + */ + h_blank_start = hactive + 1 + h_blank_start_adjust; + h_blank_end = hactive + hblank - 2 + h_blank_end_adjust; + /* + * The manual says h_total - 5, but the + * bios does differently... + */ + if (screen->width >= 1600) + h_start_fifo_fetch = h_total - 24; + else if (screen->width >= 1280) + h_start_fifo_fetch = h_total - 19; + else if (screen->width >= 1024) + h_start_fifo_fetch = h_total - 14; + else if (screen->width >= 800) + h_start_fifo_fetch = h_total - 10; + else + h_start_fifo_fetch = h_total - 5; + + h_start_fifo_fetch += h_start_fifo_fetch_adjust; + if (h_blank_end - h_blank_start >= 0x40) + h_blank_extend = 1; + else + h_blank_extend = 0; + + if (h_sync_end - h_sync_start >= 0x20) + h_sync_extend = 1; + else + h_sync_extend = 0; + +#ifdef DEBUG + fprintf (stderr, "h_total %d h_display_end %d\n", + h_total, h_display_end); + fprintf (stderr, "h_sync_start %d h_sync_end %d h_sync_extend %d\n", + h_sync_start, h_sync_end, h_sync_extend); + fprintf (stderr, "h_blank_start %d h_blank_end %d h_blank_extend %d\n", + h_blank_start, h_blank_end, h_blank_extend); +#endif + + s3Set (s3vga, s3_h_total, h_total); + s3Set (s3vga, s3_h_display_end, h_display_end); + s3Set (s3vga, s3_h_blank_start, h_blank_start); + s3Set (s3vga, s3_h_blank_end, h_blank_end); + s3Set (s3vga, s3_h_sync_start, h_sync_start); + s3Set (s3vga, s3_h_sync_end, h_sync_end); + s3Set (s3vga, s3_screen_offset, h_screen_off); + s3Set (s3vga, s3_h_start_fifo_fetch, h_start_fifo_fetch); + s3Set (s3vga, s3_h_sync_extend, h_sync_extend); + s3Set (s3vga, s3_h_blank_extend, h_blank_extend); + + s3Set (s3vga, s3_dac_power_saving_disable, 0); + s3Set (s3vga, s3_dac_power_up_time, hactive + hblank); + + s3Set (s3vga, s3_primary_stream_l1, primary_stream_l1[0]); + + s3Set (s3vga, s3_streams_fifo_delay, 0); + + v_total = vactive + vblank - 2; + v_display_end = vactive - 1; + + v_blank_start = vactive - 1 + v_blank_start_adjust; + v_blank_end = v_blank_start + vblank - 1 + v_blank_end_adjust; + + v_retrace_start = vactive + vfp; + v_retrace_end = vactive + vblank - vbp; + + s3Set (s3vga, s3_v_total, v_total); + s3Set (s3vga, s3_v_retrace_start, v_retrace_start); + s3Set (s3vga, s3_v_retrace_end, v_retrace_end); + s3Set (s3vga, s3_v_display_end, v_display_end); + s3Set (s3vga, s3_v_blank_start, v_blank_start); + s3Set (s3vga, s3_v_blank_end, v_blank_end); + + if (vactive >= 1024) + s3Set (s3vga, s3_line_compare, 0x7ff); + else + s3Set (s3vga, s3_line_compare, 0x3ff); + + /* + * Set cursor + */ + if (!screen->softCursor) + { + cursor_address = (s3s->cursor_base - s3c->frameBuffer) / 1024; + + s3Set (s3vga, s3_cursor_address, cursor_address); + s3Set (s3vga, s3_cursor_ms_x11, 0); + s3Set (s3vga, s3_cursor_enable, 1); + } + else + s3Set (s3vga, s3_cursor_enable, 0); + +#define MAKE_GBF(bds,be,stride,bpp,tile) (\ + ((bds) << 0) | \ + ((be) << 3) | \ + ((stride) << 4) | \ + ((bpp) << 16) | \ + ((tile) << 24)) + /* + * Set accelerator + */ + switch (screen->width) { +#if 0 + case 640: s3Set (s3vga, s3_ge_screen_width, 1); break; + case 800: s3Set (s3vga, s3_ge_screen_width, 2); break; + case 1024: s3Set (s3vga, s3_ge_screen_width, 0); break; + case 1152: s3Set (s3vga, s3_ge_screen_width, 4); break; + case 1280: s3Set (s3vga, s3_ge_screen_width, 3); break; + case 1600: s3Set (s3vga, s3_ge_screen_width, 6); break; +#endif + default: + s3Set (s3vga, s3_ge_screen_width, 7); /* use global bitmap descriptor */ + } + +#if 0 + crtc->l_parm_0_7 = screen->width / 4; /* Undocumented. */ +#endif + + /* + * Set DPMS to normal + */ + s3Set (s3vga, s3_hsync_control, 0); + s3Set (s3vga, s3_vsync_control, 0); + + _s3SetBlank (s3, s3vga, TRUE); + if (s3s->use_streams) + s3Set (s3vga, s3_primary_stream_definition, 1); + else + s3Set (s3vga, s3_primary_stream_definition, 0); + + VgaFlush(&s3vga->card); + VgaSetImm (&s3vga->card, s3_clock_load_imm, 1); + VgaSetImm(&s3vga->card, s3_clock_load_imm, 0); + + + if (s3s->use_streams) + { + fb = s3s->fbmap[0]; + s3->primary_stream_control = control[0]; + s3->primary_stream_addr_0 = + s3->primary_stream_addr_1 = s3s->fb[0].bitmap_offset; + s3->primary_stream_stride = screen->fb[fb].byteStride; + s3->primary_stream_xy = (1 << 16) | 1; + s3->primary_stream_size = ((screen->fb[fb].pixelStride - 1) << 16) | screen->height; + s3->primary_stream_mem = (screen->fb[fb].byteStride * screen->height) / 8 - 1; + if (s3s->fbmap[1] >= 0) + { + fb = s3s->fbmap[1]; + s3->blend_control = 5 << 24; + if (s3s->fb[0].accel_bpp == 8) + s3->chroma_key_control = 0x33000000 | s3s->fb[0].chroma_key; + else + s3->chroma_key_control = 0x13010101; + s3->secondary_stream_control = control[1] | screen->width; + s3->secondary_stream_h_scale = (1 << 15); + s3->color_adjustment = 0; + s3->secondary_stream_vscale = (1 << 15); + s3->secondary_stream_vinit = 0; + s3->secondary_stream_mbuf = 0; + s3->secondary_stream_addr_0 = + s3->secondary_stream_addr_1 = s3s->fb[1].bitmap_offset; + s3->secondary_stream_stride = screen->fb[fb].byteStride; + s3->secondary_stream_scount = screen->height; + s3->secondary_stream_xy = (1 << 16) | 1; + s3->secondary_stream_size = ((screen->fb[fb].pixelStride - 1) << 16) | screen->height; + s3->secondary_stream_mem = (1 << 22) | ((screen->fb[fb].byteStride * screen->height) / 8 - 1); + } + else + { + s3->blend_control = 1 << 24; + s3->secondary_stream_xy = 0x07ff07ff; + s3->secondary_stream_size = 0x00010001; + } + s3->streams_fifo = (0x20 << 11) | (0x20 << 5) | 0x2; + } + s3->mult_misc_read_sel = (((1 << 9) | + (1 << 11) | + (0xe << 12)) | + (((0xe << 0) | + (0xf << 12)) << 16)); + + s3->cmd_overflow_buf_ptr = (1 << 3); + s3->bci_power_management = (1 << 9); + s3->adv_func_cntl = (3 << 8) | (1 << 4) | (1 << 2) | 1; + s3->primary_bitmap_1 = 0; + s3->primary_bitmap_2 = 0; + s3->secondary_bitmap_1 = 0; + s3->secondary_bitmap_2 = 0; + s3s->current_ma = -1; + _s3SetBlank (s3, s3vga, FALSE); +#if 0 + { + VGA16 r; + static CARD32 streams[][2] = { + /* PCI registers */ + 0x8000, 0x8024, + 0x802c, 0x8034, + 0x803c, 0x8040, +#if 0 + 0x8080, 0x808c, /* AGP */ +#endif + 0x80dc, 0x80e0, + + /* 2D registers */ + 0x8168, 0x8188, + 0x8190, 0x81a0, + 0x81c0, 0x81d8, + 0x81e0, 0x8218, + 0x8300, 0x8308, + 0x8504, 0x8510, + + /* LPB/VIP registers */ + 0xff00, 0xff18, + 0xff20, 0xff38, + 0xff40, 0xff40, + 0xff70, 0xff78, + 0xff8c, 0xffa0, + +#if 0 + /* 3D registers */ + 0x48508, 0x48508, + 0x48528, 0x48528, + 0x48548, 0x48548, + 0x48584, 0x485f0, +#endif + + /* motion compensation registers */ + 0x48900, 0x48924, +#if 0 + 0x48928, 0x48928, +#endif + + /* Mastered data transfer registers */ + 0x48a00, 0x48a1c, + + /* configuation/status registers */ + 0x48c00, 0x48c18, + 0x48c20, 0x48c24, + 0x48c40, 0x48c50, + 0x48c60, 0x48c64, + + 0, 0, + }; +#ifdef PHOENIX +#undef stderr +#define stderr stdout +#endif + CARD32 *regs = (CARD32 *) s3c->registers; + int i; + CARD32 reg; + + + for (r = S3_SR + 0; r < S3_SR + S3_NSR; r++) + fprintf (stderr, "SR%02x = %02x\n", r-S3_SR, VgaFetch (&s3vga->card, r)); + for (r = S3_GR + 0; r < S3_GR + S3_NGR; r++) + fprintf (stderr, "GR%02x = %02x\n", r-S3_GR, VgaFetch (&s3vga->card, r)); + for (r = S3_AR + 0; r < S3_AR + S3_NAR; r++) + fprintf (stderr, "AR%02x = %02x\n", r-S3_AR, VgaFetch (&s3vga->card, r)); + for (r = S3_CR + 0; r < S3_CR + S3_NCR; r++) + fprintf (stderr, "CR%02x = %02x\n", r-S3_CR, VgaFetch (&s3vga->card, r)); + for (r = S3_DAC + 0; r < S3_DAC + S3_NDAC; r++) + fprintf (stderr, "DAC%02x = %02x\n", r-S3_DAC, VgaFetch (&s3vga->card, r)); + fprintf (stderr, "MISC_OUT = %02x\n", VgaFetch (&s3vga->card, S3_MISC_OUT)); + fprintf (stderr, "INPUT_STATUS = %02x\n", VgaFetch (&s3vga->card, S3_INPUT_STATUS_1)); + + + for (i = 0; streams[i][0]; i++) + { + for (reg = streams[i][0]; reg <= streams[i][1]; reg += 4) + fprintf (stderr, "0x%4x: 0x%08x\n", reg, regs[reg/4]); + } + } +#endif + return TRUE; +} + +void +s3Disable (ScreenPtr pScreen) +{ +} + +void +s3Restore (KdCardInfo *card) +{ + S3CardInfo *s3c = card->driver; + S3Ptr s3 = s3c->s3; + S3Vga *s3vga = &s3c->s3vga; + S3Save *save = &s3c->save; + CARD8 *cursor_base; + CARD8 streams_mode; + + _s3SetBlank (s3, s3vga, TRUE); + /* streams processor state */ + streams_mode = s3Get (s3vga, s3_streams_mode); + s3SetImm (s3vga, s3_streams_mode, 3); + s3->global_bitmap_1 = save->global_bitmap_1; + s3->global_bitmap_2 = save->global_bitmap_2; + s3->adv_func_cntl = save->adv_func_cntl; + s3->primary_bitmap_1 = save->primary_bitmap_1; + s3->primary_bitmap_2 = save->primary_bitmap_2; + s3->secondary_bitmap_1 = save->secondary_bitmap_1; + s3->secondary_bitmap_2 = save->secondary_bitmap_2; + s3->primary_stream_control = save->primary_stream_control; + s3->blend_control = save->blend_control; + s3->primary_stream_addr_0 = save->primary_stream_addr_0; + s3->primary_stream_addr_0 = save->primary_stream_addr_0; + s3->primary_stream_stride = save->primary_stream_stride; + s3->primary_stream_xy = save->primary_stream_xy; + s3->primary_stream_size = save->primary_stream_size; + s3->primary_stream_mem = save->primary_stream_mem; + s3->secondary_stream_xy = save->secondary_stream_xy; + s3->secondary_stream_size = save->secondary_stream_size; + s3->streams_fifo = save->streams_fifo; + s3SetImm (s3vga, s3_streams_mode, streams_mode); + /* graphics engine state */ + s3->alt_mix = save->alt_mix; + s3->write_mask = save->write_mask; + s3->fg = save->fg; + s3->bg = save->bg; + /* XXX should save and restore real values? */ + s3->scissors_tl = 0x00000000; + s3->scissors_br = 0x0fff0fff; + + VgaRestore (&s3vga->card); + s3Set (s3vga, s3_linear_window_size, 3); + s3Set (s3vga, s3_enable_linear, 1); + VgaFlush (&s3vga->card); + memcpy (s3c->frameBuffer, save->text_save, S3_TEXT_SAVE); + s3Reset (s3vga); + _s3SetBlank (s3, s3vga, FALSE); +} + +void +_s3SetSync (S3CardInfo *s3c, int hsync, int vsync) +{ + /* this abuses the macros defined to access the crtc structure */ + S3Ptr s3 = s3c->s3; + S3Vga *s3vga = &s3c->s3vga; + + s3Set (s3vga, s3_hsync_control, hsync); + s3Set (s3vga, s3_vsync_control, vsync); + VgaFlush (&s3vga->card); +} + +Bool +s3DPMS (ScreenPtr pScreen, int mode) +{ + KdScreenPriv(pScreen); + s3CardInfo(pScreenPriv); + S3Vga *s3vga = &s3c->s3vga; + + switch (mode) { + case KD_DPMS_NORMAL: + _s3SetSync (s3c, 0, 0); + _s3SetBlank (s3c->s3, s3vga, FALSE); + break; + case KD_DPMS_STANDBY: + _s3SetBlank (s3c->s3, s3vga, TRUE); + _s3SetSync (s3c, 1, 0); + break; + case KD_DPMS_SUSPEND: + _s3SetBlank (s3c->s3, s3vga, TRUE); + _s3SetSync (s3c, 0, 1); + break; + case KD_DPMS_POWERDOWN: + _s3SetBlank (s3c->s3, s3vga, TRUE); + _s3SetSync (s3c, 1, 1); + break; + } + return TRUE; +} + +Bool +s3InitScreen(ScreenPtr pScreen) +{ + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + KdScreenInfo *screen = pScreenPriv->screen; + s3CardInfo (pScreenPriv); + s3ScreenInfo (pScreenPriv); + int ma, fb; + + if (screen->fb[1].depth) + { + FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen); + + for (ma = 0; s3s->fbmap[ma] >= 0; ma++) + { + fb = s3s->fbmap[ma]; + pScrPriv->layer[fb].key = s3s->fb[ma].chroma_key; + } + } + return TRUE; +} + +void +s3ScreenFini (KdScreenInfo *screen) +{ + S3ScreenInfo *s3s = (S3ScreenInfo *) screen->driver; + + xfree (s3s); + screen->driver = 0; +} + +void +s3CardFini (KdCardInfo *card) +{ + S3CardInfo *s3c = (S3CardInfo *) card->driver; + + KdUnmapDevice (s3c->frameBuffer, s3c->memory); + KdUnmapDevice (s3c->registers, sizeof (S3) + PACKED_OFFSET); + xfree (s3c); + card->driver = 0; +} + +KdCardFuncs s3Funcs = { + s3CardInit, + s3ScreenInit, + s3InitScreen, + s3Preserve, + s3Enable, + s3DPMS, + s3Disable, + s3Restore, + s3ScreenFini, + s3CardFini, + s3CursorInit, + s3CursorEnable, + s3CursorDisable, + s3CursorFini, + s3RecolorCursor, + s3DrawInit, + s3DrawEnable, + s3DrawSync, + s3DrawDisable, + s3DrawFini, + s3GetColors, + s3PutColors, +}; --- xorg-server-1.4.99.906.orig/hw/xgl/glx/xglxinit.c +++ xorg-server-1.4.99.906/hw/xgl/glx/xglxinit.c @@ -0,0 +1,172 @@ +/* + * Copyright © 2004 David Reveman + * + * 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 + * David Reveman not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior permission. + * David Reveman makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL DAVID REVEMAN 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. + * + * Author: David Reveman + */ + +#include "xglx.h" +#include "xglglx.h" + +xglScreenInfoRec xglScreenInfo = { + NULL, 0, 0, 0, 0, 0, + DEFAULT_GEOMETRY_DATA_TYPE, + DEFAULT_GEOMETRY_USAGE, + FALSE, + XGL_DEFAULT_PBO_MASK, + FALSE, + { + { FALSE, FALSE, { 0, 0, 0, 0 } }, + { FALSE, FALSE, { 0, 0, 0, 0 } }, + { FALSE, FALSE, { 0, 0, 0, 0 } }, + { FALSE, FALSE, { 0, 0, 0, 0 } } + } +}; + +#ifdef GLXEXT +static Bool loadGlx = TRUE; + +#ifndef NGLXEXTLOG +static char *glxExtLogFile = 0; +#endif + +#endif + +void +InitOutput (ScreenInfo *pScreenInfo, + int argc, + char **argv) +{ + +#ifdef GLXEXT + if (loadGlx) + { + if (!xglLoadGLXModules ()) + FatalError ("No GLX modules loaded"); + +#ifndef NGLXEXTLOG + if (glxExtLogFile) + { + __xglGLXLogFp = fopen (glxExtLogFile, "w"); + if (!__xglGLXLogFp) + perror ("InitOutput"); + } + else + __xglGLXLogFp = 0; +#endif + + } +#endif + + xglxInitOutput (pScreenInfo, argc, argv); +} + +Bool +LegalModifier (unsigned int key, + DeviceIntPtr pDev) +{ + return xglxLegalModifier (key, pDev); +} + +void +ProcessInputEvents (void) +{ + xglxProcessInputEvents (); +} + +void +InitInput (int argc, + char **argv) +{ + xglxInitInput (argc, argv); +} + +void +ddxUseMsg (void) +{ + ErrorF ("\nXgl usage:\n"); + +#ifdef GLXEXT + ErrorF ("-noglx don't load glx extension\n"); + +#ifndef NGLXEXTLOG + ErrorF ("-glxlog file glx extension log file\n"); +#endif + +#endif + + xglUseMsg (); + ErrorF ("\nXglx usage:\n"); + xglxUseMsg (); +} + +int +ddxProcessArgument (int argc, + char **argv, + int i) +{ + int skip; + +#ifdef GLXEXT + if (!strcmp (argv[i], "-noglx")) + { + loadGlx = FALSE; + return 1; + } + +#ifndef NGLXEXTLOG + else if (!strcmp (argv[i], "-glxlog")) + { + if (++i < argc) + glxExtLogFile = argv[i]; + } +#endif + +#endif + + skip = xglProcessArgument (argc, argv, i); + if (skip) + return skip; + + return xglxProcessArgument (argc, argv, i); +} + +void +AbortDDX (void) +{ + xglxAbort (); +} + +void +ddxGiveUp (void) +{ + xglxGiveUp (); +} + +void +OsVendorInit (void) +{ + xglxOsVendorInit (); +} + +void ddxInitGlobals() +{ +} --- xorg-server-1.4.99.906.orig/hw/dmx/examples/xled.c +++ xorg-server-1.4.99.906/hw/dmx/examples/xled.c @@ -37,7 +37,7 @@ #include #include #include -#include "xkbstr.h" +#include #include int main(int argc, char **argv) --- xorg-server-1.4.99.906.orig/hw/dmx/examples/xinput.c +++ xorg-server-1.4.99.906/hw/dmx/examples/xinput.c @@ -38,7 +38,7 @@ #include #include #include -#include "xkbstr.h" +#include #include #include --- xorg-server-1.4.99.906.orig/hw/xfree86/os-support/linux/lnx_ia64.c +++ xorg-server-1.4.99.906/hw/xfree86/os-support/linux/lnx_ia64.c @@ -0,0 +1,74 @@ +/* + * Copyright 2004, Egbert Eich + * + * 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 + * EGBERT EICH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- + * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Egbert Eich shall not + * be used in advertising or otherwise to promote the sale, use or other deal- + *ings in this Software without prior written authorization from Egbert Eich. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "ia64Pci.h" +#include "Pci.h" + +#if defined OS_PROBE_PCI_CHIPSET +IA64Chipset OS_PROBE_PCI_CHIPSET(scanpciWrapperOpt flags) +{ + struct stat unused; + struct utsname utsName; + + if (!stat("/proc/bus/mckinley/zx1",&unused) + || !stat("/proc/bus/mckinley/zx2",&unused)) + return ZX1_CHIPSET; + + if (!stat("/proc/sgi_sn/licenseID", &unused)) { + int major, minor, patch; + char *c; + + /* We need a 2.6.11 or better kernel for Altix support */ + uname(&utsName); + c = utsName.release; + + major = atoi(c); + c = strstr(c, ".") + 1; + minor = atoi(c); + c = strstr(c, ".") + 1; + patch = atoi(c); + + if (major < 2 || (major == 2 && minor < 6) || + (major == 2 && minor == 6 && patch < 11)) { + ErrorF("Kernel 2.6.11 or better needed for Altix support\n"); + return NONE_CHIPSET; + } + return ALTIX_CHIPSET; + } + + return NONE_CHIPSET; +} +#endif --- xorg-server-1.4.99.906.orig/hw/xfree86/os-support/bus/zx1PCI.h +++ xorg-server-1.4.99.906/hw/xfree86/os-support/bus/zx1PCI.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2002-2003 The XFree86 Project, Inc. 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, 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 THE + * XFREE86 PROJECT 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 XFree86 Project 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 + * XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifndef PCI_ZX1_H +#define PCI_ZX1_H 1 + +#include + +void xf86PreScanZX1(void); +void xf86PostScanZX1(void); + +#endif --- xorg-server-1.4.99.906.orig/hw/xfree86/os-support/bus/460gxPCI.h +++ xorg-server-1.4.99.906/hw/xfree86/os-support/bus/460gxPCI.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2002-2003 The XFree86 Project, Inc. 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, 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 THE + * XFREE86 PROJECT 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 XFree86 Project 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 + * XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifndef PCI_460GX_H +#define PCI_460GX_H 1 + +#include +#include + +Bool xorgProbe460GX(scanpciWrapperOpt flags); +void xf86PreScan460GX(void); +void xf86PostScan460GX(void); + +#endif --- xorg-server-1.4.99.906.orig/hw/xfree86/os-support/bus/altixPCI.h +++ xorg-server-1.4.99.906/hw/xfree86/os-support/bus/altixPCI.h @@ -0,0 +1,20 @@ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifndef PCI_ALTIX_H +#define PCI_ALTIX_H 1 + +#include +#include + +Bool xorgProbeAltix(scanpciWrapperOpt flags); +void xf86PreScanAltix(void); +void xf86PostScanAltix(void); + +/* Some defines for PCI */ +#define VENDOR_SGI 0x10A9 +#define CHIP_TIO_CA 0x1010 +#define CHIP_PIC_PCI 0x1011 + +#endif --- xorg-server-1.4.99.906.orig/hw/xfree86/os-support/bus/altixPCI.c +++ xorg-server-1.4.99.906/hw/xfree86/os-support/bus/altixPCI.c @@ -0,0 +1,83 @@ +/* + * This file contains the glue necessary for support of SGI's Altix chipset. + */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include "altixPCI.h" +#include "xf86.h" +#include "Pci.h" + +void xf86PreScanAltix(void) +{ + /* Nothing to see here... */ +} + +void xf86PostScanAltix(void) +{ + pciConfigPtr *pdev; + int idx, free_idx; + + /* + * Some altix pci chipsets do not expose themselves as host + * bridges. + * + * Walk the devices looking for buses for which there is not a + * corresponding pciDevice entry (ie. pciBusInfo[]->bridge is NULL). + * + * It is assumed that this indicates a root bridge for which we will + * construct a fake pci host bridge device. + */ + + pdev = xf86scanpci(0); + for (idx = 0; pdev[idx] != NULL; idx++) + ; + + free_idx = idx; + + for (idx = 0; idx < free_idx; idx++) { + pciConfigPtr dev, fakedev; + pciBusInfo_t *businfo; + + dev = pdev[idx]; + businfo = pciBusInfo[dev->busnum]; + + if (! businfo) { + /* device has no bus ... should this be an error? */ + continue; + } + + if (businfo->bridge) { + /* bus has a device ... no need for fixup */ + continue; + } + + if (free_idx >= MAX_PCI_DEVICES) + FatalError("SN: No room for fake root bridge device\n"); + + /* + * Construct a fake device and stick it at the end of the + * pdev array. Make it look like a host bridge. + */ + fakedev = xnfcalloc(1, sizeof(pciDevice)); + fakedev->tag = PCI_MAKE_TAG(dev->busnum, 0, 0);; + fakedev->busnum = dev->busnum; + fakedev->devnum = 0; + fakedev->funcnum = 0; + fakedev->fakeDevice = 1; + /* should figure out a better DEVID */ + fakedev->pci_device_vendor = DEVID(VENDOR_GENERIC, CHIP_VGA); + fakedev->pci_base_class = PCI_CLASS_BRIDGE; + + businfo->secondary = 0; + businfo->primary_bus = dev->busnum; + businfo->bridge = fakedev; + + fakedev->businfo = businfo; + + pdev[free_idx++] = fakedev; + } +} --- xorg-server-1.4.99.906.orig/hw/xfree86/os-support/bus/460gxPCI.c +++ xorg-server-1.4.99.906/hw/xfree86/os-support/bus/460gxPCI.c @@ -0,0 +1,469 @@ +/* + * Copyright (C) 2002-2003 The XFree86 Project, Inc. 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, 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 THE + * XFREE86 PROJECT 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 XFree86 Project 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 + * XFree86 Project. + */ + +/* + * This file contains the glue necessary for support of Intel's 460GX chipset. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "460gxPCI.h" +#include "xf86.h" +#include "Pci.h" + +/* 460GX register definitions */ +/* SAC at 0:10:0 */ +#define CBN 0x0040 +/* SAC at CBN:0:0 */ +#define DEVNPRES 0x0070 +/* SAC at CBN:1[0-7]:0 */ +#define BUSNO 0x0048 +#define SUBNO 0x0049 +#define VGASE 0x0080 +#define PCIS 0x0084 +#define IOR 0x008C +#define IORD 0x008E /* CBN:10:0 only */ +/* PXB at CBN:1[0-7]:1 */ +#define ERRCMD 0x0046 + +static int cbn_460gx = -1; +static CARD32 cbdevs_460gx = 0; +static CARD16 iord_460gx; +static int busno_460gx[8], subno_460gx[8]; +static CARD8 pcis_460gx[8], ior_460gx[8]; +static CARD8 has_err_460gx[8], err_460gx[8]; +static CARD8 iomap_460gx[16]; /* One for each 4k */ +static pciBusFuncs_t BusFuncs_460gx; + +static pciConfigPtr +Verify460GXBus(int bus) +{ + pciConfigPtr pPCI; + + if ((bus < 0) || (bus >= pciNumBuses) || + !pciBusInfo[bus] || !(pPCI = pciBusInfo[bus]->bridge) || + (pPCI->busnum != cbn_460gx) || (pPCI->funcnum != 0) || + (pPCI->devnum < 0x10) || (pPCI->devnum > 0x17)) + return NULL; + + return pPCI; +} + +/* + * This function is called to emulate the various settings in a P2P or CardBus + * bridge's control register using one of a 460GX's SAC host bridges. + */ +static CARD16 +Control460GXBridge(int bus, CARD16 mask, CARD16 value) +{ + pciConfigPtr pPCI; + PCITAG tag; + CARD16 current = 0; + CARD8 tmp; + + if ((pPCI = Verify460GXBus(bus))) { + /* Start with VGA enablement */ + tmp = pciReadByte(pPCI->tag, VGASE); + if (tmp & 0x01) { + current |= PCI_PCI_BRIDGE_VGA_EN; + if ((mask & PCI_PCI_BRIDGE_VGA_EN) && + !(value & PCI_PCI_BRIDGE_VGA_EN)) + pciWriteByte(pPCI->tag, VGASE, tmp & ~0x01); + } else { + if (mask & value & PCI_PCI_BRIDGE_VGA_EN) + pciWriteByte(pPCI->tag, VGASE, tmp | 0x01); + } + + /* Move on to master abort failure enablement */ + if (has_err_460gx[pPCI->devnum - 0x10]) { + tag = PCI_MAKE_TAG(pPCI->busnum, pPCI->devnum, pPCI->funcnum + 1); + tmp = pciReadByte(tag, ERRCMD); + if (tmp & 0x01) { + current |= PCI_PCI_BRIDGE_MASTER_ABORT_EN; + if ((mask & PCI_PCI_BRIDGE_MASTER_ABORT_EN) && + !(value & PCI_PCI_BRIDGE_MASTER_ABORT_EN)) + pciWriteByte(tag, ERRCMD, tmp & ~0x01); + } else { + if (mask & value & PCI_PCI_BRIDGE_MASTER_ABORT_EN) + pciWriteByte(tag, ERRCMD, tmp | 0x01); + } + } + + /* Put emulation of any other P2P bridge control here */ + } + + return (current & ~mask) | (value & mask); +} + +/* + * Retrieve various bus numbers representing the connections provided by 460GX + * host bridges. + */ +static void +Get460GXBridgeBuses(int bus, int *primary, int *secondary, int *subordinate) +{ + pciConfigPtr pPCI = Verify460GXBus(bus); + int i; + + /* The returned bus numbers are initialised by the caller */ + + if (!pPCI) + return; + + i = pPCI->devnum - 0x10; + + /* These are not modified, so no need to re-read them */ + if (primary) + *primary = pPCI->busnum; + if (secondary) + *secondary = busno_460gx[i]; + if (subordinate) + *subordinate = subno_460gx[i]; +} + +/* Retrieves a list of the resources routed to a host bridge's secondary bus */ +static void +Get460GXBridgeResources(int bus, + pointer *ppIoRes, + pointer *ppMemRes, + pointer *ppPmemRes) +{ + pciConfigPtr pPCI = Verify460GXBus(bus); + resRange range; + unsigned int i, j; + + if (ppIoRes) { + xf86FreeResList(*ppIoRes); + *ppIoRes = NULL; + + if (pPCI) { + for (i = 0; i <= 0x0F; i++) { + if (iomap_460gx[i] != pPCI->devnum) + continue; + + RANGE(range, i << 12, ((i + 1) << 12) - 1, + RANGE_TYPE(ResExcIoBlock, 0)); + *ppIoRes = xf86AddResToList(*ppIoRes, &range, -1); + } + } + } + + if (ppMemRes) { + xf86FreeResList(*ppMemRes); + *ppMemRes = NULL; + + if (pPCI) { + if (!(i = (pPCI->devnum - 0x10))) + j = 127; /* (4GB - 32M) / 32M */ + else + j = pcis_460gx[i - 1] & 0x7F; + + i = pcis_460gx[i] & 0x7F; + if (i < j) { + RANGE(range, i << 25, (j << 25) - 1, + RANGE_TYPE(ResExcMemBlock, 0)); + *ppMemRes = xf86AddResToList(*ppMemRes, &range, -1); + } + } + } + + if (ppPmemRes) { + xf86FreeResList(*ppPmemRes); + *ppPmemRes = NULL; + } +} + +/* + * This checks for, and validates, the presence of the 460GX chipset, and sets + * cbn_460gx to a positive value accordingly. This function returns TRUE if + * the chipset scan is to be stopped, or FALSE if the scan is to move on to the + * next chipset. + */ + +Bool +xorgProbe460GX(scanpciWrapperOpt flags) +{ + pciBusInfo_t *pBusInfo; + PCITAG tag; + + /* Bus zero should already be set up */ + if (!(pBusInfo = pciBusInfo[0])) { + cbn_460gx = -1; + return FALSE; + } + /* First look for a 460GX's primary host bridge */ + tag = PCI_MAKE_TAG(0, 0x10, 0); + if (pciReadLong(tag, PCI_ID_REG) == DEVID(VENDOR_INTEL, CHIP_460GX_SAC)) { + return TRUE; + } + + cbn_460gx = -1; + + return FALSE; +} + +void +xf86PreScan460GX(void) +{ + pciBusInfo_t *pBusInfo; + PCITAG tag; + CARD32 tmp; + int i, devno; + + if (!(pBusInfo = pciBusInfo[0])) + return; + + /* Get CBN (Chipset bus number) */ + tag = PCI_MAKE_TAG(0, 0x10, 0); + if (!(cbn_460gx = (unsigned int)pciReadByte(tag, CBN))) { + /* Sanity check failed */ + cbn_460gx = -1; + return; + } + + if (pciNumBuses <= cbn_460gx) + pciNumBuses = cbn_460gx + 1; + + /* Set up bus CBN */ + if (!pciBusInfo[cbn_460gx]) { + pciBusInfo[cbn_460gx] = xnfalloc(sizeof(pciBusInfo_t)); + *pciBusInfo[cbn_460gx] = *pBusInfo; + } + + tag = PCI_MAKE_TAG(cbn_460gx, 0, 0); + if (pciReadLong(tag, PCI_ID_REG) != DEVID(VENDOR_INTEL, CHIP_460GX_SAC)) { + /* Sanity check failed */ + cbn_460gx = -1; + return; + } + + /* + * Find out which CBN devices the firmware thinks are present. Of these, + * we are only interested in devices 0x10 through 0x17. + */ + cbdevs_460gx = pciReadLong(tag, DEVNPRES); + + for (i = 0, devno = 0x10; devno <= 0x17; i++, devno++) { + tag = PCI_MAKE_TAG(cbn_460gx, devno, 0); + if (pciReadLong(tag, PCI_ID_REG) != + DEVID(VENDOR_INTEL, CHIP_460GX_SAC)) { + /* Sanity check failed */ + cbn_460gx = -1; + return; + } + + if (devno == 0x10) + iord_460gx = pciReadWord(tag, IORD); + + busno_460gx[i] = (unsigned int)pciReadByte(tag, BUSNO); + subno_460gx[i] = (unsigned int)pciReadByte(tag, SUBNO); + pcis_460gx[i] = pciReadByte(tag, PCIS); + ior_460gx[i] = pciReadByte(tag, IOR); + + has_err_460gx[i] = err_460gx[i] = 0; /* Insurance */ + + tag = PCI_MAKE_TAG(cbn_460gx, devno, 1); + tmp = pciReadLong(tag, PCI_ID_REG); + switch (tmp) { + case DEVID(VENDOR_INTEL, CHIP_460GX_PXB): + case DEVID(VENDOR_INTEL, CHIP_460GX_WXB): + if (cbdevs_460gx & (1 << devno)) { + /* Sanity check failed */ + cbn_460gx = -1; + return; + } + + /* + * XXX I don't have WXB docs, but PCI register dumps indicate that + * the registers we are interested in are consistent with those of + * the PXB. + */ + err_460gx[i] = pciReadByte(tag, ERRCMD); + has_err_460gx[i] = 1; + break; + + case DEVID(VENDOR_INTEL, CHIP_460GX_GXB_1): + if (cbdevs_460gx & (1 << devno)) { + /* Sanity check failed */ + cbn_460gx = -1; + return; + } + + /* + * XXX GXB isn't documented to have an ERRCMD register, nor any + * other means of failing master aborts. For now, assume master + * aborts are always allowed to complete normally. + */ + break; + + default: + if (((CARD16)(tmp + 1U) <= (CARD16)1U) && + (cbdevs_460gx & (1U << devno))) + break; + /* Sanity check failed */ + cbn_460gx = -1; + return; + } + } + + /* Allow master aborts to complete normally */ + for (i = 0, devno = 0x10; devno <= 0x17; i++, devno++) { + if (!(err_460gx[i] & 0x01)) + continue; + + pciWriteByte(PCI_MAKE_TAG(cbn_460gx, devno, 1), + ERRCMD, err_460gx[i] & ~0x01); + } + + /* + * The 460GX spec says that any access to buses higher than CBN will be + * master-aborted. It seems possible however that this is not the case in + * all 460GX implementations. For now, limit the bus scan to CBN, unless + * we have already found a higher bus number. + */ + for (i = 0; subno_460gx[i] < cbn_460gx; ) { + if (++i < 8) + continue; + + pciMaxBusNum = cbn_460gx + 1; + break; + } + + return; +} + +/* This does some 460GX-related processing after the PCI bus scan */ +void +xf86PostScan460GX(void) +{ + pciConfigPtr pPCI, *ppPCI; + pciBusInfo_t *pBusInfo; + int i, j, devno; + + if (cbn_460gx <= 0) + return; + + /* Set up our extra bus functions */ + BusFuncs_460gx = *(pciBusInfo[0]->funcs); + BusFuncs_460gx.pciControlBridge = Control460GXBridge; + BusFuncs_460gx.pciGetBridgeBuses = Get460GXBridgeBuses; + BusFuncs_460gx.pciGetBridgeResources = Get460GXBridgeResources; + + /* + * Mark all host bridges so that they are ignored by the upper-level + * xf86GetPciBridgeInfo() function. This marking is later clobbered by the + * tail end of xf86scanpci() for those bridges that actually have bus + * segments associated with them. + */ + ppPCI = xf86scanpci(0); /* Recursion is only apparent */ + while ((pPCI = *ppPCI++)) { + if ((pPCI->pci_base_class == PCI_CLASS_BRIDGE) && + (pPCI->pci_sub_class == PCI_SUBCLASS_BRIDGE_HOST)) + pPCI->businfo = HOST_NO_BUS; + } + + ppPCI = xf86scanpci(0); /* Recursion is only apparent */ + j = 0; + + /* + * Fix up CBN bus linkage. This is somewhat arbitrary. The bridge chosen + * for this must be a CBN device so that bus CBN can be recognised as the + * root segment. It also cannot be any of the bus expanders (devices + * CBN:0x10:0 through CBN:0x17:0 nor any of their functions). For now, we + * chose the SAC host bridge at CBN:0:0. + */ + pBusInfo = pciBusInfo[cbn_460gx]; + pBusInfo->bridge = pciBusInfo[0]->bridge; /* Just in case */ + while ((pPCI = *ppPCI++)) { + if (pPCI->busnum < cbn_460gx) + continue; + if (pPCI->busnum > cbn_460gx) + break; + if (pPCI->devnum < 0) + continue; + if (pPCI->devnum > 0) + break; + if (pPCI->funcnum < 0) + continue; + if (pPCI->funcnum > 0) + break; + + pBusInfo->bridge = pPCI; + pBusInfo->secondary = FALSE; + pBusInfo->primary_bus = cbn_460gx; + break; + } + + for (i = 0, devno = 0x10; devno <= 0x17; i++, devno++) { + /* Restore ERRCMD registers */ + if (err_460gx[i] & 0x01) + pciWriteByte(PCI_MAKE_TAG(cbn_460gx, devno, 1), + ERRCMD, err_460gx[i]); + + if (!(cbdevs_460gx & (1 << devno))) { + while ((pPCI = *ppPCI++)) { + if (pPCI->busnum < cbn_460gx) + continue; + if (pPCI->busnum > cbn_460gx) + break; + if (pPCI->devnum < devno) + continue; + if (pPCI->devnum > devno) + break; + if (pPCI->funcnum < 0) + continue; + if (pPCI->funcnum > 0) + break; + + if ((pBusInfo == pciBusInfo[busno_460gx[i]])) + break; + + /* Fix bus linkage */ + pBusInfo->bridge = pPCI; + pBusInfo->secondary = TRUE; + pBusInfo->primary_bus = cbn_460gx; + + /* Plug in chipset routines */ + pBusInfo->funcs = &BusFuncs_460gx; + break; + } + } + + /* Decode IOR registers */ + for(; j <= (ior_460gx[i] & 0x0F); j++) + iomap_460gx[j] = devno; + } + + /* The bottom 4k of I/O space is always routed to PCI0a */ + iomap_460gx[0] = 0x10; + + /* Decode IORD register */ + for (j = 1; j <= 0x0F; j++) + if (iord_460gx & (1 << j)) + iomap_460gx[j] = 0x10; +} --- xorg-server-1.4.99.906.orig/hw/xfree86/os-support/bus/e8870PCI.c +++ xorg-server-1.4.99.906/hw/xfree86/os-support/bus/e8870PCI.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2002-2003 The XFree86 Project, Inc. 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, 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 THE + * XFREE86 PROJECT 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 XFree86 Project 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 + * XFree86 Project. + */ + +/* + * This file contains the glue necessary for support of Intel's E8870 chipset. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "e8870PCI.h" +#include "xf86.h" +#include "Pci.h" + +Bool +xorgProbeE8870(scanpciWrapperOpt flags) +{ + PCITAG tag; + + /* Look for an E8870's Hub interface */ + tag = PCI_MAKE_TAG(0, 0x1E, 0); + if (pciReadLong(tag, PCI_ID_REG) == DEVID(VENDOR_INTEL, CHIP_82801_P2P)) + return TRUE; + + return FALSE; +} + +void +xf86PreScanE8870(void) +{ + /* XXX Fill me in... */ + return; +} + +void +xf86PostScanE8870(void) +{ + /* XXX Fill me in... */ +} --- xorg-server-1.4.99.906.orig/hw/xfree86/os-support/bus/zx1PCI.c +++ xorg-server-1.4.99.906/hw/xfree86/os-support/bus/zx1PCI.c @@ -0,0 +1,1140 @@ +/* + * Copyright (C) 2002-2003 The XFree86 Project, Inc. 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, 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 THE + * XFREE86 PROJECT 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 XFree86 Project 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 + * XFree86 Project. + */ + +/* + * This file contains the glue necessary for support of HP's ZX1 chipset. + * Keep in mind that this chipset is used in both Itanium2 and PA-RISC + * architectures. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "zx1PCI.h" +#include "xf86.h" +#include "xf86_OSlib.h" +#include "Pci.h" + +#define MIO_BASE 0xFED00000UL /* mio register base */ +#define MIO_SIZE 0x00002000UL /* 8k, minimum */ + +/* ZX1 mio register definitions */ +#define MIO_FUNCTION0 0x0000U + +#define MODULE_INFO 0x0100U +#define STATUS_CONTROL 0x0108U +#define DILLON_PRESENT 0x02UL + +#define LMMIO_DIR_BASE0 0x0300U +#define LMMIO_DIR_MASK0 0x0308U +#define LMMIO_DIR_ROUTE0 0x0310U +#define LMMIO_DIR_BASE1 0x0318U +#define LMMIO_DIR_MASK1 0x0320U +#define LMMIO_DIR_ROUTE1 0x0328U +#define LMMIO_DIR_BASE2 0x0330U +#define LMMIO_DIR_MASK2 0x0338U +#define LMMIO_DIR_ROUTE2 0x0340U +#define LMMIO_DIR_BASE3 0x0348U +#define LMMIO_DIR_MASK3 0x0350U +#define LMMIO_DIR_ROUTE3 0x0358U +#define LMMIO_DIST_BASE 0x0360U +#define LMMIO_DIST_MASK 0x0368U +#define LMMIO_DIST_ROUTE 0x0370U +#define GMMIO_DIST_BASE 0x0378U +#define PORT_DISABLE 0x02UL +#define MAP_TO_LMMIO 0x04UL +#define GMMIO_DIST_MASK 0x0380U +#define GMMIO_DIST_ROUTE 0x0388U +#define IOS_DIST_BASE 0x0390U +#define IOS_DIST_MASK 0x0398U +#define IOS_DIST_ROUTE 0x03A0U +#define ROPE_CONFIG_BASE 0x03A8U +#define VGA_ROUTE 0x03B0U +#define VGA_ENABLE 0x8000000000000000UL +#define VGA_LIGHT 0x4000000000000000UL + +#define IOS_DIR_BASE 0x03C0U +#define IOS_DIR_MASK 0x03C8U +#define IOS_DIR_ROUTE 0x03D0U +#define IOS_BASE 0x03D8U + +#define MIO_FUNCTION1 0x1000U + +#define ROPE_CONFIG 0x1040U +#define ROPE_D0 0x0100UL +#define ROPE_D2 0x0200UL +#define ROPE_D4 0x0400UL +#define ROPE_D6 0x0800UL +#define ROPE_Q0 0x1000UL +#define ROPE_Q4 0x2000UL + +#define LBA_PORT0_CNTRL 0x1200U +#define LBA_PORT1_CNTRL 0x1208U +#define LBA_PORT2_CNTRL 0x1210U +#define LBA_PORT3_CNTRL 0x1218U +#define LBA_PORT4_CNTRL 0x1220U +#define LBA_PORT5_CNTRL 0x1228U +#define LBA_PORT6_CNTRL 0x1230U +#define LBA_PORT7_CNTRL 0x1238U +#define LBA_RESET_FUNCTION 0x0000000001UL +#define LBA_CLEAR_ERROR 0x0000000010UL +#define LBA_HARD_FAIL 0x0000000040UL +#define LBA_RESET_COMPLETE 0x0100000000UL +#define LBA_RESET_TIMEOUT 0x0200000000UL + +#define ROPE_PAGE_CONTROL 0x1418U + +/* + * Total ioa configuration space size is actually 128k, but we only need the + * first 64k. + */ +#define IOA_SIZE 0x00010000UL + +/* ZX1 ioa register definitions */ +#define IOA_CONFIG_ADDR 0x0040U +#define IOA_CONFIG_DATA 0x0048U + +#define IOA_SECONDARY_BUS 0x0058U +#define IOA_SUBORDINATE_BUS 0x0059U + +#define IOA_CONTROL 0x0108U +#define IOA_RESET_FUNCTION 0x0000000001UL +#define IOA_FORWARD_VGA 0x0000000008UL +#define IOA_CLEAR_ERROR 0x0000000010UL +#define IOA_HARD_FAIL 0x0000000040UL +#define IOA_RESET_COMPLETE 0x0100000000UL + +#define IOA_LMMIO_BASE 0x0200U +#define IOA_LMMIO_MASK 0x0208U +#define IOA_GMMIO_BASE 0x0210U +#define IOA_GMMIO_MASK 0x0218U +#define IOA_WLMMIO_BASE 0x0220U +#define IOA_WLMMIO_MASK 0x0228U +#define IOA_WGMMIO_BASE 0x0230U +#define IOA_WGMMIO_MASK 0x0238U +#define IOA_IOS_BASE 0x0240U +#define IOA_IOS_MASK 0x0248U +#define IOA_ELMMIO_BASE 0x0250U +#define IOA_ELMMIO_MASK 0x0258U +#define IOA_EIOS_BASE 0x0260U +#define IOA_EIOS_MASK 0x0268U +#define IOA_GLOBAL_MASK 0x0270U +#define IOA_SLAVE_CONTROL 0x0278U +#define IOA_VGA_PEER_ENABLE 0x2000UL +#define IOA_MSI_BASE 0x0280U +#define IOA_MSI_MASK 0x0288U + +#define IOA_DMA_BASE 0x02B0U +#define IOA_DMA_MASK 0x02B8U + +#define IOA_ERROR_CONFIG 0x0680U +#define IOA_ERROR_PIOWRITE 0x0001UL +#define IOA_ERROR_PIOREAD 0x0002UL +#define IOA_ERROR_DMAWRITE 0x0004UL +#define IOA_ERROR_DMAREAD 0x0008UL +#define IOA_ERROR_CONFIG_MASTER 0x0010UL +#define IOA_ERROR_SMART 0x0020UL +#define IOA_ERROR_FATAL_SERR 0x0040UL +#define IOA_ERROR_ASSERT_SERR 0x0080UL +/* ? 0x0100UL */ +#define IOA_ERROR_LOOPBACK 0x0200UL +#define IOA_ERROR_CONFIG_TARGET 0x0400UL +#define IOA_ERROR_IO_MASTER 0x0800UL +#define IOA_ERROR_IO_TARGET 0x1000UL +#define IOA_ERROR_MEM_MASTER 0x2000UL +#define IOA_ERROR_MEM_TARGET 0x4000UL +#define IOA_ERROR_HF_IO_FATAL 0x8000UL + +#define RANGE_ENABLE 0x01UL /* In various base registers */ + +#define IO_MASK ((1UL << 16) - 1UL) +#define LMMIO_MASK ((1UL << 32) - 1UL) +#ifdef __ia64__ +#define GMMIO_MASK ((1UL << 44) - 1UL) +#else /* PA-RISC */ +#define GMMIO_MASK ((1UL << 40) - 1UL) +#endif + +#define PDH_START 0xFF000000UL +#define PDH_LAST 0xFFFFFFFFUL + +static CARD8 *pZX1mio = NULL, + *pZX1ioa = NULL; + +/* Per-rope data */ +static INT8 zx1_ropemap[8]; +static CARD32 zx1_pciids[8]; +static CARD64 zx1_lbacntl[8]; +static int zx1_busno[8], zx1_subno[8]; + +/* Array of Booleans for non-empty buses */ +static INT8 zx1_busnmpt[MAX_PCI_BUSES]; + +static pciBusFuncs_t zx1BusFuncs; +static int zx1_fakebus = -1; +static Bool zx1_hasvga = FALSE; + +static pointer pZX1IoRes[8], pZX1MemRes[8]; /* Rope resources */ + +/* Non-PCI configuration space access macros */ +#define MIO_BYTE(offset) \ + (*(volatile CARD8 *)(pointer)(pZX1mio + (offset))) +#define MIO_WORD(offset) \ + (*(volatile CARD16 *)(pointer)(pZX1mio + (offset))) +#define MIO_LONG(offset) \ + (*(volatile CARD32 *)(pointer)(pZX1mio + (offset))) +#define MIO_QUAD(offset) \ + (*(volatile CARD64 *)(pointer)(pZX1mio + (offset))) +#define IOA_BYTE(ioa, offset) \ + (*(volatile CARD8 *)(pointer)(pZX1ioa + ((offset) + ((ioa) << 13)))) +#define IOA_WORD(ioa, offset) \ + (*(volatile CARD16 *)(pointer)(pZX1ioa + ((offset) + ((ioa) << 13)))) +#define IOA_LONG(ioa, offset) \ + (*(volatile CARD32 *)(pointer)(pZX1ioa + ((offset) + ((ioa) << 13)))) +#define IOA_QUAD(ioa, offset) \ + (*(volatile CARD64 *)(pointer)(pZX1ioa + ((offset) + ((ioa) << 13)))) + +/* Range definitions */ +#define MAX_RANGE 16 +static CARD64 bot[MAX_RANGE], top[MAX_RANGE], msk[MAX_RANGE], siz[MAX_RANGE]; +static INT8 *pDecode[MAX_RANGE]; +static int nRange = 0; + +/* Track a resource range and assign a granularity to it */ +static void +SetRange(CARD64 base, CARD64 last, CARD8 width) +{ + int i; + + bot[nRange] = base; + top[nRange] = last; + msk[nRange] = (CARD64)(-1L); + if (base) + msk[nRange] &= (base ^ (base - 1UL)) >> 1; + if (last + 1UL) + msk[nRange] &= (last ^ (last + 1UL)) >> 1; + if (width < 64) + msk[nRange] &= (1UL << width) - 1UL; + + /* Look for overlapping ranges */ + for (i = 0; i < nRange; i++) { + if ((bot[i] > top[i]) || + (top[nRange] < bot[i]) || + (top[i] < bot[nRange])) + continue; + + /* Merge in overlapping range */ + if (bot[nRange] > bot[i]) + bot[nRange] = bot[i]; + if (top[nRange] < top[i]) + top[nRange] = top[i]; + + /* Assign finer granularity */ + msk[nRange] &= msk[i]; + bot[i] = 1UL; + top[i] = 0; + } + + nRange++; +} + +/* Lookup granularity associated with the range containing 'base' */ +static int +GetRange(CARD64 base) +{ + int i; + + for (i = 0; i < nRange; i++) { + if ((bot[i] > top[i]) || + (base < bot[i]) || + (base > top[i])) + continue; + + if (pDecode[i]) + break; + + /* Allocate decoding array */ + msk[i]++; + siz[i] = ((top[i] - bot[i] + 1UL) / msk[i]) + 1UL; + pDecode[i] = xnfalloc(siz[i]); + (void)memset(pDecode[i], -1, siz[i]); + break; + } + + return i; +} + +/* + * Verify that 'bus' is a rope's secondary bus and return the pciConfigPtr of + * the associated fake PCI-to-PCI bridge. + */ +static pciConfigPtr +VerifyZX1Bus(int bus) +{ + pciConfigPtr pPCI; + + if ((bus < 0) || (bus >= pciNumBuses) || + !pciBusInfo[bus] || !(pPCI = pciBusInfo[bus]->bridge) || + (pPCI->busnum != zx1_fakebus) || (pPCI->funcnum != 0) || + (pPCI->devnum < 0x10) || (pPCI->devnum > 0x17)) + return NULL; + + return pPCI; +} + +/* + * This function is called to emulate the various settings in a P2P or CardBus + * bridge's control register on a ZX1-based system. + */ +static CARD16 +ControlZX1Bridge(int bus, CARD16 mask, CARD16 value) +{ + pciConfigPtr pPCI; + CARD64 tmp1, tmp2, tmp3, ropenum; + CARD16 current = 0; + + if ((pPCI = VerifyZX1Bus(bus))) { + ropenum = pPCI->devnum & 0x07; + + /* + * Start with VGA enablement. This preserves the "VGA-lite" bit + * in mio's VGA_ROUTE register, and the VPE bit in each ioa's + * SLAVE_CONTROL register. + */ + tmp1 = MIO_QUAD(VGA_ROUTE); + tmp2 = IOA_QUAD(ropenum, IOA_CONTROL) & + ~(IOA_RESET_FUNCTION | IOA_CLEAR_ERROR); + if ((tmp1 & VGA_ENABLE) && ((tmp1 & 0x07UL) == ropenum)) { + current |= PCI_PCI_BRIDGE_VGA_EN; + if ((mask & PCI_PCI_BRIDGE_VGA_EN) && + !(value & PCI_PCI_BRIDGE_VGA_EN)) { + MIO_QUAD(VGA_ROUTE) = tmp1 & ~VGA_ENABLE; + tmp2 &= ~IOA_FORWARD_VGA; + IOA_QUAD(ropenum, IOA_CONTROL) = tmp2; + } + } else if (mask & value & PCI_PCI_BRIDGE_VGA_EN) { + if (!zx1_hasvga) { + xf86MsgVerb(X_WARNING, 3, + "HP ZX1: Attempt to enable VGA routing to bus %d" + " through rope %ld disallowed\n", bus, ropenum); + value &= ~PCI_PCI_BRIDGE_VGA_EN; + } else { + if (tmp1 & VGA_ENABLE) { + /* + * VGA is routed somewhere else. Disable it. + */ + MIO_QUAD(VGA_ROUTE) = 0UL; + tmp3 = IOA_QUAD(tmp1 & 0x07UL, IOA_CONTROL); + if (tmp3 & IOA_FORWARD_VGA) + IOA_QUAD(tmp1 & 0x07UL, IOA_CONTROL) = tmp3 & + ~(IOA_RESET_FUNCTION | IOA_FORWARD_VGA | + IOA_CLEAR_ERROR); + } + if (!(tmp2 & IOA_FORWARD_VGA)) { + tmp2 |= IOA_FORWARD_VGA; + IOA_QUAD(ropenum, IOA_CONTROL) = tmp2; + } + tmp1 = (tmp1 & ~0x07UL) | ropenum | VGA_ENABLE; + MIO_QUAD(VGA_ROUTE) = tmp1; + } + } + + /* Move on to master abort failure enablement */ + tmp1 = MIO_QUAD((ropenum << 3) + LBA_PORT0_CNTRL) & + ~(LBA_RESET_FUNCTION | LBA_CLEAR_ERROR); + if ((tmp1 & LBA_HARD_FAIL) || (tmp2 & IOA_HARD_FAIL)) { + current |= PCI_PCI_BRIDGE_MASTER_ABORT_EN; + if ((mask & PCI_PCI_BRIDGE_MASTER_ABORT_EN) && + !(value & PCI_PCI_BRIDGE_MASTER_ABORT_EN)) { + if (tmp1 & LBA_HARD_FAIL) + MIO_QUAD((ropenum << 3) + LBA_PORT0_CNTRL) = + tmp1 & ~LBA_HARD_FAIL; + if (tmp2 & IOA_HARD_FAIL) { + tmp2 &= ~IOA_HARD_FAIL; + IOA_QUAD(ropenum, IOA_CONTROL) = tmp2; + } + } + } else { + if (mask & value & PCI_PCI_BRIDGE_MASTER_ABORT_EN) { + if (!(tmp1 & LBA_HARD_FAIL)) + MIO_QUAD((ropenum << 3) + LBA_PORT0_CNTRL) = + tmp1 | LBA_HARD_FAIL; + if (!(tmp2 & IOA_HARD_FAIL)) { + tmp2 |= IOA_HARD_FAIL; + IOA_QUAD(ropenum, IOA_CONTROL) = tmp2; + } + } + } + + /* Put emulation of any other P2P bridge control here */ + } + + return (current & ~mask) | (value & mask); +} + +/* Retrieves a list of the resources routed to a rope's secondary bus */ +static void +GetZX1BridgeResources(int bus, + pointer *ppIoRes, + pointer *ppMemRes, + pointer *ppPmemRes) +{ + pciConfigPtr pPCI = VerifyZX1Bus(bus); + + if (ppIoRes) { + xf86FreeResList(*ppIoRes); + *ppIoRes = + pPCI ? xf86DupResList(pZX1IoRes[pPCI->devnum & 0x07]) : NULL; + } + + if (ppMemRes) { + xf86FreeResList(*ppMemRes); + *ppMemRes = + pPCI ? xf86DupResList(pZX1MemRes[pPCI->devnum & 0x07]) : NULL; + } + + if (ppPmemRes) { + xf86FreeResList(*ppPmemRes); + *ppPmemRes = NULL; + } +} + +/* The fake bus */ +static CARD32 +zx1FakeReadLong(PCITAG tag, int offset) +{ + FatalError("zx1FakeReadLong(0x%lX, 0x%X) called\n", + (unsigned long)tag, offset); +} + +static void +zx1FakeWriteLong(PCITAG tag, int offset, CARD32 val) +{ + FatalError("zx1FakeWriteLong(0x%lX, 0x%X, 0x%08X) called\n", + (unsigned long)tag, offset, val); +} + +static void +zx1FakeSetBits(PCITAG tag, int offset, CARD32 mask, CARD32 bits) +{ + CARD32 val; + + val = zx1FakeReadLong(tag, offset); + val &= ~mask; + val |= bits; + zx1FakeWriteLong(tag, offset, val); +} + +static pciBusFuncs_t zx1FakeBusFuncs = { + zx1FakeReadLong, + zx1FakeWriteLong, + zx1FakeSetBits +}; + +static pciBusInfo_t zx1FakeBus = { + 0, /* configMech -- copied from bus 0 */ + 0, /* numDevices -- copied from bus 0 */ + FALSE, /* secondary */ + 0, /* primary_bus -- dynamically set */ + &zx1FakeBusFuncs, /* funcs */ + NULL, /* pciBusPriv -- none */ + NULL, /* bridge -- dynamically set */ +}; + +void +xf86PreScanZX1(void) +{ + resRange range; + unsigned long mapSize = getpagesize(); + unsigned long tmp, base, ioaaddr; + unsigned long flagsd, based, lastd, maskd, routed; + unsigned long flags0, base0, last0, mask0, route0; + unsigned long flags1, base1, last1, mask1, route1; + unsigned long flags2, base2, last2, mask2, route2; + unsigned long flags3, base3, last3, mask3, route3; + unsigned long flagsg, baseg, lastg, maskg, routeg; + unsigned long flagsl, basel, lastl; + int i, rope; + + /* Map mio registers (minimum 8k) */ + if (mapSize < MIO_SIZE) + mapSize = MIO_SIZE; + + if (!(pZX1mio = xf86MapVidMem(-1, VIDMEM_MMIO, MIO_BASE, mapSize))) + return; + + /* Look for ZX1's SBA and IOC */ + if (((MIO_LONG(MIO_FUNCTION0 + PCI_ID_REG) != + DEVID(VENDOR_HP, CHIP_ZX1_SBA)) || + (MIO_LONG(MIO_FUNCTION1 + PCI_ID_REG) != + DEVID(VENDOR_HP, CHIP_ZX1_IOC))) && + ((MIO_LONG(MIO_FUNCTION0 + PCI_ID_REG) != + DEVID(VENDOR_HP, CHIP_ZX2_SBA)) || + (MIO_LONG(MIO_FUNCTION1 + PCI_ID_REG) != + DEVID(VENDOR_HP, CHIP_ZX2_IOC)))) { + xf86UnMapVidMem(-1, pZX1mio, mapSize); + pZX1mio = NULL; + return; + } + + /* Map rope configuration space */ + ioaaddr = MIO_QUAD(ROPE_CONFIG_BASE); + if (!(ioaaddr & RANGE_ENABLE) || /* No ropes */ + ((ioaaddr = ioaaddr & ~RANGE_ENABLE) & 0x01FFFFUL) || /* Not aligned */ + !(pZX1ioa = xf86MapVidMem(-1, VIDMEM_MMIO, ioaaddr, IOA_SIZE))) { + xf86UnMapVidMem(-1, pZX1mio, mapSize); + pZX1mio = NULL; + return; + } + + for (i = 0; i < 8; i++) { + zx1_ropemap[i] = i; + zx1_lbacntl[i] = 0; + xf86FreeResList(pZX1IoRes[i]); + xf86FreeResList(pZX1MemRes[i]); + pZX1IoRes[i] = pZX1MemRes[i] = NULL; + } + + /* + * Determine which of 8 possible ropes exist in the system. This is done + * by looking at their "coupling" to generate a list of candidates, + * whittling this list down by factoring in ROPE_PAGE_CONTROL register + * contents, then poking each candidate's configuration space to determine + * its existence. + */ + tmp = MIO_QUAD(ROPE_CONFIG); + if (tmp & ROPE_D0) + zx1_ropemap[1] = 0; + if (tmp & ROPE_D2) + zx1_ropemap[3] = 2; + if (tmp & ROPE_D4) + zx1_ropemap[5] = 4; + if (tmp & ROPE_D6) + zx1_ropemap[7] = 6; + if (tmp & ROPE_Q0) + zx1_ropemap[1] = zx1_ropemap[2] = zx1_ropemap[3] = 0; + if (tmp & ROPE_Q4) + zx1_ropemap[5] = zx1_ropemap[6] = zx1_ropemap[7] = 4; + + /* + * zx2 should allow better probing support via hard-fails, so no need to + * use the ROPE_PAGE_CONTROL register. Also, zx2 always has ropes 3 & 7 + * active regardless of bundling. + */ + if (MIO_LONG(MIO_FUNCTION0 + PCI_ID_REG) != + DEVID(VENDOR_HP, CHIP_ZX2_SBA)) { + + tmp = MIO_QUAD(ROPE_PAGE_CONTROL); + for (i = 0; i < 8; i++, tmp >>= 8) + if (!(CARD8)tmp) + zx1_ropemap[i] = -1; + } else { + zx1_ropemap[3] = 3; + zx1_ropemap[7] = 7; + } + + for (i = 0; i < 8; ) { + if (zx1_ropemap[i] == i) { + + /* Prevent hard-fails */ + zx1_lbacntl[i] = MIO_QUAD((i << 3) + LBA_PORT0_CNTRL) & + ~(LBA_RESET_FUNCTION | LBA_CLEAR_ERROR); + + if (zx1_lbacntl[i] & LBA_RESET_TIMEOUT) { + /* Ignore this rope and its couplings */ + do { + zx1_ropemap[i++] = -1; + } while ((i < 8) && (zx1_ropemap[i] < i)); + continue; /* Avoid over-incrementing 'i' */ + } + + if (zx1_lbacntl[i] & LBA_HARD_FAIL) + MIO_QUAD((i << 3) + LBA_PORT0_CNTRL) = + zx1_lbacntl[i] & ~LBA_HARD_FAIL; + + /* Poke for an ioa */ + zx1_pciids[i] = IOA_LONG(i, PCI_ID_REG); + switch (zx1_pciids[i]) { + case DEVID(VENDOR_HP, CHIP_ELROY): + case DEVID(VENDOR_HP, CHIP_ZX1_LBA): /* Mercury */ + case DEVID(VENDOR_HP, CHIP_ZX1_AGP8): /* QuickSilver */ + case DEVID(VENDOR_HP, CHIP_ZX2_LBA): + case DEVID(VENDOR_HP, CHIP_ZX2_PCIE): + /* Expected vendor/device IDs */ + zx1_busno[i] = + (unsigned int)IOA_BYTE(i, IOA_SECONDARY_BUS); + zx1_subno[i] = + (unsigned int)IOA_BYTE(i, IOA_SUBORDINATE_BUS); + break; + + default: + if ((CARD16)(zx1_pciids[i] + 1U) > (CARD16)1U) + xf86MsgVerb(X_NOTICE, 0, + "HP ZX1: Unexpected vendor/device id 0x%08X" + " on rope %d\n", zx1_pciids[i], i); + /* Nobody home, or not the "right" kind of rope guest */ + + /* + * Restore hard-fail setting. For "active" ropes, this is done + * later. + */ + if (zx1_lbacntl[i] & LBA_HARD_FAIL) { + MIO_QUAD((i << 3) + LBA_PORT0_CNTRL) = zx1_lbacntl[i]; + zx1_lbacntl[i] = 0; + } + + /* Ignore this rope and its couplings */ + do { + zx1_ropemap[i++] = -1; + } while ((i < 8) && (zx1_ropemap[i] < i)); + continue; /* Avoid over-incrementing 'i' */ + } + } + i++; + } + + /* Determine if VGA is currently routed */ + tmp = MIO_QUAD(VGA_ROUTE); + if (tmp & VGA_ENABLE) + zx1_hasvga = TRUE; + + /* + * Decode mio resource "coarse" routing (i.e. ignoring VGA). Due to the + * rather unusual flexibility of this chipset, this is done in a number of + * stages. For each of I/O and memory, first decode the relevant registers + * to generate ranges with an associated granularity. Overlapping ranges + * are merged into a larger range with the finer granularity. Each + * original range is then more thoroughly decoded using the granularity + * associated with the merged range that contains it. The result is then + * converted into resource lists for the common layer. + * + * Note that this doesn't care whether or not read-only bits are actually + * set as documented, nor that mask bits are contiguous. This does, + * however, factor in upper limits on I/O, LMMIO anf GMMIO addresses, and + * thus assumes high-order address bits are ignored rather than decoded. + * For example, an I/O address of 0x76543210 will be treated as 0x3210 + * rather than considered out-of-range. In part, this handling is a + * consequence of the fact that high-order mask bits are zeroes instead of + * ones. + */ + + flagsd = 0; based = 0; lastd = 0; maskd = 0; routed = 0; + flags0 = 0; base0 = 0; last0 = 0; mask0 = 0; route0 = 0; + flags1 = 0; base1 = 0; last1 = 0; mask1 = 0; route1 = 0; + flags2 = 0; base2 = 0; last2 = 0; mask2 = 0; route2 = 0; + flags3 = 0; base3 = 0; last3 = 0; mask3 = 0; route3 = 0; + flagsg = 0; baseg = 0; lastg = 0; maskg = 0; routeg = 0; + flagsl = 0; basel = 0; lastl = 0; + + if ((tmp = MIO_QUAD(IOS_DIST_BASE)) & RANGE_ENABLE) { + flagsd = RANGE_ENABLE; + maskd = MIO_QUAD(IOS_DIST_MASK); + based = tmp & maskd & (~RANGE_ENABLE & IO_MASK); + lastd = based | (~maskd & IO_MASK); + routed = MIO_QUAD(IOS_DIST_ROUTE) >> 58; + SetRange(based, lastd, routed); + } + + if ((tmp = MIO_QUAD(IOS_DIR_BASE)) & RANGE_ENABLE) { + flags0 = RANGE_ENABLE; + mask0 = MIO_QUAD(IOS_DIR_MASK); + base0 = tmp & mask0 & (~RANGE_ENABLE & IO_MASK); + last0 = base0 | (~mask0 & IO_MASK); + route0 = MIO_QUAD(IOS_DIR_ROUTE) & 0x07U; + SetRange(base0, last0, 64); + } + + if (flagsd) { + i = GetRange(based); + for (tmp = based; tmp <= lastd; tmp += msk[i]) { + if ((tmp & maskd) == based) { + base = (tmp - bot[i]) / msk[i]; + pDecode[i][base] = zx1_ropemap[(tmp >> routed) & 0x07U]; + } + } + + flagsd = 0; + } + + if (flags0) { + i = GetRange(base0); + for (tmp = base0; tmp <= last0; tmp += msk[i]) { + if ((tmp & mask0) == base0) { + base = (tmp - bot[i]) / msk[i]; + pDecode[i][base] = zx1_ropemap[route0]; + } + } + + flags0 = 0; + } + + for (i = 0; i < nRange; i++) { + if (!pDecode[i]) + continue; + + rope = pDecode[i][0]; + for (base = tmp = 0; ++tmp < siz[i]; ) { + if (rope == pDecode[i][tmp]) + continue; + + if (rope >= 0) { + RANGE(range, (base * msk[i]) + bot[i], + (tmp * msk[i]) + bot[i] - 1UL, + RANGE_TYPE(ResExcIoBlock, 0)); + pZX1IoRes[rope] = + xf86AddResToList(pZX1IoRes[rope], &range, -1); + } + + base = tmp; + rope = pDecode[i][base]; + } + + xfree(pDecode[i]); + pDecode[i] = NULL; + } + + nRange = 0; + + /* + * Move on to CPU memory access decoding. For now, don't tell the common + * layer about CPU memory ranges that are either relocated to 0 or + * translated into PCI I/O. + */ + + SetRange(MIO_BASE, MIO_BASE + MIO_SIZE - 1UL, 64); /* mio */ + SetRange(ioaaddr, ioaaddr + ((IOA_SIZE << 1) - 1UL), 64); /* ioa */ + SetRange(PDH_START, PDH_LAST, 64); /* PDH */ + + SetRange(MIO_BASE, LMMIO_MASK, 64); /* Completeness */ + + if ((tmp = MIO_QUAD(LMMIO_DIST_BASE)) & RANGE_ENABLE) { + flagsd = RANGE_ENABLE; + maskd = MIO_QUAD(LMMIO_DIST_MASK); + based = tmp & maskd & (~RANGE_ENABLE & LMMIO_MASK); + lastd = based | (~maskd & LMMIO_MASK); + routed = MIO_QUAD(LMMIO_DIST_ROUTE) >> 58; + SetRange(based, lastd, routed); + } + + if ((tmp = MIO_QUAD(LMMIO_DIR_BASE0)) & RANGE_ENABLE) { + flags0 = RANGE_ENABLE; + mask0 = MIO_QUAD(LMMIO_DIR_MASK0); + base0 = tmp & mask0 & (~RANGE_ENABLE & LMMIO_MASK); + last0 = base0 | (~mask0 & LMMIO_MASK); + route0 = MIO_QUAD(LMMIO_DIR_ROUTE0) & 0x07U; + SetRange(base0, last0, 64); + } + + if ((tmp = MIO_QUAD(LMMIO_DIR_BASE1)) & RANGE_ENABLE) { + flags1 = RANGE_ENABLE; + mask1 = MIO_QUAD(LMMIO_DIR_MASK1); + base1 = tmp & mask1 & (~RANGE_ENABLE & LMMIO_MASK); + last1 = base1 | (~mask1 & LMMIO_MASK); + route1 = MIO_QUAD(LMMIO_DIR_ROUTE1) & 0x07U; + SetRange(base1, last1, 64); + } + + if ((tmp = MIO_QUAD(LMMIO_DIR_BASE2)) & RANGE_ENABLE) { + flags2 = RANGE_ENABLE; + mask2 = MIO_QUAD(LMMIO_DIR_MASK2); + base2 = tmp & mask2 & (~RANGE_ENABLE & LMMIO_MASK); + last2 = base2 | (~mask2 & LMMIO_MASK); + route2 = MIO_QUAD(LMMIO_DIR_ROUTE2) & 0x07U; + SetRange(base2, last2, 64); + } + + if ((tmp = MIO_QUAD(LMMIO_DIR_BASE3)) & RANGE_ENABLE) { + flags3 = RANGE_ENABLE; + mask3 = MIO_QUAD(LMMIO_DIR_MASK3); + base3 = tmp & mask3 & (~RANGE_ENABLE & LMMIO_MASK); + last3 = base3 | (~mask3 & LMMIO_MASK); + route3 = MIO_QUAD(LMMIO_DIR_ROUTE3) & 0x07U; + SetRange(base3, last3, 64); + } + + if ((tmp = MIO_QUAD(GMMIO_DIST_BASE)) & RANGE_ENABLE) { + flagsg = tmp & (RANGE_ENABLE | PORT_DISABLE | MAP_TO_LMMIO); + maskg = MIO_QUAD(GMMIO_DIST_MASK); + baseg = tmp & maskg & + (~(RANGE_ENABLE | PORT_DISABLE | MAP_TO_LMMIO) & GMMIO_MASK); + lastg = baseg | (~maskg & GMMIO_MASK); + tmp = routeg = MIO_QUAD(GMMIO_DIST_ROUTE) >> 58; + if (!(flagsg & (PORT_DISABLE & MAP_TO_LMMIO)) && (tmp > 26)) + tmp = 26; + SetRange(baseg, lastg, tmp); + } + + if ((tmp = MIO_QUAD(IOS_BASE)) & RANGE_ENABLE) { + flagsl = RANGE_ENABLE; + basel = tmp & (~RANGE_ENABLE & GMMIO_MASK); + lastl = basel | 0x001FFFFFUL; + SetRange(basel, lastl, 64); + } + + if (flagsd) { + i = GetRange(based); + for (tmp = based; tmp <= lastd; tmp += msk[i]) { + if ((tmp & maskd) == based) { + base = (tmp - bot[i]) / msk[i]; + pDecode[i][base] = zx1_ropemap[(tmp >> routed) & 0x07U]; + } + } + + flagsd = 0; + } + + /* LMMIO distributed range does not address anything beyond 0xFED00000 */ + i = GetRange(MIO_BASE); + for (tmp = MIO_BASE; tmp <= LMMIO_MASK; tmp += msk[i]) { + base = (tmp - bot[i]) / msk[i]; + pDecode[i][base] = -1; + } + + /* Dillon space can sometimes be redirected to rope 0 */ + tmp = MIO_QUAD(STATUS_CONTROL); + if (!(tmp & DILLON_PRESENT)) { + i = GetRange(PDH_START); + for (tmp = PDH_START; tmp <= PDH_LAST; tmp += msk[i]) { + base = (tmp - bot[i]) / msk[i]; + pDecode[i][base] = zx1_ropemap[0]; + } + } + + if (flagsg) { + unsigned long mask = (0x07UL << routeg) | maskg; + + i = GetRange(baseg); + for (tmp = baseg; tmp <= lastg; tmp += msk[i]) { + if ((tmp & maskg) == baseg) { + base = (tmp - bot[i]) / msk[i]; + + if ((flagsg & MAP_TO_LMMIO) || + (!(flagsg & PORT_DISABLE) && + (tmp <= ((tmp & mask) | 0x03FFFFFFUL)))) { + pDecode[i][base] = -1; + } else { + pDecode[i][base] = zx1_ropemap[(tmp >> routeg) & 0x07U]; + } + } + } + + flagsg = 0; + } + + if (flagsl) { + i = GetRange(basel); + for (tmp = basel; tmp <= lastl; tmp += msk[i]) { + base = (tmp - bot[i]) / msk[i]; + pDecode[i][base] = -1; + } + + flagsl = 0; + } + + /* For now, assume directed LMMIO ranges don't overlap with each other */ + if (flags0) { + i = GetRange(base0); + for (tmp = base0; tmp <= last0; tmp += msk[i]) { + if ((tmp & mask0) == base0) { + base = (tmp - bot[i]) / msk[i]; + pDecode[i][base] = zx1_ropemap[route0]; + } + } + + flags0 = 0; + } + + if (flags1) { + i = GetRange(base1); + for (tmp = base1; tmp <= last1; tmp += msk[i]) { + if ((tmp & mask1) == base1) { + base = (tmp - bot[i]) / msk[i]; + pDecode[i][base] = zx1_ropemap[route1]; + } + } + + flags1 = 0; + } + + if (flags2) { + i = GetRange(base2); + for (tmp = base2; tmp <= last2; tmp += msk[i]) { + if ((tmp & mask2) == base2) { + base = (tmp - bot[i]) / msk[i]; + pDecode[i][base] = zx1_ropemap[route2]; + } + } + + flags2 = 0; + } + + if (flags3) { + i = GetRange(base3); + for (tmp = base3; tmp <= last3; tmp += msk[i]) { + if ((tmp & mask3) == base3) { + base = (tmp - bot[i]) / msk[i]; + pDecode[i][base] = zx1_ropemap[route3]; + } + } + + flags3 = 0; + } + + /* Claim iao config area */ + i = GetRange(ioaaddr); + for (tmp = ioaaddr; tmp < ioaaddr + (IOA_SIZE << 1); tmp += msk[i]) { + base = (tmp - bot[i]) / msk[i]; + pDecode[i][base] = -1; + } + + /* Claim mio config area */ + i = GetRange(MIO_BASE); + for (tmp = MIO_BASE; tmp < (MIO_BASE + MIO_SIZE); tmp += msk[i]) { + base = (tmp - bot[i]) / msk[i]; + pDecode[i][base] = -1; + } + + for (i = 0; i < nRange; i++) { + if (!pDecode[i]) + continue; + + rope = pDecode[i][0]; + for (base = tmp = 0; ++tmp < siz[i]; ) { + if (rope == pDecode[i][tmp]) + continue; + + if (rope >= 0) { + RANGE(range, (base * msk[i]) + bot[i], + (tmp * msk[i]) + bot[i] - 1UL, + RANGE_TYPE(ResExcMemBlock, 0)); + pZX1MemRes[rope] = + xf86AddResToList(pZX1MemRes[rope], &range, -1); + } + + base = tmp; + rope = pDecode[i][base]; + } + + xfree(pDecode[i]); + pDecode[i] = NULL; + } + + nRange = 0; + + return; +} + +/* This is called to finalise the results of a PCI bus scan */ +void +xf86PostScanZX1(void) +{ + pciConfigPtr pPCI, *ppPCI, *ppPCI2; + pciBusInfo_t *pBusInfo; + int i, idx; + + if (!pZX1mio) + return; + + (void)memset(zx1_busnmpt, FALSE, sizeof(zx1_busnmpt)); + pBusInfo = pciBusInfo[0]; + + /* + * Certain 2.4 & 2.5 Linux kernels add fake PCI devices. Remove them to + * prevent any possible interference with our PCI validation. + * + * Also, if VGA isn't routed on server entry, determine if VGA routing + * needs to be enabled while the server is running. + */ + idx = 0; + ppPCI = ppPCI2 = xf86scanpci(0); /* Recursion is only apparent */ + while ((pPCI = *ppPCI2++)) { + switch (pPCI->pci_device_vendor) { + case DEVID(VENDOR_HP, CHIP_ELROY): + case DEVID(VENDOR_HP, CHIP_ZX1_SBA): /* Pluto function 0 */ + case DEVID(VENDOR_HP, CHIP_ZX1_IOC): /* Pluto function 1 */ + case DEVID(VENDOR_HP, CHIP_ZX1_LBA): /* Mercury */ + case DEVID(VENDOR_HP, CHIP_ZX1_AGP8): /* QuickSilver */ + case DEVID(VENDOR_HP, CHIP_ZX2_SBA): + case DEVID(VENDOR_HP, CHIP_ZX2_IOC): + case DEVID(VENDOR_HP, CHIP_ZX2_LBA): + case DEVID(VENDOR_HP, CHIP_ZX2_PCIE): + xfree(pPCI); /* Remove it */ + continue; + + default: + *ppPCI++ = pPCI; + idx++; + + zx1_busnmpt[pPCI->busnum] = TRUE; + + if (zx1_hasvga) + continue; + + switch (pPCI->pci_base_class) { + case PCI_CLASS_PREHISTORIC: + if (pPCI->pci_sub_class == PCI_SUBCLASS_PREHISTORIC_VGA) + break; + continue; + + case PCI_CLASS_DISPLAY: + if (pPCI->pci_sub_class == PCI_SUBCLASS_DISPLAY_VGA) + break; + continue; + + default: + continue; + } + + zx1_hasvga = TRUE; + continue; + } + } + + /* + * Restore hard-fail settings and figure out the actual secondary and + * subordinate bus numbers. + */ + for (i = 0; i < 8; i++) { + if (zx1_ropemap[i] != i) + continue; + + if (zx1_lbacntl[i] & LBA_HARD_FAIL) + MIO_QUAD((i << 3) + LBA_PORT0_CNTRL) = zx1_lbacntl[i]; + + while ((zx1_busno[i] < zx1_subno[i]) && !pciBusInfo[zx1_subno[i]]) + zx1_subno[i]--; + + if (zx1_fakebus <= zx1_subno[i]) + zx1_fakebus = zx1_subno[i] + 1; + + while (!zx1_busnmpt[zx1_busno[i]]) { + if (zx1_busno[i]) /* Info for bus zero is in static storage */ + xfree(pciBusInfo[zx1_busno[i]]); + pciBusInfo[zx1_busno[i]++] = NULL; + if (zx1_busno[i] > zx1_subno[i]) + break; + } + } + + if (zx1_fakebus >= pciNumBuses) { + if (zx1_fakebus >= pciMaxBusNum) + FatalError("HP ZX1: No room for fake PCI bus\n"); + pciNumBuses = zx1_fakebus + 1; + } + + /* Set up our extra bus functions */ + zx1BusFuncs = *(pBusInfo->funcs); + zx1BusFuncs.pciControlBridge = ControlZX1Bridge; + zx1BusFuncs.pciGetBridgeResources = GetZX1BridgeResources; + + /* Set up our own fake bus to act as the root segment */ + zx1FakeBus.configMech = pBusInfo->configMech; + zx1FakeBus.numDevices = pBusInfo->numDevices; + zx1FakeBus.primary_bus = zx1_fakebus; + pciBusInfo[zx1_fakebus] = &zx1FakeBus; + + /* Add the fake bus' host bridge */ + if (++idx >= MAX_PCI_DEVICES) + FatalError("HP ZX1: No room for fake Host-to-PCI bridge\n"); + *ppPCI++ = zx1FakeBus.bridge = pPCI = xnfcalloc(1, sizeof(pciDevice)); + pPCI->tag = PCI_MAKE_TAG(zx1_fakebus, 0, 0); + pPCI->busnum = zx1_fakebus; + /* pPCI->devnum = pPCI->funcnum = 0; */ + pPCI->pci_device_vendor = DEVID(VENDOR_HP, CHIP_ZX1_SBA); + pPCI->pci_base_class = PCI_CLASS_BRIDGE; + /* pPCI->pci_sub_class = PCI_SUBCLASS_BRIDGE_HOST; */ + pPCI->fakeDevice = TRUE; + +#ifdef OLD_FORMAT + xf86MsgVerb(X_INFO, 2, "PCI: BusID 0x%.2x,0x%02x,0x%1x " + "ID 0x%04x,0x%04x Rev 0x%02x Class 0x%02x,0x%02x\n", + pPCI->busnum, pPCI->devnum, pPCI->funcnum, + pPCI->pci_vendor, pPCI->_pci_device, pPCI->pci_rev_id, + pPCI->pci_base_class, pPCI->pci_sub_class); +#else + xf86MsgVerb(X_INFO, 2, "PCI: %.2x:%02x:%1x: chip %04x,%04x" + " card %04x,%04x rev %02x class %02x,%02x,%02x hdr %02x\n", + pPCI->busnum, pPCI->devnum, pPCI->funcnum, + pPCI->pci_vendor, pPCI->_pci_device, + pPCI->pci_subsys_vendor, pPCI->pci_subsys_card, + pPCI->pci_rev_id, pPCI->pci_base_class, + pPCI->pci_sub_class, pPCI->pci_prog_if, + pPCI->pci_header_type); +#endif + + /* Add a fake PCI-to-PCI bridge to represent each active rope */ + for (i = 0; i < 8; i++) { + if ((zx1_ropemap[i] != i) || (zx1_busno[i] > zx1_subno[i]) || + !(pBusInfo = pciBusInfo[zx1_busno[i]])) + continue; + + if (++idx >= MAX_PCI_DEVICES) + FatalError("HP ZX1: No room for fake PCI-to-PCI bridge\n"); + *ppPCI++ = pPCI = xnfcalloc(1, sizeof(pciDevice)); + pPCI->busnum = zx1_fakebus; + pPCI->devnum = i | 0x10; + /* pPCI->funcnum = 0; */ + pPCI->tag = PCI_MAKE_TAG(zx1_fakebus, pPCI->devnum, 0); + pPCI->pci_device_vendor = zx1_pciids[i]; + pPCI->pci_base_class = PCI_CLASS_BRIDGE; + pPCI->pci_sub_class = PCI_SUBCLASS_BRIDGE_PCI; + pPCI->pci_header_type = 1; + pPCI->pci_primary_bus_number = zx1_fakebus; + pPCI->pci_secondary_bus_number = zx1_busno[i]; + pPCI->pci_subordinate_bus_number = zx1_subno[i]; + pPCI->fakeDevice = TRUE; + + pBusInfo->bridge = pPCI; + pBusInfo->secondary = TRUE; + pBusInfo->primary_bus = zx1_fakebus; + + /* Plug in chipset routines */ + pBusInfo->funcs = &zx1BusFuncs; + + /* Set bridge control register for scanpci utility */ + pPCI->pci_bridge_control = ControlZX1Bridge(zx1_busno[i], 0, 0); + +#ifdef OLD_FORMAT + xf86MsgVerb(X_INFO, 2, "PCI: BusID 0x%.2x,0x%02x,0x%1x " + "ID 0x%04x,0x%04x Rev 0x%02x Class 0x%02x,0x%02x\n", + pPCI->busnum, pPCI->devnum, pPCI->funcnum, + pPCI->pci_vendor, pPCI->_pci_device, pPCI->pci_rev_id, + pPCI->pci_base_class, pPCI->pci_sub_class); +#else + xf86MsgVerb(X_INFO, 2, "PCI: %.2x:%02x:%1x: chip %04x,%04x" + " card %04x,%04x rev %02x class %02x,%02x,%02x hdr %02x\n", + pPCI->busnum, pPCI->devnum, pPCI->funcnum, + pPCI->pci_vendor, pPCI->_pci_device, + pPCI->pci_subsys_vendor, pPCI->pci_subsys_card, + pPCI->pci_rev_id, pPCI->pci_base_class, + pPCI->pci_sub_class, pPCI->pci_prog_if, + pPCI->pci_header_type); +#endif + } + + *ppPCI = NULL; /* Terminate array */ +} --- xorg-server-1.4.99.906.orig/hw/xfree86/os-support/bus/e8870PCI.h +++ xorg-server-1.4.99.906/hw/xfree86/os-support/bus/e8870PCI.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2002-2003 The XFree86 Project, Inc. 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, 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 THE + * XFREE86 PROJECT 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 XFree86 Project 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 + * XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifndef PCI_E8870_H +#define PCI_E8870_H 1 + +#include +#include + +Bool xorgProbeE8870(scanpciWrapperOpt flags); +void xf86PreScanE8870(void); +void xf86PostScanE8870(void); + +#endif --- xorg-server-1.4.99.906.orig/hw/xfree86/os-support/shared/ia64Pci.h +++ xorg-server-1.4.99.906/hw/xfree86/os-support/shared/ia64Pci.h @@ -0,0 +1,46 @@ +/* + * Copyright 2004, Egbert Eich + * + * 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 + * EGBERT EICH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- + * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Egbert Eich shall not + * be used in advertising or otherwise to promote the sale, use or other deal- + *ings in this Software without prior written authorization from Egbert Eich. + * + */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#ifndef _IA64_PCI_H +# define _IA64_PCI_H + +#include "Pci.h" + +typedef enum { + NONE_CHIPSET, + I460GX_CHIPSET, + E8870_CHIPSET, + ZX1_CHIPSET, + ALTIX_CHIPSET +} IA64Chipset; + +# ifdef OS_PROBE_PCI_CHIPSET +extern IA64Chipset OS_PROBE_PCI_CHIPSET(scanpciWrapperOpt flags); +# endif +#endif --- xorg-server-1.4.99.906.orig/hw/xfree86/dummylib/getemptypci.c +++ xorg-server-1.4.99.906/hw/xfree86/dummylib/getemptypci.c @@ -0,0 +1,19 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +memType +getEmptyPciRange(PCITAG tag, int base_reg) +{ + return 0; +} --- xorg-server-1.4.99.906.orig/hw/xfree86/dummylib/getvalidbios.c +++ xorg-server-1.4.99.906/hw/xfree86/dummylib/getvalidbios.c @@ -0,0 +1,19 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +memType +getValidBIOSBase(PCITAG tag, int num) +{ + return 0; +} --- xorg-server-1.4.99.906.orig/hw/xfree86/dummylib/pcitestmulti.c +++ xorg-server-1.4.99.906/hw/xfree86/dummylib/pcitestmulti.c @@ -0,0 +1,19 @@ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* + * Utility functions required by libxf86_os. + */ + +int +pciTestMultiDeviceCard(int bus, int dev, int func, PCITAG** pTag) +{ + return 0; +} + --- xorg-server-1.4.99.906.orig/hw/xfree86/doc/README.modes +++ xorg-server-1.4.99.906/hw/xfree86/doc/README.modes @@ -0,0 +1,474 @@ + Multi-monitor Mode Setting APIs + Keith Packard, SaveScreen and the core X screen saver will be +implemented by disabling outputs and crtcs using their dpms functions. + + void + xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags) + +Pass this function to xf86DPMSInit and all DPMS mode switching will be +managed by using the dpms functions provided by the Outputs and CRTCs. + + Bool + xf86CrtcScreenInit (ScreenPtr screen) + +This function completes the screen initialization process for the crtc and +output objects. Call it near the end of the ScreenInit function, after the +frame buffer and acceleration layers have been added. + +3.3 EnterVT functions + +Functions used during EnterVT, or whenever the current configuration needs +to be applied to the hardware. + + Bool + xf86SetDesiredModes (ScrnInfoPtr scrn) + +xf86InitialConfiguration selects the desired configuration at PreInit time; +when the server finally hits ScreenInit, xf86SetDesiredModes is used by the +driver to take that configuration and apply it to the hardware. In addition, +successful mode selection at other times updates the configuration that will +be used by this function, so LeaveVT/EnterVT pairs can simply invoke this +and return to the previous configuration. + +3.4 SwitchMode functions + +Functions called from the pScrn->SwitchMode hook, which is used by the +XFree86-VidModeExtension and the keypad mode switch commands. + + Bool + xf86SetSingleMode (ScrnInfoPtr scrn, + DisplayModePtr desired, + Rotation rotation) + +This function applies the specified mode to all active outputs. Which is to +say, it picks reasonable modes for all active outputs, attempting to get the +screen to the specified size while not breaking anything that is currently +working. + +3.7 get_modes functions + +Functions called during output->get_modes to help build lists of modes + + xf86MonPtr + xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus) + +This returns the EDID data structure for the 'output' using the I2C bus +'pDDCBus'. This has no effect on 'output' itself. + + void + xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon) + +Once the EDID data has been fetched, this call applies the EDID data to the +output object, setting the physical size and also various properties, like +the DDC root window property (when output is the 'compat' output), and the +RandR 1.2 EDID output properties. + + DisplayModePtr + xf86OutputGetEDIDModes (xf86OutputPtr output) + +Given an EDID data structure, this function computes a list of suitable +modes. This function also applies a sequence of 'quirks' during this process +so that the returned modes may not actually match the mode data present in +the EDID data. + +3.6 Other functions + +These remaining functions in the API can be used by the driver as needed. + + Bool + xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, + int x, int y) + +Applies a mode to a CRTC. All of the outputs which are currently using the +specified CRTC are included in the mode setting process. 'x' and 'y' are the +offset within the frame buffer that the crtc is placed at. No checking is +done in this function to ensure that the mode is usable by the active +outputs. + + void + xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY) + +This discards the mode lists for all outputs, re-detects monitor presence +and then acquires new mode lists for all monitors which are not disconnected. +Monitor configuration data is used to modify the mode lists returned by the +outputs. 'maxX' and 'maxY' limit the maximum size modes that will be +returned. + + void + xf86SetScrnInfoModes (ScrnInfoPtr pScrn) + +This copies the 'compat' output mode list into the pScrn modes list which is +used by the XFree86-VidModeExtension and the keypad mode switching +operations. The current 'desired' mode for the CRTC associated with the +'compat' output is placed first in this list to indicate the current mode. +Usually, the driver won't need to call this function as +xf86InitialConfiguration will do so automatically, as well as any RandR +functions which reprobe for modes. However, if the driver reprobes for modes +at other times using xf86ProbeOutputModes, this function needs to be called. + + Bool + xf86DiDGAReInit (ScreenPtr pScreen) + +This is similar to xf86SetScrnInfoModes, but it applies the 'compat' output +mode list to the set of modes advertised by the DGA extension; it needs to +be called whenever xf86ProbeOutputModes is invoked. + + void + xf86DisableUnusedFunctions(ScrnInfoPtr pScrn) + +After any sequence of calls using xf86CrtcSetMode, this function cleans up +any leftover Output and CRTC objects by disabling them, saving power. It is +safe to call this whenever the server is running as it only disables objects +which are not currently in use. + +4. CRTC operations + +4.1 CRTC functions + +These functions provide an abstract interface for the CRTC object; most +manipulation of the CRTC object is done through these functions. + + void + crtc->funcs->dpms (xf86CrtcPtr crtc, int mode) + +Where 'mode' is one of DPMSModeOff, DPMSModeSuspend, DPMSModeStandby or +DPMSModeOn. This requests that the crtc go to the specified power state. +When changing power states, the output dpms functions are invoked before the +crtc dpms functions. + + void + crtc->funcs->save (xf86CrtcPtr crtc) + + void + crtc->funcs->restore (xf86CrtcPtr crtc) + +Preserve/restore any register contents related to the CRTC. These are +strictly a convenience for the driver writer; if the existing driver has +fully operation save/restore functions, you need not place any additional +code here. In particular, the server itself never uses this function. + + Bool + crtc->funcs->lock (xf86CrtcPtr crtc) + + void + crtc->funcs->unlock (xf86CrtcPtr crtc) + +These functions are invoked around mode setting operations; the intent is +that DRI locking be done here to prevent DRI applications from manipulating +the hardware while the server is busy changing the output configuration. If +the lock function returns FALSE, the unlock function will not be invoked. + + Bool + crtc->funcs->mode_fixup (xf86CrtcPtr crtc, + DisplayModePtr mode, + DisplayModePtr adjusted_mode) + +This call gives the CRTC a chance to see what mode will be set and to +comment on the mode by changing 'adjusted_mode' as needed. This function +shall not modify the state of the crtc hardware at all. If the CRTC cannot +accept this mode, this function may return FALSE. + + void + crtc->funcs->prepare (xf86CrtcPtr crtc) + +This call is made just before the mode is set to make the hardware ready for +the operation. A usual function to perform here is to disable the crtc so +that mode setting can occur with clocks turned off and outputs deactivated. + + void + crtc->funcs->mode_set (xf86CrtcPtr crtc, + DisplayModePtr mode, + DisplayModePtr adjusted_mode) + +This function applies the specified mode (possibly adjusted by the CRTC +and/or Outputs). + + void + crtc->funcs->commit (xf86CrtcPtr crtc) + +Once the mode has been applied to the CRTC and Outputs, this function is +invoked to let the hardware turn things back on. + + void + crtc->funcs->gamma_set (xf86CrtcPtr crtc, CARD16 *red, + CARD16 *green, CARD16 *blue, int size) + +This function adjusts the gamma ramps for the specified crtc. + + void * + crtc->funcs->shadow_allocate (xf86CrtcPtr crtc, int width, int height) + +This function allocates frame buffer space for a shadow frame buffer. When +allocated, the crtc must scan from the shadow instead of the main frame +buffer. This is used for rotation. The address returned is passed to the +shadow_create function. This function should return NULL on failure. + + PixmapPtr + crtc->funcs->shadow_create (xf86CrtcPtr crtc, void *data, + int width, int height) + +This function creates a pixmap object that will be used as a shadow of the +main frame buffer for CRTCs which are rotated or reflected. 'data' is the +value returned by shadow_allocate. + + void + crtc->funcs->shadow_destroy (xf86CrtcPtr crtc, PixmapPtr pPixmap, + void *data) + +Destroys any associated shadow objects. If pPixmap is NULL, then a pixmap +was not created, but 'data' may still be non-NULL indicating that the shadow +had been allocated. + + void + crtc->funcs->destroy (xf86CrtcPtr crtc) + +When a CRTC is destroyed (which only happens in error cases), this function +can clean up any driver-specific data. + +4.2 CRTC fields + +The CRTC object is not opaque; there are several fields of interest to the +driver writer. + + struct _xf86Crtc { + /** + * Associated ScrnInfo + */ + ScrnInfoPtr scrn; + + /** + * Active state of this CRTC + * + * Set when this CRTC is driving one or more outputs + */ + Bool enabled; + + /** Track whether cursor is within CRTC range */ + Bool cursorInRange; + + /** Track state of cursor associated with this CRTC */ + Bool cursorShown; + + /** + * Active mode + * + * This reflects the mode as set in the CRTC currently + * It will be cleared when the VT is not active or + * during server startup + */ + DisplayModeRec mode; + Rotation rotation; + PixmapPtr rotatedPixmap; + void *rotatedData; + + /** + * Position on screen + * + * Locates this CRTC within the frame buffer + */ + int x, y; + + /** + * Desired mode + * + * This is set to the requested mode, independent of + * whether the VT is active. In particular, it receives + * the startup configured mode and saves the active mode + * on VT switch. + */ + DisplayModeRec desiredMode; + Rotation desiredRotation; + int desiredX, desiredY; + + /** crtc-specific functions */ + const xf86CrtcFuncsRec *funcs; + + /** + * Driver private + * + * Holds driver-private information + */ + void *driver_private; + #ifdef RANDR_12_INTERFACE + /** + * RandR crtc + * + * When RandR 1.2 is available, this + * points at the associated crtc object + */ + RRCrtcPtr randr_crtc; + #else + void *randr_crtc; + #endif + }; + + +5. Output functions. + +6. Configuration + +Because the configuration file syntax is fixed, +this was done by creating new "Driver" section options that hook specific +outputs to specific "Monitor" sections in the file. The option: +section of the form: + + Option "monitor-VGA" "My VGA Monitor" + +connects the VGA output of this driver to the "Monitor" section with +Identifier "My VGA Monitor". All of the usual monitor options can now be +placed in that "Monitor" section and will be applied to the VGA output +configuration. --- xorg-server-1.4.99.906.orig/ChangeLog +++ xorg-server-1.4.99.906/ChangeLog @@ -1,3 +1,11 @@ +commit c0c73e9236cffece7c8049515b03facb41f12f0e +Author: Adam Jackson +Date: Wed Jul 23 14:16:47 2008 -0400 + + xserver 1.4.99.906 + + You know, Mesa 7.1 could release any day now and that'd be just fine. + commit e909a396194e64119d04fc6ecb68ddc4265a3e49 Author: Pierre-Loup A. Griffais Date: Tue Jul 22 17:34:37 2008 -0700 --- xorg-server-1.4.99.906.orig/debian/xsfbs/xsfbs.sh +++ xorg-server-1.4.99.906/debian/xsfbs/xsfbs.sh @@ -0,0 +1,931 @@ +# $Id$ + +# This is the X Strike Force shell library for X Window System package +# maintainer scripts. It serves to define shell functions commonly used by +# such packages, and performs some error checking necessary for proper operation +# of those functions. By itself, it does not "do" much; the maintainer scripts +# invoke the functions defined here to accomplish package installation and +# removal tasks. + +# If you are reading this within a Debian package maintainer script (e.g., +# /var/lib/dpkg)info/PACKAGE.{config,preinst,postinst,prerm,postrm}), you can +# skip past this library by scanning forward in this file to the string +# "GOBSTOPPER". + +SOURCE_VERSION=@SOURCE_VERSION@ +OFFICIAL_BUILD=@OFFICIAL_BUILD@ + +# Use special abnormal exit codes so that problems with this library are more +# easily tracked down. +SHELL_LIB_INTERNAL_ERROR=86 +SHELL_LIB_THROWN_ERROR=74 +SHELL_LIB_USAGE_ERROR=99 + +# old -> new variable names +if [ -z "$DEBUG_XORG_PACKAGE" ] && [ -n "$DEBUG_XFREE86_PACKAGE" ]; then + DEBUG_XORG_PACKAGE="$DEBUG_XFREE86_PACKAGE" +fi +if [ -z "$DEBUG_XORG_DEBCONF" ] && [ -n "$DEBUG_XFREE86_DEBCONF" ]; then + DEBUG_XORG_DEBCONF="$DEBUG_XFREE86_DEBCONF" +fi + +# initial sanity checks +if [ -z "$THIS_PACKAGE" ]; then + cat >&2 < on the World Wide Web for +instructions, read the file /usr/share/doc/debian/bug-reporting.txt from the +"doc-debian" package, or install the "reportbug" package and use the command of +the same name to file a report against version $SOURCE_VERSION of this package. +EOF + exit $SHELL_LIB_USAGE_ERROR +fi + +if [ -z "$THIS_SCRIPT" ]; then + cat >&2 < on the World Wide Web for +instructions, read the file /usr/share/doc/debian/bug-reporting.txt from the +"doc-debian" package, or install the "reportbug" package and use the command of +the same name to file a report against version $SOURCE_VERSION of the +"$THIS_PACKAGE" package. +EOF + exit $SHELL_LIB_USAGE_ERROR +fi + +ARCHITECTURE="$(dpkg --print-installation-architecture)" + +if [ "$1" = "reconfigure" ] || [ -n "$DEBCONF_RECONFIGURE" ]; then + RECONFIGURE="true" +else + RECONFIGURE= +fi + +if ([ "$1" = "install" ] || [ "$1" = "configure" ]) && [ -z "$2" ]; then + FIRSTINST="yes" +fi + +if [ -z "$RECONFIGURE" ] && [ -z "$FIRSTINST" ]; then + UPGRADE="yes" +fi + +trap "message;\ + message \"Received signal. Aborting $THIS_PACKAGE package $THIS_SCRIPT script.\";\ + message;\ + exit 1" HUP INT QUIT TERM + +reject_nondigits () { + # syntax: reject_nondigits [ operand ... ] + # + # scan operands (typically shell variables whose values cannot be trusted) for + # characters other than decimal digits and barf if any are found + while [ -n "$1" ]; do + # does the operand contain anything but digits? + if ! expr "$1" : "[[:digit:]]\+$" > /dev/null 2>&1; then + # can't use die(), because it wraps message() which wraps this function + echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_nondigits() encountered" \ + "possibly malicious garbage \"$1\"" >&2 + exit $SHELL_LIB_THROWN_ERROR + fi + shift + done +} + +reject_whitespace () { + # syntax: reject_whitespace [ operand ] + # + # scan operand (typically a shell variable whose value cannot be trusted) for + # whitespace characters and barf if any are found + if [ -n "$1" ]; then + # does the operand contain any whitespace? + if expr "$1" : "[[:space:]]" > /dev/null 2>&1; then + # can't use die(), because I want to avoid forward references + echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_whitespace() encountered" \ + "possibly malicious garbage \"$1\"" >&2 + exit $SHELL_LIB_THROWN_ERROR + fi + fi +} + +reject_unlikely_path_chars () { + # syntax: reject_unlikely_path_chars [ operand ... ] + # + # scan operands (typically shell variables whose values cannot be trusted) for + # characters unlikely to be seen in a path and which the shell might + # interpret and barf if any are found + while [ -n "$1" ]; do + # does the operand contain any funny characters? + if expr "$1" : '.*[!$&()*;<>?|].*' > /dev/null 2>&1; then + # can't use die(), because I want to avoid forward references + echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_unlikely_path_chars()" \ + "encountered possibly malicious garbage \"$1\"" >&2 + exit $SHELL_LIB_THROWN_ERROR + fi + shift + done +} + +# Query the terminal to establish a default number of columns to use for +# displaying messages to the user. This is used only as a fallback in the +# event the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while +# the script is running, and this cannot, only being calculated once.) +DEFCOLUMNS=$(stty size 2> /dev/null | awk '{print $2}') || true +if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" > /dev/null 2>&1; then + DEFCOLUMNS=80 +fi + +message () { + # pretty-print messages of arbitrary length + reject_nondigits "$COLUMNS" + echo "$*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} >&2 +} + +observe () { + # syntax: observe message ... + # + # issue observational message suitable for logging someday when support for + # it exists in dpkg + if [ -n "$DEBUG_XORG_PACKAGE" ]; then + message "$THIS_PACKAGE $THIS_SCRIPT note: $*" + fi +} + +warn () { + # syntax: warn message ... + # + # issue warning message suitable for logging someday when support for + # it exists in dpkg; also send to standard error + message "$THIS_PACKAGE $THIS_SCRIPT warning: $*" +} + +die () { + # syntax: die message ... + # + # exit script with error message + message "$THIS_PACKAGE $THIS_SCRIPT error: $*" + exit $SHELL_LIB_THROWN_ERROR +} + +internal_error () { + # exit script with error; essentially a "THIS SHOULD NEVER HAPPEN" message + message "internal error: $*" + if [ -n "$OFFICIAL_BUILD" ]; then + message "Please report a bug in the $THIS_SCRIPT script of the" \ + "$THIS_PACKAGE package, version $SOURCE_VERSION to the Debian Bug" \ + "Tracking System. Include all messages above that mention the" \ + "$THIS_PACKAGE package. Visit " \ + " on the World Wide Web for" \ + "instructions, read the file" \ + "/usr/share/doc/debian/bug-reporting.txt from the doc-debian" \ + "package, or install the reportbug package and use the command of" \ + "the same name to file a report." + fi + exit $SHELL_LIB_INTERNAL_ERROR +} + +usage_error () { + message "usage error: $*" + message "Please report a bug in the $THIS_SCRIPT script of the" \ + "$THIS_PACKAGE package, version $SOURCE_VERSION to the Debian Bug" \ + "Tracking System. Include all messages above that mention the" \ + "$THIS_PACKAGE package. Visit " \ + " on the World Wide Web for" \ + "instructions, read the file" \ + "/usr/share/doc/debian/bug-reporting.txt from the doc-debian" \ + "package, or install the reportbug package and use the command of" \ + "the same name to file a report." + exit $SHELL_LIB_USAGE_ERROR +} + + +maplink () { + # returns what symlink should point to; i.e., what the "sane" answer is + # Keep this in sync with the debian/*.links files. + # This is only needed for symlinks to directories. + # + # XXX: Most of these look wrong in the X11R7 world and need to be fixed. + # If we've stopped using this function, fixing it might enable us to re-enable + # it again and catch more errors. + case "$1" in + /etc/X11/xkb/compiled) echo /var/lib/xkb ;; + /etc/X11/xkb/xkbcomp) echo /usr/X11R6/bin/xkbcomp ;; + /usr/X11R6/lib/X11/app-defaults) echo /etc/X11/app-defaults ;; + /usr/X11R6/lib/X11/fs) echo /etc/X11/fs ;; + /usr/X11R6/lib/X11/lbxproxy) echo /etc/X11/lbxproxy ;; + /usr/X11R6/lib/X11/proxymngr) echo /etc/X11/proxymngr ;; + /usr/X11R6/lib/X11/rstart) echo /etc/X11/rstart ;; + /usr/X11R6/lib/X11/twm) echo /etc/X11/twm ;; + /usr/X11R6/lib/X11/xdm) echo /etc/X11/xdm ;; + /usr/X11R6/lib/X11/xinit) echo /etc/X11/xinit ;; + /usr/X11R6/lib/X11/xkb) echo /etc/X11/xkb ;; + /usr/X11R6/lib/X11/xserver) echo /etc/X11/xserver ;; + /usr/X11R6/lib/X11/xsm) echo /etc/X11/xsm ;; + /usr/bin/X11) echo ../X11R6/bin ;; + /usr/bin/rstartd) echo ../X11R6/bin/rstartd ;; + /usr/include/X11) echo ../X11R6/include/X11 ;; + /usr/lib/X11) echo ../X11R6/lib/X11 ;; + *) internal_error "maplink() called with unknown path \"$1\"" ;; + esac +} + +analyze_path () { + # given a supplied set of pathnames, break each one up by directory and do an + # ls -dl on each component, cumulatively; i.e. + # analyze_path /usr/X11R6/bin -> ls -dl /usr /usr/X11R6 /usr/X11R6/bin + # Thanks to Randolph Chung for this clever hack. + + local f g + + while [ -n "$1" ]; do + reject_whitespace "$1" + g= + message "Analyzing $1:" + for f in $(echo "$1" | tr / \ ); do + if [ -e /$g$f ]; then + ls -dl /$g$f /$g$f.dpkg-* 2> /dev/null || true + g=$g$f/ + else + message "/$g$f: nonexistent; directory contents of /$g:" + ls -l /$g + break + fi + done + shift + done +} + +find_culprits () { + local f p dpkg_info_dir possible_culprits smoking_guns bad_packages package \ + msg + + reject_whitespace "$1" + message "Searching for overlapping packages..." + dpkg_info_dir=/var/lib/dpkg/info + if [ -d $dpkg_info_dir ]; then + if [ "$(echo $dpkg_info_dir/*.list)" != "$dpkg_info_dir/*.list" ]; then + possible_culprits=$(ls -1 $dpkg_info_dir/*.list | egrep -v \ + "(xbase-clients|x11-common|xfs|xlibs)") + if [ -n "$possible_culprits" ]; then + smoking_guns=$(grep -l "$1" $possible_culprits || true) + if [ -n "$smoking_guns" ]; then + bad_packages=$(printf "\\n") + for f in $smoking_guns; do + # too bad you can't nest parameter expansion voodoo + p=${f%*.list} # strip off the trailing ".list" + package=${p##*/} # strip off the directories + bad_packages=$(printf "%s\n%s" "$bad_packages" "$package") + done + msg=$(cat < /dev/null 2>&1; then + message "The readlink command was not found. Please install version" \ + "1.13.1 or later of the debianutils package." + readlink () { + # returns what symlink in $1 actually points to + perl -e '$l = shift; exit 1 unless -l $l; $r = readlink $l; exit 1 unless $r; print "$r\n"' "$1" + } +fi + +check_symlink () { + # syntax: check_symlink symlink + # + # See if specified symlink points where it is supposed to. Return 0 if it + # does, and 1 if it does not. + # + # Primarily used by check_symlinks_and_warn() and check_symlinks_and_bomb(). + + local symlink + + # validate arguments + if [ $# -ne 1 ]; then + usage_error "check_symlink() called with wrong number of arguments;" \ + "expected 1, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + symlink="$1" + + if [ "$(maplink "$symlink")" = "$(readlink "$symlink")" ]; then + return 0 + else + return 1 + fi +} + +check_symlinks_and_warn () { + # syntax: check_symlinks_and_warn symlink ... + # + # For each argument, check for symlink sanity, and warn if it isn't sane. + # + # Call this function from a preinst script in the event $1 is "upgrade" or + # "install". + + local errmsg symlink + + # validate arguments + if [ $# -lt 1 ]; then + usage_error "check_symlinks_and_warn() called with wrong number of" \ + "arguments; expected at least 1, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + while [ -n "$1" ]; do + symlink="$1" + if [ -L "$symlink" ]; then + if ! check_symlink "$symlink"; then + observe "$symlink symbolic link points to wrong location" \ + "$(readlink "$symlink"); removing" + rm "$symlink" + fi + elif [ -e "$symlink" ]; then + errmsg="$symlink exists and is not a symbolic link; this package cannot" + errmsg="$errmsg be installed until this" + if [ -f "$symlink" ]; then + errmsg="$errmsg file" + elif [ -d "$symlink" ]; then + errmsg="$errmsg directory" + else + errmsg="$errmsg thing" + fi + errmsg="$errmsg is removed" + die "$errmsg" + fi + shift + done +} + +check_symlinks_and_bomb () { + # syntax: check_symlinks_and_bomb symlink ... + # + # For each argument, check for symlink sanity, and bomb if it isn't sane. + # + # Call this function from a postinst script. + + local problem symlink + + # validate arguments + if [ $# -lt 1 ]; then + usage_error "check_symlinks_and_bomb() called with wrong number of" + "arguments; expected at least 1, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + while [ -n "$1" ]; do + problem= + symlink="$1" + if [ -L "$symlink" ]; then + if ! check_symlink "$symlink"; then + problem=yes + warn "$symlink symbolic link points to wrong location" \ + "$(readlink "$symlink")" + fi + elif [ -e "$symlink" ]; then + problem=yes + warn "$symlink is not a symbolic link" + else + problem=yes + warn "$symlink symbolic link does not exist" + fi + if [ -n "$problem" ]; then + analyze_path "$symlink" "$(readlink "$symlink")" + find_culprits "$symlink" + die "bad symbolic links on system" + fi + shift + done +} + +font_update () { + # run $UPDATECMDS in $FONTDIRS + + local dir cmd shortcmd x_font_dir_prefix + + x_font_dir_prefix="/usr/share/fonts/X11" + + if [ -z "$UPDATECMDS" ]; then + usage_error "font_update() called but \$UPDATECMDS not set" + fi + if [ -z "$FONTDIRS" ]; then + usage_error "font_update() called but \$FONTDIRS not set" + fi + + reject_unlikely_path_chars "$UPDATECMDS" + reject_unlikely_path_chars "$FONTDIRS" + + for dir in $FONTDIRS; do + if [ -d "$x_font_dir_prefix/$dir" ]; then + for cmd in $UPDATECMDS; do + if which "$cmd" > /dev/null 2>&1; then + shortcmd=${cmd##*/} + observe "running $shortcmd in $dir font directory" + cmd_opts= + if [ "$shortcmd" = "update-fonts-alias" ]; then + cmd_opts=--x11r7-layout + fi + if [ "$shortcmd" = "update-fonts-dir" ]; then + cmd_opts=--x11r7-layout + fi + if [ "$shortcmd" = "update-fonts-scale" ]; then + cmd_opts=--x11r7-layout + fi + $cmd $cmd_opts $dir || warn "$cmd $cmd_opts $dir" \ + "failed; font directory data may not" \ + "be up to date" + else + warn "$cmd not found; not updating corresponding $dir font" \ + "directory data" + fi + done + else + warn "$dir is not a directory; not updating font directory data" + fi + done +} + +remove_conffile_prepare () { + # syntax: remove_conffile_prepare filename official_md5sum ... + # + # Check a conffile "filename" against a list of canonical MD5 checksums. + # If the file's current MD5 checksum matches one of the "official_md5sum" + # operands provided, then prepare the conffile for removal from the system. + # We defer actual deletion until the package is configured so that we can + # roll this operation back if package installation fails. + # + # Call this function from a preinst script in the event $1 is "upgrade" or + # "install" and verify $2 to ensure the package is being upgraded from a + # version (or installed over a version removed-but-not-purged) prior to the + # one in which the conffile was obsoleted. + + local conffile current_checksum + + # validate arguments + if [ $# -lt 2 ]; then + usage_error "remove_conffile_prepare() called with wrong number of" \ + "arguments; expected at least 2, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + conffile="$1" + shift + + # does the conffile even exist? + if [ -e "$conffile" ]; then + # calculate its checksum + current_checksum=$(md5sum < "$conffile" | sed 's/[[:space:]].*//') + # compare it to each supplied checksum + while [ -n "$1" ]; do + if [ "$current_checksum" = "$1" ]; then + # we found a match; move the confffile and stop looking + observe "preparing obsolete conffile $conffile for removal" + mv "$conffile" "$conffile.$THIS_PACKAGE-tmp" + break + fi + shift + done + fi +} + +remove_conffile_lookup () { + # syntax: remove_conffile_lookup package filename + # + # Lookup the md5sum of a conffile in dpkg's database, and prepare for removal + # if it matches the actual file's md5sum. + # + # Call this function when you would call remove_conffile_prepare but only + # want to check against dpkg's status database instead of known checksums. + + local package conffile old_md5sum + + # validate arguments + if [ $# -ne 2 ]; then + usage_error "remove_conffile_lookup() called with wrong number of" \ + "arguments; expected 1, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + package="$1" + conffile="$2" + + if ! [ -e "$conffile" ]; then + return + fi + old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$package" | \ + awk '{ if (match($0, "^ '"$conffile"' ")) print $2}')" + if [ -n "$old_md5sum" ]; then + remove_conffile_prepare "$conffile" "$old_md5sum" + fi +} + +remove_conffile_commit () { + # syntax: remove_conffile_commit filename + # + # Complete the removal of a conffile "filename" that has become obsolete. + # + # Call this function from a postinst script after having used + # remove_conffile_prepare() in the preinst. + + local conffile + + # validate arguments + if [ $# -ne 1 ]; then + usage_error "remove_conffile_commit() called with wrong number of" \ + "arguments; expected 1, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + conffile="$1" + + # if the temporary file created by remove_conffile_prepare() exists, remove it + if [ -e "$conffile.$THIS_PACKAGE-tmp" ]; then + observe "committing removal of obsolete conffile $conffile" + rm "$conffile.$THIS_PACKAGE-tmp" + fi +} + +remove_conffile_rollback () { + # syntax: remove_conffile_rollback filename + # + # Roll back the removal of a conffile "filename". + # + # Call this function from a postrm script in the event $1 is "abort-upgrade" + # or "abort-install" is after having used remove_conffile_prepare() in the + # preinst. + + local conffile + + # validate arguments + if [ $# -ne 1 ]; then + usage_error "remove_conffile_rollback() called with wrong number of" \ + "arguments; expected 1, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + conffile="$1" + + # if the temporary file created by remove_conffile_prepare() exists, move it + # back + if [ -e "$conffile.$THIS_PACKAGE-tmp" ]; then + observe "rolling back removal of obsolete conffile $conffile" + mv "$conffile.$THIS_PACKAGE-tmp" "$conffile" + fi +} + +replace_conffile_with_symlink_prepare () { + # syntax: replace_conffile_with_symlink_prepare oldfilename newfilename \ + # official_md5sum ... + # + # Check a conffile "oldfilename" against a list of canonical MD5 checksums. + # If the file's current MD5 checksum matches one of the "official_md5sum" + # operands provided, then prepare the conffile for removal from the system. + # We defer actual deletion until the package is configured so that we can + # roll this operation back if package installation fails. Otherwise copy it + # to newfilename and let dpkg handle it through conffiles mechanism. + # + # Call this function from a preinst script in the event $1 is "upgrade" or + # "install" and verify $2 to ensure the package is being upgraded from a + # version (or installed over a version removed-but-not-purged) prior to the + # one in which the conffile was obsoleted. + + local conffile current_checksum + + # validate arguments + if [ $# -lt 3 ]; then + usage_error "replace_conffile_with_symlink_prepare() called with wrong" \ + " number of arguments; expected at least 3, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + oldconffile="$1" + shift + newconffile="$1" + shift + + remove_conffile_prepare "$_oldconffile" "$@" + # If $oldconffile still exists, then md5sums didn't match. + # Copy it to new one. + if [ -f "$oldconffile" ]; then + cp "$oldconffile" "$newconffile" + fi + +} + +replace_conffile_with_symlink_commit () { + # syntax: replace_conffile_with_symlink_commit oldfilename + # + # Complete the removal of a conffile "oldfilename" that has been + # replaced by a symlink. + # + # Call this function from a postinst script after having used + # replace_conffile_with_symlink_prepare() in the preinst. + + local conffile + + # validate arguments + if [ $# -ne 1 ]; then + usage_error "replace_conffile_with_symlink_commit() called with wrong" \ + "number of arguments; expected 1, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + conffile="$1" + + remove_conffile_commit "$conffile" +} + +replace_conffile_with_symlink_rollback () { + # syntax: replace_conffile_with_symlink_rollback oldfilename newfilename + # + # Roll back the replacing of a conffile "oldfilename" with symlink to + # "newfilename". + # + # Call this function from a postrm script in the event $1 is "abort-upgrade" + # or "abort-install" and verify $2 to ensure the package failed to upgrade + # from a version (or install over a version removed-but-not-purged) prior + # to the one in which the conffile was obsoleted. + # You should have used replace_conffile_with_symlink_prepare() in the + # preinst. + + local conffile + + # validate arguments + if [ $# -ne 2 ]; then + usage_error "replace_conffile_with_symlink_rollback() called with wrong" \ + "number of arguments; expected 2, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + oldconffile="$1" + newconffile="$2" + + remove_conffile_rollback "$_oldconffile" + if [ -f "$newconffile" ]; then + rm "$newconffile" + fi +} + +run () { + # syntax: run command [ argument ... ] + # + # Run specified command with optional arguments and report its exit status. + # Useful for commands whose exit status may be nonzero, but still acceptable, + # or commands whose failure is not fatal to us. + # + # NOTE: Do *not* use this function with db_get or db_metaget commands; in + # those cases the return value of the debconf command *must* be checked + # before the string returned by debconf is used for anything. + + local retval + + # validate arguments + if [ $# -lt 1 ]; then + usage_error "run() called with wrong number of arguments; expected at" \ + "least 1, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + "$@" || retval=$? + + if [ ${retval:-0} -ne 0 ]; then + observe "command \"$*\" exited with status $retval" + fi +} + +register_x_lib_dir_with_ld_so () { + # syntax: register_x_lib_dir_with_ld_so + # + # Configure the dynamic loader ld.so to search /usr/X11R6/lib for shared + # libraries. + # + # Call this function from the postinst script of a package that places a + # shared library in /usr/X11R6/lib, before invoking ldconfig. + + local dir ldsoconf + + dir="/usr/X11R6/lib" + ldsoconf="/etc/ld.so.conf" + + # is the line not already present? + if ! fgrep -qsx "$dir" "$ldsoconf"; then + observe "adding $dir directory to $ldsoconf" + echo "$dir" >> "$ldsoconf" + fi +} + +deregister_x_lib_dir_with_ld_so () { + # syntax: deregister_x_lib_dir_with_ld_so + # + # Configure dynamic loader ld.so to not search /usr/X11R6/lib for shared + # libraries, if and only if no shared libaries remain there. + # + # Call this function from the postrm script of a package that places a shared + # library in /usr/X11R6/lib, in the event "$1" is "remove", and before + # invoking ldconfig. + + local dir ldsoconf fgrep_status cmp_status + + dir="/usr/X11R6/lib" + ldsoconf="/etc/ld.so.conf" + + # is the line present? + if fgrep -qsx "$dir" "$ldsoconf"; then + # are there any shared objects in the directory? + if [ "$(echo "$dir"/lib*.so.*.*)" = "$dir/lib*.so.*.*" ]; then + # glob expansion produced nothing, so no shared libraries are present + observe "removing $dir directory from $ldsoconf" + # rewrite the file (very carefully) + set +e + fgrep -svx "$dir" "$ldsoconf" > "$ldsoconf.dpkg-tmp" + fgrep_status=$? + set -e + case $fgrep_status in + 0|1) ;; # we don't actually care if any lines matched or not + *) die "error reading \"$ldsoconf\"; fgrep exited with status" \ + "$fgrep_status" ;; + esac + set +e + cmp -s "$ldsoconf.dpkg-tmp" "$ldsoconf" + cmp_status=$? + set -e + case $cmp_status in + 0) rm "$ldsoconf.dpkg-tmp" ;; # files are identical + 1) mv "$ldsoconf.dpkg-tmp" "$ldsoconf" ;; # files differ + *) die "error comparing \"$ldsoconf.dpkg-tmp\" to \"$ldsoconf\";" \ + "cmp exited with status $cmp_status" ;; + esac + fi + fi +} + +make_symlink_sane () { + # syntax: make_symlink_sane symlink target + # + # Ensure that the symbolic link symlink exists, and points to target. + # + # If symlink does not exist, create it and point it at target. + # + # If symlink exists but is not a symbolic link, back it up. + # + # If symlink exists, is a symbolic link, but points to the wrong location, fix + # it. + # + # If symlink exists, is a symbolic link, and already points to target, do + # nothing. + # + # This function wouldn't be needed if ln had an -I, --idempotent option. + + # Validate arguments. + if [ $# -ne 2 ]; then + usage_error "make_symlink_sane() called with wrong number of arguments;" \ + "expected 2, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + # We could just use the positional parameters as-is, but that makes things + # harder to follow. + local symlink target + + symlink="$1" + target="$2" + + if [ -L "$symlink" ] && [ "$(readlink "$symlink")" = "$target" ]; then + observe "link from $symlink to $target already exists" + else + observe "creating symbolic link from $symlink to $target" + mkdir -p "${target%/*}" "${symlink%/*}" + ln -s -b -S ".dpkg-old" "$target" "$symlink" + fi +} + +migrate_dir_to_symlink () { + # syntax: migrate_dir_to_symlink old_location new_location + # + # Per Debian Policy section 6.5.4, "A directory will never be replaced by a + # symbolic link to a directory or vice versa; instead, the existing state + # (symlink or not) will be left alone and dpkg will follow the symlink if + # there is one." + # + # We have to do it ourselves. + # + # This function moves the contents of old_location, a directory, into + # new_location, a directory, then makes old_location a symbolic link to + # new_location. + # + # old_location need not exist, but if it does, it must be a directory (or a + # symlink to a directory). If it is not, it is backed up. If new_location + # exists already and is not a directory, it is backed up. + # + # This function should be called from a package's preinst so that other + # packages unpacked after this one --- but before this package's postinst runs + # --- are unpacked into new_location even if their payloads contain + # old_location filespecs. + + # Validate arguments. + if [ $# -ne 2 ]; then + usage_error "migrate_dir_to_symlink() called with wrong number of" + "arguments; expected 2, got $#" + exit $SHELL_LIB_USAGE_ERROR + fi + + # We could just use the positional parameters as-is, but that makes things + # harder to follow. + local new old + + old="$1" + new="$2" + + # Is old location a symlink? + if [ -L "$old" ]; then + # Does it already point to new location? + if [ "$(readlink "$old")" = "$new" ]; then + # Nothing to do; migration has already been done. + observe "migration of $old to $new already done" + return 0 + else + # Back it up. + warn "backing up symbolic link $old as $old.dpkg-old" + mv -b "$old" "$old.dpkg-old" + fi + fi + + # Does old location exist, but is not a directory? + if [ -e "$old" ] && ! [ -d "$old" ]; then + # Back it up. + warn "backing up non-directory $old as $old.dpkg-old" + mv -b "$old" "$old.dpkg-old" + fi + + observe "migrating $old to $new" + + # Is new location a symlink? + if [ -L "$new" ]; then + # Does it point the wrong way, i.e., back to where we're migrating from? + if [ "$(readlink "$new")" = "$old" ]; then + # Get rid of it. + observe "removing symbolic link $new which points to $old" + rm "$new" + else + # Back it up. + warn "backing up symbolic link $new as $new.dpkg-old" + mv -b "$new" "$new.dpkg-old" + fi + fi + + # Does new location exist, but is not a directory? + if [ -e "$new" ] && ! [ -d "$new" ]; then + warn "backing up non-directory $new as $new.dpkg-old" + mv -b "$new" "$new.dpkg-old" + fi + + # Create new directory if it does not yet exist. + if ! [ -e "$new" ]; then + observe "creating $new" + mkdir -p "$new" + fi + + # Copy files in old location to new location. Back up any filenames that + # already exist in the new location with the extension ".dpkg-old". + observe "copying files from $old to $new" + if ! (cd "$old" && cp -a -b -S ".dpkg-old" . "$new"); then + die "error(s) encountered while copying files from $old to $new" + fi + + # Remove files at old location. + observe "removing $old" + rm -r "$old" + + # Create symlink from old location to new location. + make_symlink_sane "$old" "$new" +} + +# vim:set ai et sw=2 ts=2 tw=80: + +# GOBSTOPPER: The X Strike Force shell library ends here. --- xorg-server-1.4.99.906.orig/debian/xsfbs/xsfbs.mk +++ xorg-server-1.4.99.906/debian/xsfbs/xsfbs.mk @@ -0,0 +1,293 @@ +#!/usr/bin/make -f + +# Debian X Strike Force Build System (XSFBS): Make portion + +# Copyright 1996 Stephen Early +# Copyright 1997 Mark Eichin +# Copyright 1998-2005, 2007 Branden Robinson +# Copyright 2005 David Nusinow +# +# Licensed under the GNU General Public License, version 2. See the file +# /usr/share/common-licenses/GPL or . + +# Originally by Stephen Early +# Modified by Mark W. Eichin +# Modified by Adam Heath +# Modified by Branden Robinson +# Modified by Fabio Massimo Di Nitto +# Modified by David Nusinow +# Acknowledgements to Manoj Srivastava. + +# Pass $(DH_OPTIONS) into the environment for debhelper's benefit. +export DH_OPTIONS + +# force quilt to not use ~/.quiltrc and to use debian/patches +QUILT = QUILT_PATCHES=debian/patches quilt --quiltrc /dev/null + +# Set up parameters for the upstream build environment. + +# Determine (source) package name from Debian changelog. +SOURCE_NAME:=$(shell dpkg-parsechangelog -ldebian/changelog \ + | grep '^Source:' | awk '{print $$2}') + +# Determine package version from Debian changelog. +SOURCE_VERSION:=$(shell dpkg-parsechangelog -ldebian/changelog \ + | grep '^Version:' | awk '{print $$2}') + +# Determine upstream version number. +UPSTREAM_VERSION:=$(shell echo $(SOURCE_VERSION) | sed 's/-.*//') + +# Determine the source version without the epoch for make-orig-tar-gz +NO_EPOCH_VER:=$(shell echo $(UPSTREAM_VERSION) | sed 's/^.://') + +# Figure out who's building this package. +BUILDER:=$(shell echo $${DEBEMAIL:-$${EMAIL:-$$(echo $$LOGNAME@$$(cat /etc/mailname 2>/dev/null))}}) + +# Find out if this is an official build; an official build has nothing but +# digits, dots, and/or the codename of a release in the Debian part of the +# version number. Anything else indicates an unofficial build. +OFFICIAL_BUILD:=$(shell VERSION=$(SOURCE_VERSION); if ! expr "$$(echo $${VERSION\#\#*-} | sed 's/\(woody\|sarge\|etch\|lenny\)//g')" : ".*[^0-9.].*" >/dev/null 2>&1; then echo yes; fi) + +# Set up parameters for the Debian build environment. + +# Determine our architecture. +BUILD_ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH) +# Work around some old-time dpkg braindamage. +BUILD_ARCH:=$(subst i486,i386,$(BUILD_ARCH)) +# The DEB_HOST_ARCH variable may be set per the Debian cross-compilation policy. +ifdef DEB_HOST_ARCH + ARCH:=$(DEB_HOST_ARCH) +else + # dpkg-cross sets the ARCH environment variable; if set, use it. + ifdef ARCH + ARCH:=$(ARCH) + else + ARCH:=$(BUILD_ARCH) + endif +endif + +# $(STAMP_DIR) houses stamp files for complex targets. +STAMP_DIR:=stampdir + +# $(DEBTREEDIR) is where all install rules are told (via $(DESTDIR)) to place +# their files. +DEBTREEDIR:=$(CURDIR)/debian/tmp + +# All "important" targets have four lines: +# 1) A target name that is invoked by a package-building tool or the user. +# This consists of a dependency on a "$(STAMP_DIR)/"-prefixed counterpart. +# 2) A line delcaring 1) as a phony target (".PHONY:"). +# 3) A "$(STAMP_DIR)/"-prefixed target which does the actual work, and may +# depend on other targets. +# 4) A line declaring 3) as a member of the $(stampdir_targets) variable; the +# "$(STAMP_DIR)/" prefix is omitted. +# +# This indirection is needed so that the "stamp" files that signify when a rule +# is done can be located in a separate "stampdir". Recall that make has no way +# to know when a goal has been met for a phony target (like "build" or +# "install"). +# +# At the end of each "$(STAMP_DIR)/" target, be sure to run the command ">$@" +# so that the target will not be run again. Removing the file will make Make +# run the target over. + +# All phony targets should be declared as dependencies of .PHONY, even if they +# do not have "($STAMP_DIR)/"-prefixed counterparts. + +# Define a harmless default rule to keep things from going nuts by accident. +.PHONY: default +default: + +# Set up the $(STAMP_DIR) directory. +.PHONY: stampdir +stampdir_targets+=stampdir +stampdir: $(STAMP_DIR)/stampdir +$(STAMP_DIR)/stampdir: + mkdir $(STAMP_DIR) + >$@ + +# Set up the package build directory as quilt expects to find it. +.PHONY: prepare +stampdir_targets+=prepare +prepare: $(STAMP_DIR)/prepare +$(STAMP_DIR)/prepare: $(STAMP_DIR)/log $(STAMP_DIR)/genscripts + >$@ + +.PHONY: log +stampdir_targets+=log +log: $(STAMP_DIR)/log +$(STAMP_DIR)/log: $(STAMP_DIR)/stampdir + mkdir -p $(STAMP_DIR)/log + +# Apply all patches to the upstream source. +.PHONY: patch +stampdir_targets+=patch +patch: $(STAMP_DIR)/patch +$(STAMP_DIR)/patch: $(STAMP_DIR)/prepare + if ! [ `which quilt` ]; then \ + echo "Couldn't find quilt. Please install it or add it to the build-depends for this package."; \ + exit 1; \ + fi; \ + if $(QUILT) next >/dev/null 2>&1; then \ + echo -n "Applying patches..."; \ + if $(QUILT) push -a -v >$(STAMP_DIR)/log/patch 2>&1; then \ + cat $(STAMP_DIR)/log/patch; \ + echo "successful."; \ + else \ + cat $(STAMP_DIR)/log/patch; \ + echo "failed! (check $(STAMP_DIR)/log/patch for details)"; \ + exit 1; \ + fi; \ + else \ + echo "No patches to apply"; \ + fi; \ + >$@ + +# Revert all patches to the upstream source. +.PHONY: unpatch +unpatch: $(STAMP_DIR)/log + rm -f $(STAMP_DIR)/patch + @echo -n "Unapplying patches..."; \ + if $(QUILT) applied >/dev/null 2>/dev/null; then \ + if $(QUILT) pop -a -v >$(STAMP_DIR)/log/unpatch 2>&1; then \ + cat $(STAMP_DIR)/log/unpatch; \ + echo "successful."; \ + else \ + cat $(STAMP_DIR)/log/unpatch; \ + echo "failed! (check $(STAMP_DIR)/log/unpatch for details)"; \ + exit 1; \ + fi; \ + else \ + echo "nothing to do."; \ + fi + +# Clean the generated maintainer scripts. +.PHONY: cleanscripts +cleanscripts: + rm -f $(STAMP_DIR)/genscripts + rm -f debian/*.config \ + debian/*.postinst \ + debian/*.postrm \ + debian/*.preinst \ + debian/*.prerm + +# Clean the package build tree. +.PHONY: xsfclean +xsfclean: cleanscripts unpatch + dh_testdir + rm -rf .pc + rm -rf $(STAMP_DIR) $(SOURCE_DIR) + rm -rf imports + dh_clean debian/shlibs.local \ + debian/po/pothead + +# Generate the debconf templates POT file header. +debian/po/pothead: debian/po/pothead.in + sed -e 's/SOURCE_VERSION/$(SOURCE_VERSION)/' \ + -e 's/DATE/$(shell date "+%F %X%z"/)' <$< >$@ + +# Update POT and PO files. +.PHONY: updatepo +updatepo: debian/po/pothead + debian/scripts/debconf-updatepo --pot-header=pothead --verbose + +# Remove files from the upstream source tree that we don't need, or which have +# licensing problems. It must be run before creating the .orig.tar.gz. +# +# Note: This rule is for Debian package maintainers' convenience, and is not +# needed for conventional build scenarios. +.PHONY: prune-upstream-tree +prune-upstream-tree: + # Ensure we're in the correct directory. + dh_testdir + grep -rvh '^#' debian/prune/ | xargs --no-run-if-empty rm -rf + +# Verify that there are no offsets or fuzz in the patches we apply. +# +# Note: This rule is for Debian package maintainers' convenience, and is not +# needed for conventional build scenarios. +.PHONY: patch-audit +patch-audit: prepare unpatch + @echo -n "Auditing patches..."; \ + >$(STAMP_DIR)/log/patch; \ + FUZZY=; \ + while [ -n "$$($(QUILT) next)" ]; do \ + RESULT=$$($(QUILT) push -v | tee -a $(STAMP_DIR)/log/patch | grep ^Hunk | sed 's/^Hunk.*\(succeeded\|FAILED\).*/\1/');\ + case "$$RESULT" in \ + succeeded) \ + echo "fuzzy patch: $$($(QUILT) top)" \ + | tee -a $(STAMP_DIR)/log/$$($(QUILT) top); \ + FUZZY=yes; \ + ;; \ + FAILED) \ + echo "broken patch: $$($(QUILT) next)" \ + | tee -a $(STAMP_DIR)/log/$$($(QUILT) next); \ + exit 1; \ + ;; \ + esac; \ + done; \ + if [ -n "$$FUZZY" ]; then \ + echo "there were fuzzy patches; please fix."; \ + exit 1; \ + else \ + echo "done."; \ + fi + +# Generate the maintainer scripts. +.PHONY: genscripts +stampdir_targets+=genscripts +genscripts: $(STAMP_DIR)/genscripts +$(STAMP_DIR)/genscripts: $(STAMP_DIR)/stampdir + for FILE in debian/*.config.in \ + debian/*.postinst.in \ + debian/*.postrm.in \ + debian/*.preinst.in \ + debian/*.prerm.in; do \ + if [ -e "$$FILE" ]; then \ + MAINTSCRIPT=$$(echo $$FILE | sed 's/.in$$//'); \ + sed -n '1,/^#INCLUDE_SHELL_LIB#$$/p' <$$FILE \ + | sed -e '/^#INCLUDE_SHELL_LIB#$$/d' >$$MAINTSCRIPT.tmp; \ + cat debian/xsfbs/xsfbs.sh >>$$MAINTSCRIPT.tmp; \ + sed -n '/^#INCLUDE_SHELL_LIB#$$/,$$p' <$$FILE \ + | sed -e '/^#INCLUDE_SHELL_LIB#$$/d' >>$$MAINTSCRIPT.tmp; \ + sed -e 's/@SOURCE_VERSION@/$(SOURCE_VERSION)/' \ + -e 's/@OFFICIAL_BUILD@/$(OFFICIAL_BUILD)/' \ + -e 's/@DEFAULT_DCRESOLUTIONS@/$(DEFAULT_DCRESOLUTIONS)/' \ + <$$MAINTSCRIPT.tmp >$$MAINTSCRIPT; \ + rm $$MAINTSCRIPT.tmp; \ + fi; \ + done + # Validate syntax of generated shell scripts. + #sh debian/scripts/validate-posix-sh debian/*.config \ + # debian/*.postinst \ + # debian/*.postrm \ + # debian/*.preinst \ + # debian/*.prerm + >$@ + +# Generate the shlibs.local file. +debian/shlibs.local: + cat debian/*.shlibs >$@ + +SERVERMINVERS = $(shell cat /usr/share/xserver-xorg/serverminver 2>/dev/null) +VIDEOABI = $(shell cat /usr/share/xserver-xorg/videoabiver 2>/dev/null) +INPUTABI = $(shell cat /usr/share/xserver-xorg/inputabiver 2>/dev/null) +SERVER_DEPENDS = xserver-xorg-core (>= $(SERVERMINVERS)) +VIDDRIVER_PROVIDES = xserver-xorg-video-$(VIDEOABI) +INPDRIVER_PROVIDES = xserver-xorg-input-$(INPUTABI) +ifeq ($(PACKAGE),) +PACKAGE=$(shell awk '/^Package:/ { print $$2; exit }' < debian/control) +endif + +.PHONY: serverabi +serverabi: install +ifeq ($(SERVERMINVERS),) + @echo error: xserver-xorg-dev needs to be installed + @exit 1 +else + echo "xserver:Depends=$(SERVER_DEPENDS)" >> debian/$(PACKAGE).substvars + echo "xviddriver:Provides=$(VIDDRIVER_PROVIDES)" >> debian/$(PACKAGE).substvars + echo "xinpdriver:Provides=$(INPDRIVER_PROVIDES)" >> debian/$(PACKAGE).substvars +endif + +# vim:set noet ai sts=8 sw=8 tw=0: --- xorg-server-1.4.99.906.orig/debian/xserver-xorg-core.install +++ xorg-server-1.4.99.906/debian/xserver-xorg-core.install @@ -0,0 +1,16 @@ +usr/lib/xorg/modules/*.so +usr/lib/xorg/modules/extensions/*.so +usr/lib/xorg/modules/fonts/* +usr/lib/xorg/modules/linux/*.so +usr/lib/xorg/modules/freebsd/*.so +usr/lib/xorg/modules/multimedia/*.so +usr/bin/Xorg +usr/share/man/man1/Xserver.1 +usr/share/man/man1/Xorg.1 +usr/share/man/man4/exa.4 +usr/share/man/man4/fbdevhw.4 +usr/share/man/man5/xorg.conf.5 +usr/bin/cvt +usr/bin/gtf +usr/share/man/man1/cvt.1 +usr/share/man/man1/gtf.1 --- xorg-server-1.4.99.906.orig/debian/local/xvfb-run +++ xorg-server-1.4.99.906/debian/local/xvfb-run @@ -0,0 +1,183 @@ +#!/bin/sh + +# $Id: xvfb-run 2027 2004-11-16 14:54:16Z branden $ + +# This script starts an instance of Xvfb, the "fake" X server, runs a command +# with that server available, and kills the X server when done. The return +# value of the command becomes the return value of this script. +# +# If anyone is using this to build a Debian package, make sure the package +# Build-Depends on xvfb, xbase-clients, and xfonts-base. + +set -e + +PROGNAME=xvfb-run +SERVERNUM=99 +AUTHFILE= +ERRORFILE=/dev/null +STARTWAIT=3 +XVFBARGS="-screen 0 640x480x8" +LISTENTCP="-nolisten tcp" +XAUTHPROTO=. + +# Query the terminal to establish a default number of columns to use for +# displaying messages to the user. This is used only as a fallback in the event +# the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while the +# script is running, and this cannot, only being calculated once.) +DEFCOLUMNS=$(stty size 2>/dev/null | awk '{print $2}') || true +if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" >/dev/null 2>&1; then + DEFCOLUMNS=80 +fi + +# Display a message, wrapping lines at the terminal width. +message () { + echo "$PROGNAME: $*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} +} + +# Display an error message. +error () { + message "error: $*" >&2 +} + +# Display a usage message. +usage () { + if [ -n "$*" ]; then + message "usage error: $*" + fi + cat <"$ERRORFILE" 2>&1 + fi + if [ -n "$XVFB_RUN_TMPDIR" ]; then + if ! rm -r "$XVFB_RUN_TMPDIR"; then + error "problem while cleaning up temporary directory" + exit 5 + fi + fi +} + +# Parse the command line. +ARGS=$(getopt --options +ae:f:hn:lp:s:w: \ + --long auto-servernum,error-file:,auth-file:,help,server-num:,listen-tcp,xauth-protocol:,server-args:,wait: \ + --name "$PROGNAME" -- "$@") +GETOPT_STATUS=$? + +if [ $GETOPT_STATUS -ne 0 ]; then + error "internal error; getopt exited with status $GETOPT_STATUS" + exit 6 +fi + +eval set -- "$ARGS" + +while :; do + case "$1" in + -a|--auto-servernum) SERVERNUM=$(find_free_servernum) ;; + -e|--error-file) ERRORFILE="$2"; shift ;; + -f|--auth-file) AUTHFILE="$2"; shift ;; + -h|--help) SHOWHELP="yes" ;; + -n|--server-num) SERVERNUM="$2"; shift ;; + -l|--listen-tcp) LISTENTCP="" ;; + -p|--xauth-protocol) XAUTHPROTO="$2"; shift ;; + -s|--server-args) XVFBARGS="$2"; shift ;; + -w|--wait) STARTWAIT="$2"; shift ;; + --) shift; break ;; + *) error "internal error; getopt permitted \"$1\" unexpectedly" + exit 6 + ;; + esac + shift +done + +if [ "$SHOWHELP" ]; then + usage + exit 0 +fi + +if [ -z "$*" ]; then + usage "need a command to run" >&2 + exit 2 +fi + +if ! which xauth >/dev/null; then + error "xauth command not found" + exit 3 +fi + +# tidy up after ourselves +trap clean_up EXIT + +# If the user did not specify an X authorization file to use, set up a temporary +# directory to house one. +if [ -z "$AUTHFILE" ]; then + XVFB_RUN_TMPDIR="${TMPDIR:-/tmp}/$PROGNAME.$$" + if ! mkdir -p -m 700 "$XVFB_RUN_TMPDIR"; then + error "temporary directory $XVFB_RUN_TMPDIR already exists" + exit 4 + fi + AUTHFILE=$(tempfile -n "$XVFB_RUN_TMPDIR/Xauthority") +fi + +# Start Xvfb. +MCOOKIE=$(mcookie) +XAUTHORITY=$AUTHFILE xauth add ":$SERVERNUM" "$XAUTHPROTO" "$MCOOKIE" \ + >"$ERRORFILE" 2>&1 +XAUTHORITY=$AUTHFILE Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP >"$ERRORFILE" \ + 2>&1 & +XVFBPID=$! +sleep "$STARTWAIT" +if ! kill -0 $XVFBPID 2>/dev/null; then + echo "Xvfb failed to start" >&2 + exit 1 +fi + +# Start the command and save its exit status. +set +e +DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1 +RETVAL=$? +set -e + +# Kill Xvfb now that the command has exited. +kill $XVFBPID + +# Return the executed command's exit status. +exit $RETVAL + +# vim:set ai et sts=4 sw=4 tw=80: --- xorg-server-1.4.99.906.orig/debian/local/xvfb-run.1 +++ xorg-server-1.4.99.906/debian/local/xvfb-run.1 @@ -0,0 +1,282 @@ +.\" $Id: xvfb-run.1 2138 2005-01-17 23:40:27Z branden $ +.\" +.\" Copyright 1998-2004 Branden Robinson . +.\" +.\" This is free software; you may redistribute it and/or modify +.\" it under the terms of the GNU General Public License as +.\" published by the Free Software Foundation; either version 2, +.\" or (at your option) any later version. +.\" +.\" This is distributed in the hope that it will be useful, but +.\" WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License with +.\" the Debian operating system, in /usr/share/common-licenses/GPL; if +.\" not, write to the Free Software Foundation, Inc., 59 Temple Place, +.\" Suite 330, Boston, MA 02111-1307 USA +.\" +.\" We need the URL macro from groff's www macro package, but also want +.\" things to work all right for people who don't have it. So we define +.\" our own URL macro and let the www macro package override it if it's +.\" available. +.de URL +\\$2 \(laURL: \\$1 \(ra\\$3 +.. +.if \n[.g] .mso www.tmac +.TH xvfb\-run 1 "2004\-11\-12" "Debian Project" +.SH NAME +xvfb\-run \- run specified X client or command in a virtual X server environment +.SH SYNOPSIS +.B xvfb\-run +[ +.I options +] +.I command +.SH DESCRIPTION +.B xvfb\-run +is a wrapper for the +.BR Xvfb (1x) +command which simplifies the task of running commands (typically an X +client, or a script containing a list of clients to be run) within a virtual +X server environment. +.PP +.B xvfb\-run +sets up an X authority file (or uses an existing user\-specified one), +writes a cookie to it (see +.BR xauth (1x)) +and then starts the +.B Xvfb +X server as a background process. +The process ID of +.B Xvfb +is stored for later use. +The specified +.I command +is then run using the X display corresponding to the +.B Xvfb +server +just started and the X authority file created earlier. +.PP +When the +.I command +exits, its status is saved, the +.B Xvfb +server is killed (using the process ID stored earlier), the X authority +cookie removed, and the authority file deleted (if the user did not specify +one to use). +.B xvfb\-run +then exits with the exit status of +.IR command . +.PP +.B xvfb\-run +requires the +.B xauth +command to function. +.SH OPTIONS +.TP +.B \-a\fR,\fB \-\-auto\-servernum +Try to get a free server number, starting at 99, or the argument to +.BR \-\-server\-num . +.TP +.BI \-e\ file \fR,\fB\ \-\-error\-file= file +Store output from +.B xauth +and +.B Xvfb +in +.IR file . +The default is +.IR /dev/null . +.TP +.BI \-f\ file \fR,\fB\ \-\-auth\-file= file +Store X authentication data in +.IR file . +By default, a temporary directory called +.IR xvfb\-run. PID +(where PID is the process ID of +.B xvfb\-run +itself) is created in the directory specified by the environment variable +.B TMPDIR +(or +.I /tmp +if that variable is null or unset), and the +.BR tempfile (1) +command is used to create a file in that temporary directory called +.IR Xauthority . +.TP +.B \-h\fR,\fB \-\-help +Display a usage message and exit. +.TP +.BI \-n\ servernumber \fR,\fB\ \-\-server\-num= servernumber +Use +.I servernumber +as the server number (but see the +.B \-a\fR,\fB \-\-auto\-servernum +option above). +The default is 99. +.TP +.B \-l\fR,\fB \-\-listen\-tcp +Enable TCP port listening in the X server. +For security reasons (to avoid denial\-of\-service attacks or exploits), +TCP port listening is disabled by default. +.TP +.BI \-p\ protocolname \fR,\fB\ \-\-xauth\-protocol= protocolname +Use +.I protocolname +as the X authority protocol to use. +The default is \(oq.\(cq, which +.B xauth +interprets as its own default protocol, which is MIT\-MAGIC\-COOKIE\-1. +.TP +.BI \-s\ arguments \fR,\fB\ \-\-server\-args= arguments +Pass +.I arguments +to the +.B Xvfb +server. +Be careful to quote any whitespace characters that may occur within +.I arguments +to prevent them from regarded as separators for +.BR xvfb\-run 's +own arguments. +Also, note that specification of \(oq\-nolisten tcp\(cq in +.I arguments +may override the function of +.BR xvfb\-run 's +own +.B \-l\fR,\fB \-\-listen\-tcp +option, and that specification of the server number (e.g., \(oq:1\(cq) may +be ignored because of the way the X server parses its argument list. +Use the +.B xvfb\-run +option +.BI \-n\ servernumber \fR,\fB\ \-\-server\-num= servernumber +to achieve the latter function. +The default is \(oq\-screen 0 640x480x8\(cq. +.TP +.BI \-w\ delay \fR,\fB\ \-\-wait= delay +Wait +.I delay +seconds after launching +.B Xvfb +before attempting to start the specified command. +The default is 3. +.SH ENVIRONMENT +.TP +.B COLUMNS +indicates the width of the terminal device in character cells. +This value is used for formatting diagnostic messages. +If not set, the terminal is queried using +.BR stty (1) +to determine its width. +If that fails, a value of \(oq80\(cq is assumed. +.TP +.B TMPDIR +specifies the directory in which to place +.BR xvfb\-run 's +temporary directory for storage of the X authority file; only used if the +.B \-f +or +.B \-\-auth\-file +options are not specified. +.SH "OUTPUT FILES" +.PP +Unless the +.B \-f +or +.B \-\-auth\-file +options are specified, a temporary +directory and file within it are created (and deleted) to store the X +authority cookies used by the +.B Xvfb +server and client(s) run under it. +See +.BR tempfile (1). +If \-f or \-\-auth\-file are used, then the specified X authority file is +only written to, not created or deleted (though +.B xauth +creates an authority file itself if told to use use that does not already +exist). +.PP +An error file with a user\-specified name is also created if the +.B \-e +or +.B \-\-error\-file +options are specifed; see above. +.SH "EXIT STATUS" +.B xvfb\-run +uses its exit status as well as output to standard error to communicate +diagnostics. +The exit status of \(oq1\(cq is not used, and should be interpreted as failure +of the specified command. +.TP +0 +.B xvfb\-run +only uses this exit status if the +.B \-h\fR,\fB \-\-help +option is given. +In all other situations, this may be interpreted as success of the specified +command. +.TP +2 +No command to run was specified. +.TP +3 +The +.B xauth +command is not available. +.TP +4 +The temporary directory that was going to be used already exists; since +.B xvfb\-run +produces a uniquely named directory, this may indicate an attempt by another +process on the system to exploit a temporary file race condition. +.TP +5 +A problem was encountered while cleaning up the temporary directory. +.TP +6 +A problem was encountered while using +.BR getopt (1) +to parse the command\-line arguments. +.SH EXAMPLES +.TP +.B xvfb\-run \-\-auto\-servernum \-\-server\-num=1 xlogo +runs the +.BR xlogo (1x) +demonstration client inside the +.B Xvfb +X server on the first available server number greater than or equal to 1. +.TP +.B xvfb\-run \-\-server\-args="\-screen 0 1024x768x24" ico \-faces +runs the +.BR ico (1x) +demonstration client (and passes it the +.B \-faces +argument) inside the +.B Xvfb +X server, configured with a root window of 1024 by 768 pixels and a color +depth of 24 bits. +.PP +Note that the demo X clients used in the above examples will not exit on +their own, so they will have to be killed before +.B xvfb\-run +will exit. +.SH BUGS +See +.URL "http://bugs.debian.org/xvfb" "the Debian Bug Tracking System" . +If you wish to report a bug in +.BR xvfb\-run , +please use the +.BR reportbug (1) +command. +.SH AUTHOR +.B xfvb\-run +was written by Branden Robinson and Jeff Licquia with sponsorship from +Progeny Linux Systems. +.SH "SEE ALSO" +.BR Xvfb (1x), +.BR xauth (1x) +.\" vim:set et tw=80: --- xorg-server-1.4.99.906.orig/debian/serverminver +++ xorg-server-1.4.99.906/debian/serverminver @@ -0,0 +1 @@ +2:1.4.99.905 --- xorg-server-1.4.99.906.orig/debian/videoabiver +++ xorg-server-1.4.99.906/debian/videoabiver @@ -0,0 +1 @@ +2.9 --- xorg-server-1.4.99.906.orig/debian/xnest.install +++ xorg-server-1.4.99.906/debian/xnest.install @@ -0,0 +1,2 @@ +usr/bin/Xnest +usr/share/man/man1/Xnest.1 --- xorg-server-1.4.99.906.orig/debian/xserver-xorg-core.postrm.in +++ xorg-server-1.4.99.906/debian/xserver-xorg-core.postrm.in @@ -0,0 +1,15 @@ +#!/bin/sh + +set -e + +THIS_PACKAGE=xserver-xorg-core +THIS_SCRIPT=postrm + +#INCLUDE_SHELL_LIB# + +if [ "$1" = "purge" ]; then + rm /var/log/Xorg.*.log || true + rm /var/log/Xorg.*.log.old || true +fi + +#DEBHELPER# --- xorg-server-1.4.99.906.orig/debian/xserver-xorg-core.NEWS +++ xorg-server-1.4.99.906/debian/xserver-xorg-core.NEWS @@ -0,0 +1,62 @@ +xorg-server (2:1.3.0.0.dfsg-3) unstable; urgency=low + + * The server now includes a patch to always include the font paths + defined at compile-time by default. This will help prevent errors with + finding fonts when a xorg.conf has alternate font paths specified. + + As a result of this, many of the font paths shipped in our default + xorg.conf are obsolete, and may be deleted. If you have no customized + your xorg.conf, a future update to the xserver-xorg package will + re-create the file from your stored preferences. + + If for some reason you do not want the server to look in the default + font paths, you can set the boolean variable "UseDefaultFontPath" to + "False" in the ServerFlags section of your xorg.conf. + + -- David Nusinow Tue, 24 Apr 2007 00:18:04 -0400 + +xorg-server (2:1.2.99.905-3) experimental; urgency=low + + * This server update includes a patch to enable proper module defaults in + the server. A default set of modules will be loaded unless you + specifically specify that they don't load. You may do this in the module + section of your xorg.conf using the "Disable" instruction. Note that + this will only override the default, not an explicit "Load". + + This change will not affect most users, however if you have a customized + xorg.conf in which you comment out "Load" lines to disable modules, you + will want to change those lines so that they are uncommented and say + "Disable" instead of "Load". The most notable example of this is the dri + module, which is now loaded by default. Those who experience crashes + when dri is enabled will want to make this change to ensure that their + system does not begin to crash again. + + -- David Nusinow Sat, 14 Apr 2007 12:41:37 -0400 + +xserver-xorg-core (1:1.0.2-5) unstable; urgency=low + + * Several users have reported an error on load like the following: + + "(EE) Failed to load module "GLcore" (loader failed, 7)" + + To resolve this error and the related ones in the logfile above it, + remove the line to load the glcore module in your /etc/X11/xorg.conf. + Other similar errors about module loading can be resolved the same way. + If you have not customized your config file by hand, you can run the + command "dpkg-reconfigure xserver-xorg" as root to do this for you. + + -- David Nusinow Wed, 12 Apr 2006 19:38:51 -0400 + +xserver-xorg-core (1:1.0.2-3) unstable; urgency=low + + * With the latest updates of Xorg, we have transitioned from X11R6 to + X11R7. Part of this transition involves changing the paths to the + xfonts and the xkb data files, as well as the modules loaded by the X + server. One way to automatically update the paths is to run + "dpkg-reconfigure xserver-xorg" as root and it will automatically + generate a new config file for you. Note that this will currently not + work for people who have customized config files due to a bug, so + you'll have to manually edit your config if you have customized it + previously. + + -- David Nusinow Wed, 12 Apr 2006 19:38:51 -0400 --- xorg-server-1.4.99.906.orig/debian/control +++ xorg-server-1.4.99.906/debian/control @@ -0,0 +1,219 @@ +Source: xorg-server +Section: x11 +Priority: optional +Maintainer: Ubuntu Core Developers +XSBC-Original-Maintainer: Debian X Strike Force +Uploaders: David Nusinow , Steve Langasek , Julien Cristau , Drew Parsons +# all the Build-Depends up to x11proto-xf86-dri-dev are for the normal Xorg +# server, and common dependencies for the DIX. +# x11proto-xf86dri-dev and libdrm-dev are for DRI support for the Xorg server. +# x11proto-print-dev and libfreetype6-dev are for Xprint +# everything on is for the DMX and Xnest servers. +Build-Depends: debhelper (>= 4.0.0), lsb-release, pkg-config, bison, flex, + automake, libtool, xutils-dev, + x11proto-bigreqs-dev, x11proto-composite-dev (>= 1:0.4), x11proto-core-dev (>= 7.0.9), + x11proto-damage-dev (>= 1.1), x11proto-evie-dev, x11proto-fixes-dev (>= 4.0), + x11proto-kb-dev (>= 1.0.3), x11proto-xinerama-dev, x11proto-randr-dev (>= 1.2), + x11proto-record-dev, x11proto-render-dev (>= 2:0.9.3), x11proto-resource-dev, + x11proto-scrnsaver-dev, x11proto-trap-dev, x11proto-video-dev, + x11proto-xcmisc-dev, x11proto-xext-dev (>= 6.9.99.0), + x11proto-xf86bigfont-dev, x11proto-xf86dga-dev, x11proto-xf86misc-dev, + x11proto-xf86vidmode-dev, xtrans-dev, libxau-dev (>= 1:0.99.1), + x11proto-input-dev (>= 1.4.2), + libxdmcp-dev (>= 1:0.99.1), libxfont-dev, libfontenc-dev, + libxkbfile-dev (>= 1:0.99.1), libpixman-1-dev (>= 0.9.5), + libpciaccess-dev, libssl-dev, + x11proto-xf86dri-dev, libdrm-dev (>= 2.3.1) [!hurd-i386], + x11proto-print-dev, libfreetype6-dev, xfonts-utils, + x11proto-gl-dev (>= 1.4.9), libgl1-mesa-dev (>= 7.1~rc1), + libxmuu-dev (>= 1:0.99.1), libxext-dev (>= 1:0.99.1), + libx11-dev (>= 1:0.99.2), libxrender-dev (>= 1:0.9.0), + libxi-dev (>= 1:0.99.1), x11proto-dmx-dev, quilt, libdmx-dev (>= 1:1.0.1), + libxpm-dev (>= 1:3.5.3), libxaw7-dev (>= 1:0.99.1), + libxt-dev (>= 1:0.99.1), libxmu-dev (>= 1:0.99.1), + libxtst-dev (>= 1:0.99.1), libxres-dev (>= 1:0.99.1), + libxfixes-dev (>= 1:3.0.0), libdbus-1-dev [!hurd-i386], + libhal-dev [!hurd-i386], libxv-dev, mesa-common-dev (>= 7.1~rc1) +Build-Conflicts: xlibs-static-dev +Standards-Version: 3.7.3 +Vcs-Git: git://git.debian.org/git/pkg-xorg/xserver/xorg-server +Vcs-Browser: http://git.debian.org/?p=pkg-xorg/xserver/xorg-server.git + +Package: xserver-xorg-core +Architecture: any +Depends: x11-common (>= 1:7.0.0), ${shlibs:Depends}, ${misc:Depends}, xserver-xorg +Recommends: xkb-data, xfonts-base, libgl1-mesa-dri (>= 7.1~rc1) +Suggests: xfonts-100dpi | xfonts-75dpi, xfonts-scalable +Conflicts: xserver-xorg (<< 6.8.2-38), xserver-xfree86 (<< 1:7.0.0), + xserver-xorg-video, xserver-common, xserver-xorg-video-1.0, xserver-xorg-input, + xserver-xorg-video-1.9, xserver-xorg-input-wacom (<< 0.7.8), + xserver-xorg-video-2, xserver-xorg-input-2 +Replaces: xserver-xorg (<< 6.8.2-38), xserver-xfree86 (<< 1:7.0.0), + xserver-common +Provides: xserver +Description: Xorg X server - core server + The Xorg X server is an X server for several architectures and operating + systems, which is derived from the XFree86 4.x series of X servers. + . + The Xorg server supports most modern graphics hardware from most vendors, + and supersedes all XFree86 X servers. + . + The Xorg server either needs fonts installed on the local host, or needs to + know of a remote hosts that provides font services (with xfs, for instance). + The former means that fonts packages are mandatory. The latter means that + font packages may be gratuitous. To err on the side of caution, install at + least the xfonts-base, xfonts-100dpi or xfonts-75dpi, and xfonts-scalable + packages. + . + More information about X.Org can be found at: + + + + . + This package is built from the X.org xserver module. + +Package: xserver-xorg-dev +Architecture: any +Depends: ${misc:Depends}, libpixman-1-dev, x11proto-core-dev, x11proto-input-dev (>= 1.4), x11proto-xext-dev, x11proto-video-dev, x11proto-randr-dev (>= 1.2), x11proto-render-dev (>= 2:0.9.3), x11proto-fonts-dev, libpciaccess-dev +Description: Xorg X server - development files + This package provides development files for the X.Org ('Xorg') X server. + This is not quite the same as the DDK (Driver Development Kit) from the + XFree86 4.x and X.Org 6.7, 6.8 and 6.9 series of servers; it provides + headers and a pkg-config file for drivers using autotools to build + against. + . + Unless you are developing or building a driver, you probably want + xserver-xorg and/or xserver-xorg-core instead. + . + More information about X.Org can be found at: + + + + . + This package is built from the X.org xserver module. + +Package: xdmx +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: distributed multihead X server + Xdmx is a proxy X server that uses one or more other X servers as its + display device(s). It provides multi-head X functionality for displays that + might be located on different machines. Xdmx functions as a front-end X server + that acts as a proxy to a set of back-end X servers. All of the visible + rendering is passed to the back-end X servers. Clients connect to the Xdmx + front-end, and everything appears as it would in a regular multi-head + configuration. If Xinerama is enabled (e.g., with +xinerama on the command + line), the clients see a single large screen. + . + More information about X.Org can be found at: + + + + . + This package is built from the X.org xserver module. + +Package: xdmx-tools +Architecture: any +Depends: xdmx, ${shlibs:Depends}, ${misc:Depends} +Replaces: xdmx (<= 2:1.1.1-10) +Description: Distributed Multihead X tools + This package provides a collection of tools used for administration of + the Xdmx server; see the xdmx package for more information. + . + More information about X.Org can be found at: + + + + . + This package is built from the X.org xserver module. + +Package: xnest +Architecture: any +Depends: x11-common, ${shlibs:Depends}, ${misc:Depends} +Recommends: libgl1-mesa-dri (>= 7.1~rc1) +Description: Nested X server + Xnest is a nested X server that simply relays all its requests to another + X server, where it runs as a client. This means that it appears as another + window in your current X session. Xnest relies upon its parent X server + for font services. + . + Use of the Xephyr X server instead of Xnest is recommended. + . + More information about X.Org can be found at: + + + + . + This package is built from the X.org xserver module. + +Package: xvfb +Architecture: any +Depends: x11-common, ${shlibs:Depends}, ${misc:Depends}, xauth, xfonts-base +Description: Virtual Framebuffer 'fake' X server + Xvfb provides an X server that can run on machines with no display hardware + and no physical input devices. It emulates a dumb framebuffer using virtual + memory. The primary use of this server was intended to be server testing, + but other novel uses for it have been found, including testing clients + against unusual depths and screen configurations, doing batch processing with + Xvfb as a background rendering engine, load testing, as an aid to porting the + X server to a new platform, and providing an unobtrusive way to run + applications that don't really need an X server but insist on having one + anyway. + . + This package also contains a convenience script called xvfb-run which + simplifies the automated execution of X clients in a virtual server + environment. This convenience script requires the use of the xauth + program. + . + More information about X.Org can be found at: + + + + . + This package is built from the X.org xserver module. + +Package: xserver-xephyr +Architecture: any +Depends: x11-common, ${shlibs:Depends}, ${misc:Depends} +Recommends: xbase-clients, xfonts-base, libgl1-mesa-dri (>= 7.1~rc1) +Description: nested X server + Xephyr is an X server that can be run inside another X server, + much like Xnest. It is based on the kdrive X server, and as a + result it supports newer extensions than Xnest, including render and + composite. + . + More information about X.Org can be found at: + + + + . + This package is built from the X.org xserver module. + +Package: xserver-xfbdev +Architecture: alpha amd64 arm armeb armel hppa i386 ia64 lpia m32r m68k mips mipsel powerpc ppc64 sh3 sh3eb sh4 sh4eb sparc +Depends: ${shlibs:Depends}, ${misc:Depends} +Recommends: xbase-clients, xfonts-base +Description: Linux framebuffer device tiny X server + xserver-xfbdev is a Linux framebuffer device tiny X server based on the + kdrive X server. + . + More information about X.Org can be found at: + + + + . + This package is built from the X.org xserver module. + +Package: xserver-xorg-core-dbg +Architecture: any +Depends: xserver-xorg-core (= ${binary:Version}) +Priority: extra +Description: Xorg - the X.Org X server (debugging symbols) + The Xorg X server is an X server for several architectures and operating + systems, which is derived from the XFree86 4.x series of X servers. + . + The Xorg server supports most modern graphics hardware from most vendors, + and supersedes all XFree86 X servers. + . + This package provides debugging symbols for the Xorg X server and associated + modules. --- xorg-server-1.4.99.906.orig/debian/xdmx.install +++ xorg-server-1.4.99.906/debian/xdmx.install @@ -0,0 +1,2 @@ +usr/bin/Xdmx +usr/share/man/man1/Xdmx.1 --- xorg-server-1.4.99.906.orig/debian/patches/132_add_parsing_for_xkb.options.patch +++ xorg-server-1.4.99.906/debian/patches/132_add_parsing_for_xkb.options.patch @@ -0,0 +1,68 @@ +From: Peter Hutterer +Date: Tue, 29 Jul 2008 03:29:57 +0000 (+0930) +Subject: config: add parsing for input.x11_options.XkbOptions. #16874 +X-Git-Url: http://gitweb.freedesktop.org/?p=xorg/xserver.git;a=commitdiff;h=35b14519b4a3158592a089170ec039bbc219603e + +config: add parsing for input.x11_options.XkbOptions. #16874 + +X.Org Bug 16874 +--- + +--- a/config/hal.c ++++ b/config/hal.c +@@ -1,5 +1,6 @@ + /* + * Copyright © 2007 Daniel Stone ++ * Copyright © 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), +@@ -54,6 +55,7 @@ struct xkb_options { + char* model; + char* rules; + char* variant; ++ char* options; + }; + + +@@ -284,6 +286,11 @@ device_added(LibHalContext *hal_ctx, con + if (xkb_opts.variant) + xfree(xkb_opts.variant); + xkb_opts.variant = strdup(tmp_val); ++ } else if (!strcasecmp(&tmp[3], "options")) ++ { ++ if (xkb_opts.options) ++ xfree(xkb_opts.options); ++ xkb_opts.options = strdup(tmp_val); + } + } else + { +@@ -318,6 +325,10 @@ device_added(LibHalContext *hal_ctx, con + { + if (!xkb_opts.model) + xkb_opts.model = strdup(tmp_val); ++ } else if (!strcasecmp(tmp, "options")) ++ { ++ if (!xkb_opts.options) ++ xkb_opts.options = strdup(tmp_val); + } + xfree(tmp_val); + } +@@ -338,6 +349,8 @@ device_added(LibHalContext *hal_ctx, con + add_option(&options, "xkb_variant", xkb_opts.variant); + if (xkb_opts.model) + add_option(&options, "xkb_model", xkb_opts.model); ++ if (xkb_opts.options) ++ add_option(&options, "xkb_options", xkb_opts.options); + + /* this isn't an error, but how else do you output something that the user can see? */ + LogMessage(X_INFO, "config/hal: Adding input device %s\n", name); +@@ -379,6 +392,8 @@ unwind: + xfree(xkb_opts.model); + if (xkb_opts.variant) + xfree(xkb_opts.variant); ++ if (xkb_opts.options) ++ xfree(xkb_opts.options); + + dbus_error_free(&error); + --- xorg-server-1.4.99.906.orig/debian/patches/123_no_composite_for_xvfb_run.patch +++ xorg-server-1.4.99.906/debian/patches/123_no_composite_for_xvfb_run.patch @@ -0,0 +1,11 @@ +--- debian/local/xvfb-run 2006-10-13 18:42:49.000000000 +0200 ++++ xorg-server-1.1.1/debian/local/xvfb-run 2006-10-13 18:42:37.000000000 +0200 +@@ -16,7 +16,7 @@ + AUTHFILE= + ERRORFILE=/dev/null + STARTWAIT=3 +-XVFBARGS="-screen 0 640x480x8" ++XVFBARGS="-screen 0 640x480x8 -extension Composite" + LISTENTCP="-nolisten tcp" + XAUTHPROTO=. + --- xorg-server-1.4.99.906.orig/debian/patches/133_support_strlist_for_xkboptions.patch +++ xorg-server-1.4.99.906/debian/patches/133_support_strlist_for_xkboptions.patch @@ -0,0 +1,88 @@ +From: Peter Hutterer +Date: Fri, 1 Aug 2008 04:54:54 +0000 (+0930) +Subject: config: support type strlist for XkbOptions property. +X-Git-Url: http://gitweb.freedesktop.org/?p=xorg/xserver.git;a=commitdiff;h=92c51b183c2ff06361dad7f918daed6577ba4935 + +config: support type strlist for XkbOptions property. + +For backwards compatibility with server 1.4. +--- + +--- a/config/hal.c ++++ b/config/hal.c +@@ -132,9 +132,6 @@ get_prop_string(LibHalContext *hal_ctx, + return ret; + } + +-/* this function is no longer used... keep it here in case its needed in +- * the future. */ +-#if 0 + static char * + get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop) + { +@@ -168,7 +165,6 @@ get_prop_string_array(LibHalContext *hal + + return ret; + } +-#endif + + static void + device_added(LibHalContext *hal_ctx, const char *udi) +@@ -250,12 +246,12 @@ device_added(LibHalContext *hal_ctx, con + + /* normal options first (input.x11_options.) */ + if (!strncasecmp(psi_key, LIBHAL_PROP_KEY, sizeof(LIBHAL_PROP_KEY)-1)){ ++ char* tmp; + + /* only support strings for all values */ + tmp_val = get_prop_string(hal_ctx, udi, psi_key); + + if (tmp_val){ +- char* tmp; + + /* xkb needs special handling. HAL specs include + * input.xkb.xyz options, but the x11-input.fdi specifies +@@ -298,14 +294,25 @@ device_added(LibHalContext *hal_ctx, con + add_option(&options, psi_key + sizeof(LIBHAL_PROP_KEY)-1, tmp_val); + xfree(tmp_val); + } ++ } else ++ { ++ /* server 1.4 had xkb_options as strlist. */ ++ if ((tmp = strcasestr(psi_key, "xkb")) && ++ (!strcasecmp(&tmp[3], "options")) && ++ (tmp_val = get_prop_string_array(hal_ctx, udi, psi_key))) ++ { ++ if (xkb_opts.options) ++ xfree(xkb_opts.options); ++ xkb_opts.options = strdup(tmp_val); ++ } + } + } else if (!strncasecmp(psi_key, LIBHAL_XKB_PROP_KEY, sizeof(LIBHAL_XKB_PROP_KEY)-1)){ ++ char* tmp; + + /* only support strings for all values */ + tmp_val = get_prop_string(hal_ctx, udi, psi_key); + + if (tmp_val){ +- char* tmp; + + tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1]; + +@@ -331,6 +338,16 @@ device_added(LibHalContext *hal_ctx, con + xkb_opts.options = strdup(tmp_val); + } + xfree(tmp_val); ++ } else ++ { ++ /* server 1.4 had xkb options as strlist */ ++ tmp_val = get_prop_string_array(hal_ctx, udi, psi_key); ++ if (tmp_val) ++ { ++ tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1]; ++ if (!strcasecmp(tmp, ".options") && (!xkb_opts.options)) ++ xkb_opts.options = strdup(tmp_val); ++ } + } + } + } --- xorg-server-1.4.99.906.orig/debian/patches/135_rethrow_signals.patch +++ xorg-server-1.4.99.906/debian/patches/135_rethrow_signals.patch @@ -0,0 +1,19 @@ +diff -Nurp xorg-server-1.4.99.905/hw/xfree86/common/xf86Events.c xorg-server-1.4.99.905-working/hw/xfree86/common/xf86Events.c +--- xorg-server-1.4.99.905/hw/xfree86/common/xf86Events.c 2008-06-30 13:11:03.000000000 -0700 ++++ xorg-server-1.4.99.905-working/hw/xfree86/common/xf86Events.c 2008-07-14 08:23:51.000000000 -0700 +@@ -763,6 +763,15 @@ xf86SigHandler(int signo) + + xorg_backtrace(); + ++ switch (signo) { ++ case SIGSEGV: ++ case SIGBUS: ++ case SIGILL: ++ case SIGFPE: ++ ErrorF ("Caught signal %d. Server aborting\n", signo); ++ raise (signo); ++ } ++ + FatalError("Caught signal %d. Server aborting\n", signo); + } + --- xorg-server-1.4.99.906.orig/debian/patches/131_remove_open-coded_strcasestr.patch +++ xorg-server-1.4.99.906/debian/patches/131_remove_open-coded_strcasestr.patch @@ -0,0 +1,43 @@ +From: Daniel Stone +Date: Wed, 16 Jul 2008 00:00:25 +0000 (+0300) +Subject: HAL: Remove grotesque open-coded strcasestr +X-Git-Url: http://gitweb.freedesktop.org/?p=xorg/xserver.git;a=commitdiff;h=b8dd07f855c555af56cbf0f69df799f424da2cca + +HAL: Remove grotesque open-coded strcasestr + +Not only was this pretty ugly, but it didn't even work on systems +without strcasestr anyway, due to the define not being in dix-config.h. +Lack of strcasestr is handled transparently with the version from +FreeBSD now anyway, so, huzzah. +--- + +--- a/config/hal.c ++++ b/config/hal.c +@@ -262,17 +262,7 @@ device_added(LibHalContext *hal_ctx, con + * Since we can't predict the order in which the keys + * arrive, we need to store them. + */ +-#ifndef HAVE_STRCASESTR +- int psi_key_len = strlen(psi_key); +- char *lower_psi_key = xalloc(psi_key_len + 1); +- +- CopyISOLatin1Lowered((unsigned char *) lower_psi_key, +- (unsigned char *) psi_key, +- psi_key_len); +- if ((tmp = strstr(lower_psi_key, "xkb"))) +-#else + if ((tmp = strcasestr(psi_key, "xkb"))) +-#endif + { + if (!strcasecmp(&tmp[3], "layout")) + { +@@ -301,9 +291,6 @@ device_added(LibHalContext *hal_ctx, con + add_option(&options, psi_key + sizeof(LIBHAL_PROP_KEY)-1, tmp_val); + xfree(tmp_val); + } +-#ifndef HAVE_STRCASESTR +- xfree(lower_psi_key); +-#endif + } + } else if (!strncasecmp(psi_key, LIBHAL_XKB_PROP_KEY, sizeof(LIBHAL_XKB_PROP_KEY)-1)){ + --- xorg-server-1.4.99.906.orig/debian/patches/107_fedora_dont_backfill_bg_none.patch +++ xorg-server-1.4.99.906/debian/patches/107_fedora_dont_backfill_bg_none.patch @@ -0,0 +1,23 @@ +Disable backfilling of windows created with bg=none, which otherwise +would force a framebuffer readback. + +Index: xorg-server-1.2.0/composite/compalloc.c +=================================================================== +--- foo/composite/compalloc.c.orig 2007-09-18 18:16:24.000000000 -0700 ++++ foo/composite/compalloc.c 2007-09-18 18:16:48.000000000 -0700 +@@ -471,6 +471,7 @@ compNewPixmap (WindowPtr pWin, int x, in + pPixmap->screen_x = x; + pPixmap->screen_y = y; + ++#if 0 + if (pParent->drawable.depth == pWin->drawable.depth) + { + GCPtr pGC = GetScratchGC (pWin->drawable.depth, pScreen); +@@ -529,6 +530,7 @@ compNewPixmap (WindowPtr pWin, int x, in + if (pDstPicture) + FreePicture (pDstPicture, 0); + } ++#endif + return pPixmap; + } + --- xorg-server-1.4.99.906.orig/debian/patches/series +++ xorg-server-1.4.99.906/debian/patches/series @@ -0,0 +1,17 @@ +001_fedora_extramodes.patch +#06_use_proc_instead_of_sysfs_for_pci_domains.diff +13_debian_add_xkbpath_env_variable.diff +100_xserver_exa_force_greedy.patch +101_fedora_xserver-1.3.0-document-fontpath-correctly.patch +102_ubuntu_sharevts_load_cpu.patch +104_psb_auto.patch +107_fedora_dont_backfill_bg_none.patch +110_fedora_no_move_damage.patch +121_only_switch_vt_when_active.diff +123_no_composite_for_xvfb_run.patch +130_fedora_call_switchcorekeyboard.patch +131_remove_open-coded_strcasestr.patch +132_add_parsing_for_xkb.options.patch +133_support_strlist_for_xkboptions.patch +134_protect_against_out_of_bounds.patch +135_rethrow_signals.patch --- xorg-server-1.4.99.906.orig/debian/patches/13_debian_add_xkbpath_env_variable.diff +++ xorg-server-1.4.99.906/debian/patches/13_debian_add_xkbpath_env_variable.diff @@ -0,0 +1,27 @@ +--- xorg-server.orig/xkb/xkbInit.c ++++ xorg-server/xkb/xkbInit.c +@@ -805,6 +805,14 @@ + extern unsigned char XkbDfltAccessXOptions; + + int ++xkbInitGlobals() ++{ ++ char * xkbpath= getenv("XKBPATH"); ++ if (xkbpath!=NULL) ++ XkbBaseDirectory= xkbpath; ++} ++ ++int + XkbProcessArguments(int argc,char *argv[],int i) + { + if (strcmp(argv[i],"-kb")==0) { +--- xorg-server.orig/os/utils.c ++++ xorg-server/os/utils.c +@@ -685,6 +685,7 @@ + */ + void InitGlobals(void) + { ++ xkbInitGlobals(); + ddxInitGlobals(); + } + --- xorg-server-1.4.99.906.orig/debian/patches/001_fedora_extramodes.patch +++ xorg-server-1.4.99.906/debian/patches/001_fedora_extramodes.patch @@ -0,0 +1,85 @@ +From: Adam Jackson +Date: Sun, 28 Oct 2007 09:37:52 +0100 +Subject: [PATCH] Fedora extra modes list + +--- +Index: xorg-server/hw/xfree86/common/extramodes +=================================================================== +--- xorg-server.orig/hw/xfree86/common/extramodes ++++ xorg-server/hw/xfree86/common/extramodes +@@ -3,16 +3,75 @@ + // + // $XFree86: xc/programs/Xserver/hw/xfree86/etc/extramodes,v 1.5 2002/06/05 19:43:05 dawes Exp $ + // ++// NOTE: Please keep all video modes sorted in order of X res, then Y res for ++// ease of maintenance and readability. + + # 832x624 @ 75Hz (74.55Hz) (fix if the official/Apple spec is different) hsync: 49.725kHz + ModeLine "832x624" 57.284 832 864 928 1152 624 625 628 667 -Hsync -Vsync + ++# 1152x864 @ 60.00 Hz (GTF) hsync: 53.70 kHz; pclk: 81.62 MHz ++Modeline "1152x864" 81.62 1152 1216 1336 1520 864 865 868 895 -HSync +Vsync ++ ++# 1152x864 @ 70.00 Hz (GTF) hsync: 63.00 kHz; pclk: 96.77 MHz ++Modeline "1152x864" 96.77 1152 1224 1344 1536 864 865 868 900 -HSync +Vsync ++ ++# 1152x864 @ 75.00 Hz (GTF) hsync: 67.65 kHz; pclk: 104.99 MHz ++Modeline "1152x864" 104.99 1152 1224 1352 1552 864 865 868 902 -HSync +Vsync ++ ++# 1152x864 @ 85.00 Hz (GTF) hsync: 77.10 kHz; pclk: 119.65 MHz ++Modeline "1152x864" 119.65 1152 1224 1352 1552 864 865 868 907 -HSync +Vsync ++ ++# 1152x864 @ 85Hz (Red Hat custom modeline) ++ModeLine "1152x864" 121.5 1152 1216 1344 1568 864 865 868 911 +hsync -vsync ++ ++# 1152x864 @ 100.00 Hz (GTF) hsync: 91.50 kHz; pclk: 143.47 MHz ++Modeline "1152x864" 143.47 1152 1232 1360 1568 864 865 868 915 -HSync +Vsync ++ ++# 1360x768 59.96 Hz (CVT) hsync: 47.37 kHz; pclk: 72.00 MHz ++Modeline "1360x768" 72.00 1360 1408 1440 1520 768 771 781 790 +hsync -vsync ++ ++# 1360x768 59.80 Hz (CVT) hsync: 47.72 kHz; pclk: 84.75 MHz ++Modeline "1360x768" 84.75 1360 1432 1568 1776 768 771 781 798 -hsync +vsync ++ + # 1400x1050 @ 60Hz (VESA GTF) hsync: 65.5kHz + ModeLine "1400x1050" 122.0 1400 1488 1640 1880 1050 1052 1064 1082 +hsync +vsync + ++# 1400x1050 @ 70.00 Hz (GTF) hsync: 76.51 kHz; pclk: 145.06 MHz ++Modeline "1400x1050" 145.06 1400 1496 1648 1896 1050 1051 1054 1093 -HSync +Vsync ++ + # 1400x1050 @ 75Hz (VESA GTF) hsync: 82.2kHz + ModeLine "1400x1050" 155.8 1400 1464 1784 1912 1050 1052 1064 1090 +hsync +vsync + ++# 1400x1050 @ 85.00 Hz (GTF) hsync: 93.76 kHz; pclk: 179.26 MHz ++Modeline "1400x1050" 179.26 1400 1504 1656 1912 1050 1051 1054 1103 -HSync +Vsync ++ ++# 1440x900 @ 60.00 Hz (CVT) field rate 59.89 Hz; hsync: 55.93 kHz; pclk: 106.50 MHz ++Modeline "1440x900" 106.50 1440 1520 1672 1904 900 903 909 934 -HSync +Vsync ++ ++# 1600x1024 for SGI 1600 SW ++ModeLine "1600x1024" 103.125 1600 1600 1656 1664 1024 1024 1029 1030 +Hsync +Vsync ++ ++# 1680x1050 59.88 Hz (CVT 1.76MA-R) hsync: 64.67 kHz; pclk: 119.00 MHz ++Modeline "1680x1050" 119.00 1680 1728 1760 1840 1050 1053 1059 1080 +hsync -vsync ++ ++# 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz ++Modeline "1680x1050" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync ++ ++# 1680x1050 69.88 Hz (CVT) hsync: 76.58 kHz; pclk: 174.00 MHz ++Modeline "1680x1050" 174.00 1680 1800 1976 2272 1050 1053 1059 1096 -hsync +vsync ++ ++# 1680x1050 74.89 Hz (CVT 1.76MA) hsync: 82.31 kHz; pclk: 187.00 MHz ++Modeline "1680x1050" 187.00 1680 1800 1976 2272 1050 1053 1059 1099 -hsync +vsync ++ ++# 1680x1050 84.94 Hz (CVT 1.76MA) hsync: 93.86 kHz; pclk: 214.75 MHz ++Modeline "1680x1050" 214.75 1680 1808 1984 2288 1050 1053 1059 1105 -hsync +vsync ++ ++# 1920x1080 59.93 Hz (CVT 2.07M9-R) hsync: 66.59 kHz; pclk: 138.50 MHz ++Modeline "1920x1080" 138.50 1920 1968 2000 2080 1080 1083 1088 1111 +hsync -vsync ++ ++# 1920x1200 59.95 Hz (CVT 2.30MA-R) hsync: 74.04 kHz; pclk: 154.00 MHz ++Modeline "1920x1200" 154.00 1920 1968 2000 2080 1200 1203 1209 1235 +hsync -vsync ++ + # 1920x1440 @ 85Hz (VESA GTF) hsync: 128.5kHz + Modeline "1920x1440" 341.35 1920 2072 2288 2656 1440 1441 1444 1512 -hsync +vsync + --- xorg-server-1.4.99.906.orig/debian/patches/101_fedora_xserver-1.3.0-document-fontpath-correctly.patch +++ xorg-server-1.4.99.906/debian/patches/101_fedora_xserver-1.3.0-document-fontpath-correctly.patch @@ -0,0 +1,42 @@ +Index: xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre +=================================================================== +--- xorg-server.orig/hw/xfree86/doc/man/xorg.conf.man.pre 2008-06-18 10:28:16.000000000 +0300 ++++ xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre 2008-06-18 12:06:37.000000000 +0300 +@@ -356,11 +356,11 @@ + .PP + .RS 4 + .nf +-.I __projectroot__/lib/X11/fonts/misc/ +-.I __projectroot__/lib/X11/fonts/TTF/ +-.I __projectroot__/lib/X11/fonts/Type1/ +-.I __projectroot__/lib/X11/fonts/75dpi/ +-.I __projectroot__/lib/X11/fonts/100dpi/ ++.I __projectroot__/share/X11/fonts/misc/ ++.I __projectroot__/share/X11/fonts/TTF/ ++.I __projectroot__/share/X11/fonts/Type1/ ++.I __projectroot__/share/X11/fonts/75dpi/ ++.I __projectroot__/share/X11/fonts/100dpi/ + .fi + .RE + .PP +@@ -368,13 +368,13 @@ + .PP + .RS 4 + .nf +-.I __projectroot__/lib/X11/fonts/local/ +-.I __projectroot__/lib/X11/fonts/misc/ +-.I __projectroot__/lib/X11/fonts/75dpi/:unscaled +-.I __projectroot__/lib/X11/fonts/100dpi/:unscaled +-.I __projectroot__/lib/X11/fonts/Type1/ +-.I __projectroot__/lib/X11/fonts/75dpi/ +-.I __projectroot__/lib/X11/fonts/100dpi/ ++.I __projectroot__/share/X11/fonts/local/ ++.I __projectroot__/share/X11/fonts/misc/ ++.I __projectroot__/share/X11/fonts/75dpi/:unscaled ++.I __projectroot__/share/X11/fonts/100dpi/:unscaled ++.I __projectroot__/share/X11/fonts/Type1/ ++.I __projectroot__/share/X11/fonts/75dpi/ ++.I __projectroot__/share/X11/fonts/100dpi/ + .fi + .RE + .PP --- xorg-server-1.4.99.906.orig/debian/patches/06_use_proc_instead_of_sysfs_for_pci_domains.diff +++ xorg-server-1.4.99.906/debian/patches/06_use_proc_instead_of_sysfs_for_pci_domains.diff @@ -0,0 +1,36 @@ +Upstream commit 56f21bda1ce95741c88c423b60bd709eef26eb12 was supposed to +only avoid multiple scans of the PCI devices, but it actually also added +an "optimization" based on using sysfs files instead of /proc. However, +this code is broken, for instance because there are no ioctl handler on +/sys/bus/pci/devices/*/config files while there some on /proc/bus/pci/* + +It breaks the Xserver on architectures that require such ioctls to scan +the PCI devices and/or deal with PCI domains: +#422077: xserver-xorg: Fatal server error on sparc: xf86MapPciMem failed +#422095: xserver-xorg-core: fails to start on powerpc, no devices detected + +The following patch forces the server to behave as if we were running on +a 2.4 kernel while scanning PCI devices, so that the sysfs code is disabled. + +Upstream doesn't apply this patch since they want to fix the sysfs-code. +See https://bugs.freedesktop.org/show_bug.cgi?id=7248 + +Thanks to Jim Watson for testing! + +--- + hw/xfree86/os-support/bus/linuxPci.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: xorg-server-1.3.0.0.dfsg/hw/xfree86/os-support/bus/linuxPci.c +=================================================================== +--- xorg-server-1.3.0.0.dfsg.orig/hw/xfree86/os-support/bus/linuxPci.c 2007-05-10 21:51:55.000000000 +0200 ++++ xorg-server-1.3.0.0.dfsg/hw/xfree86/os-support/bus/linuxPci.c 2007-05-10 21:52:13.000000000 +0200 +@@ -148,7 +148,7 @@ + int domain, bus, dev, func; + char file[64]; + struct stat ignored; +- static int is26 = -1; ++ static int is26 = 0; + + domain = PCI_DOM_FROM_TAG(tag); + bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)); --- xorg-server-1.4.99.906.orig/debian/patches/09_debian_xserver_rtff.diff +++ xorg-server-1.4.99.906/debian/patches/09_debian_xserver_rtff.diff @@ -0,0 +1,52 @@ +$Id: 910_debian_Xserver_RTFF.diff 486 2005-08-03 04:51:11Z dnusinow $ + +Give the user a far stronger clue as to what to do when their font configuration +is horribly screwed up; this patch by Branden Robinson. + +Index: a/dix/main.c +=================================================================== +--- a/dix/main.c.orig 2006-11-13 19:59:22.000000000 +0100 ++++ b/dix/main.c 2006-11-26 01:55:13.000000000 +0100 +@@ -407,10 +407,42 @@ + defaultFontPath); + } + if (!SetDefaultFont(defaultTextFont)) ++#ifdef DEBIAN ++ FatalError("could not open default font '%s';\n" ++"the X server's font paths might be misconfigured, remote font server(s)\n" ++"may be unreachable, and/or local fonts may not be installed or are not\n" ++"configured correctly.\n" ++"\n" ++"People inexperienced with the X Window System should have the\n" ++"\"xorg\" package installed.\n" ++"# apt-get install xorg\n" ++"\n" ++"Other useful commands to run include:\n" ++"$ dpkg --status x11-common\n" ++"$ dpkg --status xfonts-base\n" ++"$ zmore /usr/share/doc/x11-common/FAQ.gz", defaultTextFont); ++#else + FatalError("could not open default font '%s'", defaultTextFont); ++#endif + if (!(rootCursor = CreateRootCursor(defaultCursorFont, 0))) ++#ifdef DEBIAN ++ FatalError("could not open default cursor font '%s';\n" ++"the X server's font paths might be misconfigured, remote font server(s)\n" ++"may be unreachable, and/or local fonts may not be installed or are not\n" ++"configured correctly.\n" ++"\n" ++"People inexperienced with the X Window System should have the\n" ++"\"xorg\" package installed.\n" ++"# apt-get install xorg\n" ++"\n" ++"Other useful commands to run include:\n" ++"$ dpkg --status x11-common\n" ++"$ dpkg --status xfonts-base\n" ++"$ zmore /usr/share/doc/x11-common/FAQ.gz", defaultTextFont); ++#else + FatalError("could not open default cursor font '%s'", + defaultCursorFont); ++#endif + #ifdef DPMSExtension + /* check all screens, looking for DPMS Capabilities */ + DPMSCapableFlag = DPMSSupported(); --- xorg-server-1.4.99.906.orig/debian/patches/100_xserver_exa_force_greedy.patch +++ xorg-server-1.4.99.906/debian/patches/100_xserver_exa_force_greedy.patch @@ -0,0 +1,34 @@ +Index: xorg-server/exa/exa.c +=================================================================== +--- xorg-server.orig/exa/exa.c 2008-06-18 10:28:15.000000000 +0300 ++++ xorg-server/exa/exa.c 2008-06-18 12:07:25.000000000 +0300 +@@ -837,6 +837,11 @@ + dixSetPrivate(&pScreen->devPrivates, exaScreenPrivateKey, pExaScr); + + pExaScr->migration = ExaMigrationAlways; ++ if (pScreenInfo->flags & EXA_MIGRATION_GREEDY) { ++ pExaScr->migration = ExaMigrationGreedy; ++ LogMessage(X_INFO, "EXA(%d): Forcing greedy migration option\n", ++ pScreen->myNum); ++ } + + exaDDXDriverInit(pScreen); + +Index: xorg-server/exa/exa.h +=================================================================== +--- xorg-server.orig/exa/exa.h 2008-06-18 10:28:16.000000000 +0300 ++++ xorg-server/exa/exa.h 2008-06-18 12:07:25.000000000 +0300 +@@ -735,6 +735,13 @@ + #define EXA_TWO_BITBLT_DIRECTIONS (1 << 2) + + /** ++ * EXA_MIGRATION_GREEDY indicates to EXA that the driver prefers to ++ * use the "greedy" migration heuristic. This is to work around ++ * issues with EXA on the Intel 965 chipset. (LP: #177492) ++ */ ++#define EXA_MIGRATION_GREEDY (1 << 3) ++ ++/** + * EXA_HANDLES_PIXMAPS indicates to EXA that the driver can handle + * all pixmap addressing and migration. + */ --- xorg-server-1.4.99.906.orig/debian/patches/102_ubuntu_sharevts_load_cpu.patch +++ xorg-server-1.4.99.906/debian/patches/102_ubuntu_sharevts_load_cpu.patch @@ -0,0 +1,28 @@ +Index: xorg-server/hw/xfree86/os-support/linux/lnx_init.c +=================================================================== +--- xorg-server.orig/hw/xfree86/os-support/linux/lnx_init.c 2008-06-18 10:28:16.000000000 +0300 ++++ xorg-server/hw/xfree86/os-support/linux/lnx_init.c 2008-06-18 12:06:06.000000000 +0300 +@@ -283,9 +283,7 @@ + FatalError("Unable to set screen info\n"); + close(fbfd); + #endif +- } else { /* ShareVTs */ +- close(xf86Info.consoleFd); +- } ++ } + signal(SIGUSR2, xf86ReloadInputDevs); + } else { /* serverGeneration != 1 */ + if (!ShareVTs && VTSwitch) +@@ -314,7 +312,11 @@ + int vtno = -1; + #endif + +- if (ShareVTs) return; ++ if (ShareVTs) ++ { ++ close(xf86Info.consoleFd); ++ return; ++ } + + #if defined(DO_OS_FONTRESTORE) + if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0) --- xorg-server-1.4.99.906.orig/debian/patches/104_psb_auto.patch +++ xorg-server-1.4.99.906/debian/patches/104_psb_auto.patch @@ -0,0 +1,30 @@ +This patch adds autodetection support for the Poulsbo ("psb") driver +needed by moblin.org for the Intel mobile chipset. Rather than add an +else if, I restructured things with a case statement to make it conform +in style to the savage driver section. + +Bryce Harrington 23-Aug-2007 + +Index: xorg-server/hw/xfree86/common/xf86AutoConfig.c +=================================================================== +--- xorg-server.orig/hw/xfree86/common/xf86AutoConfig.c 2008-06-18 10:28:16.000000000 +0300 ++++ xorg-server/hw/xfree86/common/xf86AutoConfig.c 2008-06-18 12:06:33.000000000 +0300 +@@ -158,9 +158,15 @@ + case 0x102c: return "chips"; + case 0x1013: return "cirrus"; + case 0x8086: +- if ((dev->device_id == 0x00d1) || (dev->device_id == 0x7800)) +- return "i740"; +- else return "intel"; ++ switch (dev->device_id) ++ { ++ case 0x00d1: case 0x7800: ++ return "i740"; ++ case 0x8108: ++ return "psb"; ++ default: ++ return "intel"; ++ } + case 0x102b: return "mga"; + case 0x10c8: return "neomagic"; + case 0x105d: return "i128"; --- xorg-server-1.4.99.906.orig/debian/patches/121_only_switch_vt_when_active.diff +++ xorg-server-1.4.99.906/debian/patches/121_only_switch_vt_when_active.diff @@ -0,0 +1,32 @@ +Index: xorg-server/hw/xfree86/os-support/linux/lnx_init.c +=================================================================== +--- xorg-server.orig/hw/xfree86/os-support/linux/lnx_init.c 2008-06-18 12:06:06.000000000 +0300 ++++ xorg-server/hw/xfree86/os-support/linux/lnx_init.c 2008-06-18 12:06:25.000000000 +0300 +@@ -344,10 +344,25 @@ + + if (VTSwitch) + { ++ struct vt_stat vts; ++ + /* +- * Perform a switch back to the active VT when we were started ++ * Perform a switch back to the active VT when we were started. ++ * We cannot rely on vtSema to determine if the server was the ++ * active VT at the time of shutdown since it has already been ++ * released. Instead, we manually check the current VT and ++ * compare it with the VT we were running on. + */ +- if (activeVT >= 0) { ++ if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0) ++ { ++ /* If this failed, fall back to old behaviour ++ * of always switching. */ ++ xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n", ++ strerror(errno)); ++ vts.v_active = xf86Info.vtno; ++ } ++ ++ if (activeVT >= 0 && vts.v_active == xf86Info.vtno) { + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0) + xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n", + strerror(errno)); --- xorg-server-1.4.99.906.orig/debian/patches/130_fedora_call_switchcorekeyboard.patch +++ xorg-server-1.4.99.906/debian/patches/130_fedora_call_switchcorekeyboard.patch @@ -0,0 +1,61 @@ +From b2943b507261d1c68a6266b090ec44495d7796a1 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Mon, 28 Jul 2008 12:17:17 +0930 +Subject: [PATCH] xfree86: call SwitchCoreKeyboard for first physical device. + +The VCK's keymap is different to the (evdev) keyboard's keymap. Any changes to +the VCK are lost when the first key is pressed (see X.Org Bug 16364). By +calling SwitchCoreKeyboard for the first hotplugged keyboard, the keymap is +toggled already when the first apps start. + +This fixes GNOME, which stores the keycode instead of the keysym. +Fixes xmodmap, etc. settings in xinitrc or otherwise set before the first key +press. + +This breaks if the first hotplugged keyboard is not the actual keyboard the +user wants to use. +--- + hw/xfree86/common/xf86Xinput.c | 27 +++++++++++++++++++++++++++ + 1 files changed, 27 insertions(+), 0 deletions(-) + +diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c +index 710e787..fe08626 100644 +--- a/hw/xfree86/common/xf86Xinput.c ++++ b/hw/xfree86/common/xf86Xinput.c +@@ -423,6 +423,33 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev) + (!is_auto || xf86Info.autoEnableDevices)) + EnableDevice(dev); + ++ /* XXX: The VCK always starts with built-in defaults for keymap. These ++ * defaults are different to the evdev ones. When the first key is hit on ++ * an extension device, the keymap is copied into the VCK's and any ++ * changes made at runtime to the VCK map are lost. ++ * ++ * If this is the first real keyboard to activate, force a ++ * SwitchCoreKeyboard so the VCK has the same keymap as we do. ++ * ++ * Next time we hit a key, we don't change the map over anymore (see ++ * SwitchCoreKeyboard), and live happily ever after. ++ * Until we have 2 physical keyboards. Or the first real keyboard isn't ++ * actually the one we use. Oh well. ++ */ ++ if (dev->key) ++ { ++ DeviceIntPtr it; ++ ++ for (it = inputInfo.keyboard->next; it; it = it->next) ++ { ++ if (it->key && it != dev) ++ break; ++ } ++ ++ if (!it) /* no other keyboard found */ ++ SwitchCoreKeyboard(dev); ++ } ++ + *pdev = dev; + return Success; + +-- +1.5.5.1 + --- xorg-server-1.4.99.906.orig/debian/patches/134_protect_against_out_of_bounds.patch +++ xorg-server-1.4.99.906/debian/patches/134_protect_against_out_of_bounds.patch @@ -0,0 +1,45 @@ +From: Peter Hutterer +Date: Fri, 1 Aug 2008 06:22:07 +0000 (+0930) +Subject: config: protect against potential out-of-bounds indexing. +X-Git-Url: http://gitweb.freedesktop.org/?p=xorg/xserver.git;a=commitdiff;h=3c6a9c531f673b7a0cb9ca01860b4dbe79686363 + +config: protect against potential out-of-bounds indexing. +--- + +--- a/config/hal.c ++++ b/config/hal.c +@@ -260,7 +260,7 @@ device_added(LibHalContext *hal_ctx, con + * Since we can't predict the order in which the keys + * arrive, we need to store them. + */ +- if ((tmp = strcasestr(psi_key, "xkb"))) ++ if ((tmp = strcasestr(psi_key, "xkb")) && strlen(tmp) >= 4) + { + if (!strcasecmp(&tmp[3], "layout")) + { +@@ -298,6 +298,7 @@ device_added(LibHalContext *hal_ctx, con + { + /* server 1.4 had xkb_options as strlist. */ + if ((tmp = strcasestr(psi_key, "xkb")) && ++ (strlen(tmp) >= 4) && + (!strcasecmp(&tmp[3], "options")) && + (tmp_val = get_prop_string_array(hal_ctx, udi, psi_key))) + { +@@ -312,7 +313,7 @@ device_added(LibHalContext *hal_ctx, con + /* only support strings for all values */ + tmp_val = get_prop_string(hal_ctx, udi, psi_key); + +- if (tmp_val){ ++ if (tmp_val && strlen(psi_key) >= sizeof(LIBHAL_XKB_PROP_KEY)) { + + tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1]; + +@@ -342,7 +343,7 @@ device_added(LibHalContext *hal_ctx, con + { + /* server 1.4 had xkb options as strlist */ + tmp_val = get_prop_string_array(hal_ctx, udi, psi_key); +- if (tmp_val) ++ if (tmp_val && strlen(psi_key) >= sizeof(LIBHAL_XKB_PROP_KEY)) + { + tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1]; + if (!strcasecmp(tmp, ".options") && (!xkb_opts.options)) --- xorg-server-1.4.99.906.orig/debian/patches/110_fedora_no_move_damage.patch +++ xorg-server-1.4.99.906/debian/patches/110_fedora_no_move_damage.patch @@ -0,0 +1,35 @@ +Disable damage notifications on move for manually redirected windows. +The automatic compositor needs damage notification on move, but a +compositing manager doesn't. + +Index: xorg-server/composite/compwindow.c +=================================================================== +--- xorg-server.orig/composite/compwindow.c 2008-06-18 10:28:16.000000000 +0300 ++++ xorg-server/composite/compwindow.c 2008-06-18 12:06:20.000000000 +0300 +@@ -580,12 +580,15 @@ + } + else + { ++ CompWindowPtr cw = GetCompWindow (pWin); ++ + ptOldOrg.x -= dx; + ptOldOrg.y -= dy; + REGION_TRANSLATE (prgnSrc, prgnSrc, + pWin->drawable.x - ptOldOrg.x, + pWin->drawable.y - ptOldOrg.y); +- DamageDamageRegion (&pWin->drawable, prgnSrc); ++ if (pWin->redirectDraw && cw->update == CompositeRedirectAutomatic) ++ DamageDamageRegion (&pWin->drawable, prgnSrc); + } + cs->CopyWindow = pScreen->CopyWindow; + pScreen->CopyWindow = compCopyWindow; +@@ -664,7 +667,8 @@ + /* + * Report that as damaged so it will be redrawn + */ +- DamageDamageRegion (&pWin->drawable, &damage); ++ if (cw->update == CompositeRedirectAutomatic) ++ DamageDamageRegion (&pWin->drawable, &damage); + REGION_UNINIT (pScreen, &damage); + /* + * Save the new border clip region --- xorg-server-1.4.99.906.orig/debian/xserver-xephyr.docs +++ xorg-server-1.4.99.906/debian/xserver-xephyr.docs @@ -0,0 +1 @@ +hw/kdrive/ephyr/README --- xorg-server-1.4.99.906.orig/debian/compat +++ xorg-server-1.4.99.906/debian/compat @@ -0,0 +1 @@ +4 --- xorg-server-1.4.99.906.orig/debian/xserver-xorg-core.bug.script +++ xorg-server-1.4.99.906/debian/xserver-xorg-core.bug.script @@ -0,0 +1,122 @@ +#!/bin/sh + +# $Id$ + +PATH="/sbin:$PATH" +CONFIG_DIR=/etc/X11 +SERVER_SYMLINK="$CONFIG_DIR/X" +XORGCONFIG="$CONFIG_DIR/xorg.conf" +CONFIG_AUX_DIR=/var/lib/x11 +SERVER_SYMLINK_CHECKSUM="$CONFIG_AUX_DIR/${SERVER_SYMLINK##*/}.md5sum" +SERVER_SYMLINK_ROSTER="$CONFIG_AUX_DIR/${SERVER_SYMLINK##*/}.roster" +XORGCONFIG_CHECKSUM="$CONFIG_AUX_DIR/${XORGCONFIG##*/}.md5sum" +XORGCONFIG_ROSTER="$CONFIG_AUX_DIR/${XORGCONFIG##*/}.roster" + +exec >&3 + +if [ -e "$SERVER_SYMLINK_ROSTER" ]; then + printf "Contents of $SERVER_SYMLINK_ROSTER:\n" + cat "$SERVER_SYMLINK_ROSTER" +else + printf "$SERVER_SYMLINK_ROSTER does not exist.\n" +fi + +printf "\n" + +if [ -e "$SERVER_SYMLINK" ]; then + if [ -e "$SERVER_SYMLINK_CHECKSUM" ]; then + if [ "$(readlink "$SERVER_SYMLINK" | md5sum)" = \ + "$(cat "$SERVER_SYMLINK_CHECKSUM")" ]; then + printf "%s target unchanged from checksum in %s.\n" \ + "$SERVER_SYMLINK" "$SERVER_SYMLINK_CHECKSUM" + else + printf "%s target does not match checksum in %s.\n" \ + "$SERVER_SYMLINK" "$SERVER_SYMLINK_CHECKSUM" + fi + else + printf "$SERVER_SYMLINK_CHECKSUM does not exist.\n" + fi + printf "\n" + printf "X server symlink status:\n" + ls -dl "$SERVER_SYMLINK" + ls -dl "$(readlink "$SERVER_SYMLINK")" +else + printf "$SERVER_SYMLINK does not exist.\n" +fi + +if ! [ -L "$SERVER_SYMLINK" ]; then + printf "$SERVER_SYMLINK is not a symlink.\n" +fi + +if ! [ -x "$SERVER_SYMLINK" ]; then + printf "$SERVER_SYMLINK is not executable.\n" +fi + +printf "\n" + +if [ -e "$XORGCONFIG_ROSTER" ]; then + printf "Contents of $XORGCONFIG_ROSTER:\n" + cat "$XORGCONFIG_ROSTER" +else + printf "$XORGCONFIG_ROSTER does not exist.\n" +fi + +printf "\n" + +if which lspci > /dev/null 2>&1; then + printf "VGA-compatible devices on PCI bus:\n" + LC_ALL=C lspci | grep 'VGA compatible controller:' + LC_ALL=C lspci -n | grep 'Class 0300:' +else + printf "The lspci command was not found; not including PCI data.\n" +fi + +printf "\n" + +if [ -e "$XORGCONFIG" ]; then + if [ -e "$XORGCONFIG_CHECKSUM" ]; then + if [ "$(md5sum "$XORGCONFIG")" = "$(cat "$XORGCONFIG_CHECKSUM")" ]; then + printf "%s unchanged from checksum in %s.\n" "$XORGCONFIG" \ + "$XORGCONFIG_CHECKSUM" + else + printf "%s does not match checksum in %s.\n" "$XORGCONFIG" \ + "$XORGCONFIG_CHECKSUM" + fi + else + printf "$XORGCONFIG_CHECKSUM does not exist.\n" + fi + printf "\n" + printf "Xorg X server configuration file status:\n" + ls -dl "$XORGCONFIG" + printf "\n" + printf "Contents of $XORGCONFIG:\n" + iconv -c -t ascii "$XORGCONFIG" + printf "\n" +else + printf "$XORGCONFIG does not exist.\n" +fi + +printf "\n" + +XORG_LOGS=$(ls -dt /var/log/Xorg.*.log 2>/dev/null) + +if [ -n "$XORG_LOGS" ]; then + printf "Xorg X server log files on system:\n" + ls -dlrt /var/log/Xorg.*.log 2>/dev/null + printf "\n" + for LOG in $XORG_LOGS; do + if [ -f "$LOG" ]; then + printf "Contents of most recent Xorg X server log file\n" + printf "%s:\n" "$LOG" + cat "$LOG" + # the log files are large; only show the most recent + break + fi + done +else + printf "No Xorg X server log files found.\n" +fi + +printf "\n" + +# vim:set ai et sts=4 sw=4 tw=0: --- xorg-server-1.4.99.906.orig/debian/xserver-xephyr.install +++ xorg-server-1.4.99.906/debian/xserver-xephyr.install @@ -0,0 +1 @@ +usr/bin/Xephyr --- xorg-server-1.4.99.906.orig/debian/copyright +++ xorg-server-1.4.99.906/debian/copyright @@ -0,0 +1,1136 @@ +This package was downloaded from +http://xorg.freedesktop.org/releases/individual/xserver/ +The upstream tarball has been modified to remove the files listed in +debian/prune/non-free. + + Licenses + + The X.Org Foundation + + March 2004 + +1. Introduction + +The X.org Foundation X Window System distribution is a compilation of code +and documentation from many sources. This document is intended primarily as +a guide to the licenses used in the distribution: you must check each file +and/or package for precise redistribution terms. None-the-less, this summary +may be useful to many users. No software incorporating the XFree86 1.1 +license has been incorporated. + +This document is based on the compilation from XFree86. + +2. XFree86 License + +XFree86 code without an explicit copyright is covered by the following copy- +right/license: + +Copyright (C) 1994-2003 The XFree86 Project, Inc. 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, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is fur- +nished 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, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- +NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the XFree86 Project shall not +be used in advertising or otherwise to promote the sale, use or other deal- +ings in this Software without prior written authorization from the XFree86 +Project. + +3. Other Licenses + +Portions of code are covered by the following licenses/copyrights. See indi- +vidual files for the copyright dates. + +3.1 X/MIT Copyrights + +3.1.1 X Consortium + +Copyright (C) X Consortium + +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 fur- +nished 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, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X +CONSORTIUM 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 X Consortium 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 X Consortium. + +X Window System is a trademark of X Consortium, Inc. + +3.1.2 The Open Group + +Copyright The Open Group + +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, FIT- +NESS 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 Open Group 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 Open Group. + +3.2 Berkeley-based copyrights: + +o + +3.2.1 General + +Redistribution and use in source and binary forms, with or without modifica- +tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- +CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- +CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- +ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +3.2.2 UCB/LBL + +Copyright (c) 1993 The Regents of the University of California. All rights +reserved. + +This software was developed by the Computer Systems Engineering group at +Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and contributed to +Berkeley. + +All advertising materials mentioning features or use of this software must +display the following acknowledgement: This product includes software devel- +oped by the University of California, Lawrence Berkeley Laboratory. + +Redistribution and use in source and binary forms, with or without modifica- +tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: This product includes soft- + ware developed by the University of California, Berkeley and its con- + tributors. + + 4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS- +CLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +3.2.3 The NetBSD Foundation, Inc. + +Copyright (c) 2003 The NetBSD Foundation, Inc. All rights reserved. + +This code is derived from software contributed to The NetBSD Foundation by +Ben Collver + +Redistribution and use in source and binary forms, with or without modifica- +tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: This product includes soft- + ware developed by the NetBSD Foundation, Inc. and its contributors. + + 4. Neither the name of The NetBSD Foundation nor the names of its con- + tributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSE- +QUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAM- +AGE. + +3.2.4 Theodore Ts'o. + +Copyright Theodore Ts'o, 1994, 1995, 1996, 1997, 1998, 1999. All rights +reserved. + +Redistribution and use in source and binary forms, with or without modifica- +tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + and the entire permission notice in its entirety, including the dis- + claimer of warranties. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. he name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE, ALL OF WHICH ARE HEREBY DISCLAIMED. IN NO +EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- +CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- +ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF NOT +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +3.2.5 Theo de Raadt and Damien Miller + +Copyright (c) 1995,1999 Theo de Raadt. All rights reserved. Copyright (c) +2001-2002 Damien Miller. All rights reserved. + +Redistribution and use in source and binary forms, with or without modifica- +tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- +CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- +CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- +ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +3.2.6 Todd C. Miller + +Copyright (c) 1998 Todd C. Miller + +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MER- +CHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE FOR ANY +SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CON- +TRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +3.2.7 Thomas Winischhofer + +Copyright (C) 2001-2004 Thomas Winischhofer + +Redistribution and use in source and binary forms, with or without modifica- +tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- +CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- +ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +3.3 NVIDIA Corp + +Copyright (c) 1996 NVIDIA, Corp. All rights reserved. + +NOTICE TO USER: The source code is copyrighted under U.S. and international +laws. NVIDIA, Corp. of Sunnyvale, California owns the copyright and as +design patents pending on the design and interface of the NV chips. Users +and possessors of this source code are hereby granted a nonexclusive, roy- +alty-free copyright and design patent license to use this code in individual +and commercial software. + +Any use of this source code must include, in the user documentation and +internal comments to the code, notices to the end user as follows: + +Copyright (c) 1996 NVIDIA, Corp. NVIDIA design patents pending in the U.S. +and foreign countries. + +NVIDIA, CORP. MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE +CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WAR- +RANTY OF ANY KIND. NVIDIA, CORP. DISCLAIMS ALL WARRANTIES WITH REGARD TO +THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA, CORP. BE LIABLE +FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAM- +AGES 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 SOURCE CODE. + +3.4 GLX Public License + +GLX PUBLIC LICENSE (Version 1.0 (2/11/99)) ("License") + +Subject to any third party claims, Silicon Graphics, Inc. ("SGI") hereby +grants permission to Recipient (defined below), under Recipient's copyrights +in the Original Software (defined below), to use, copy, modify, merge, pub- +lish, distribute, sublicense and/or sell copies of Subject Software (defined +below), and to permit persons to whom the Subject Software is furnished in +accordance with this License to do the same, subject to all of the following +terms and conditions, which Recipient accepts by engaging in any such use, +copying, modifying, merging, publishing, distributing, sublicensing or sell- +ing: + +1. Definitions. + + (a) "Original Software" means source code of computer software code + which is described in Exhibit A as Original Software. + + (b) "Modifications" means any addition to or deletion from the sub- + stance or structure of either the Original Software or any previous + Modifications. When Subject Software is released as a series of + files, a Modification means (i) any addition to or deletion from + the contents of a file containing Original Software or previous + Modifications and (ii) any new file that contains any part of the + Original Code or previous Modifications. + + (c) "Subject Software" means the Original Software or Modifications + or the combination of the Original Software and Modifications, or + portions of any of the foregoing. + + (d) "Recipient" means an individual or a legal entity exercising + rights under, and complying with all of the terms of, this License. + For legal entities, "Recipient" includes any entity which controls, + is controlled by, or is under common control with Recipient. For + purposes of this definition, "control" of an entity means (a) the + power, direct or indirect, to direct or manage such entity, or (b) + ownership of fifty percent (50%) or more of the outstanding shares + or beneficial ownership of such entity. + +2. Redistribution of Source Code Subject to These Terms. Redistributions of +Subject Software in source code form must retain the notice set forth in +Exhibit A, below, in every file. A copy of this License must be included in +any documentation for such Subject Software where the recipients' rights +relating to Subject Software are described. Recipient may distribute the +source code version of Subject Software under a license of Recipient's +choice, which may contain terms different from this License, provided that +(i) Recipient is in compliance with the terms of this License, and (ii) the +license terms include this Section 2 and Sections 3, 4, 7, 8, 10, 12 and 13 +of this License, which terms may not be modified or superseded by any other +terms of such license. If Recipient distributes the source code version under +a different license Recipient must make it absolutely clear that any terms +which differ from this License are offered by Recipient alone, not by SGI. +Recipient hereby agrees to indemnify SGI for any liability incurred by SGI as +a result of any such terms Recipient offers. + +3. Redistribution in Executable Form. The notice set forth in Exhibit A must +be conspicuously included in any notice in an executable version of Subject +Software, related documentation or collateral in which Recipient describes +the user's rights relating to the Subject Software. Recipient may distribute +the executable version of Subject Software under a license of Recipient's +choice, which may contain terms different from this License, provided that +(i) Recipient is in compliance with the terms of this License, and (ii) the +license terms include this Section 3 and Sections 4, 7, 8, 10, 12 and 13 of +this License, which terms may not be modified or superseded by any other +terms of such license. If Recipient distributes the executable version under +a different license Recipient must make it absolutely clear that any terms +which differ from this License are offered by Recipient alone, not by SGI. +Recipient hereby agrees to indemnify SGI for any liability incurred by SGI as +a result of any such terms Recipient offers. + +4. Termination. This License and the rights granted hereunder will terminate +automatically if Recipient fails to comply with terms herein and fails to +cure such breach within 30 days of the breach. Any sublicense to the Subject +Software which is properly granted shall survive any termination of this +License absent termination by the terms of such sublicense. Provisions which, +by their nature, must remain in effect beyond the termination of this License +shall survive. + +5. No Trademark Rights. This License does not grant any rights to use any +trade name, trademark or service mark whatsoever. No trade name, trademark or +service mark of SGI may be used to endorse or promote products derived from +the Subject Software without prior written permission of SGI. + +6. No Other Rights. This License does not grant any rights with respect to +the OpenGL API or to any software or hardware implementation thereof or to +any other software whatsoever, nor shall any other rights or licenses not +expressly granted hereunder arise by implication, estoppel or otherwise with +respect to the Subject Software. Title to and ownership of the Original Soft- +ware at all times remains with SGI. All rights in the Original Software not +expressly granted under this License are reserved. + +7. Compliance with Laws; Non-Infringement. Recipient shall comply with all +applicable laws and regulations in connection with use and distribution of +the Subject Software, including but not limited to, all export and import +control laws and regulations of the U.S. government and other countries. +Recipient may not distribute Subject Software that (i) in any way infringes +(directly or contributorily) the rights (including patent, copyright, trade +secret, trademark or other intellectual property rights of any kind) of any +other person or entity or (ii) breaches any representation or warranty, +express, implied or statutory, which under any applicable law it might be +deemed to have been distributed. + +8. Claims of Infringement. If Recipient at any time has knowledge of any one +or more third party claims that reproduction, modification, use, distribu- +tion, import or sale of Subject Software (including particular functionality +or code incorporated in Subject Software) infringes the third party's intel- +lectual property rights, Recipient must place in a well-identified web page +bearing the title "LEGAL" a description of each such claim and a description +of the party making each such claim in sufficient detail that a user of the +Subject Software will know whom to contact regarding the claim. Also, upon +gaining such knowledge of any such claim, Recipient must conspicuously +include the URL for such web page in the Exhibit A notice required under Sec- +tions 2 and 3, above, and in the text of any related documentation, license +agreement or collateral in which Recipient describes end user's rights relat- +ing to the Subject Software. If Recipient obtains such knowledge after it +makes Subject Software available to any other person or entity, Recipient +shall take other steps (such as notifying appropriate mailing lists or news- +groups) reasonably calculated to inform those who received the Subject Soft- +ware that new knowledge has been obtained. + +9. DISCLAIMER OF WARRANTY. SUBJECT SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, +WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT +LIMITATION, WARRANTIES THAT THE SUBJECT SOFTWARE IS FREE OF DEFECTS, MER- +CHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON- INFRINGING. SGI ASSUMES NO +RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE. SHOULD ANY SOFTWARE +PROVE DEFECTIVE IN ANY RESPECT, SGI ASSUMES NO COST OR LIABILITY FOR ANY SER- +VICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN +ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY SUBJECT SOFTWARE IS AUTHORIZED +HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +10. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THE- +ORY, WHETHER TORT (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE OR STRICT LIA- +BILITY), CONTRACT, OR OTHERWISE, SHALL SGI OR ANY SGI LICENSOR BE LIABLE FOR +ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY +CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK +STOPPAGE, LOSS OF DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER +COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF +THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY +TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SGI's NEGLIGENCE TO +THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO +NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, +SO THAT EXCLUSION AND LIMITATION MAY NOT APPLY TO RECIPIENT. + +11. Indemnity. Recipient shall be solely responsible for damages arising, +directly or indirectly, out of its utilization of rights under this License. +Recipient will defend, indemnify and hold harmless Silicon Graphics, Inc. +from and against any loss, liability, damages, costs or expenses (including +the payment of reasonable attorneys fees) arising out of Recipient's use, +modification, reproduction and distribution of the Subject Software or out of +any representation or warranty made by Recipient. + +12. U.S. Government End Users. The Subject Software is a "commercial item" +consisting of "commercial computer software" as such terms are defined in +title 48 of the Code of Federal Regulations and all U.S. Government End +Users acquire only the rights set forth in this License and are subject to +the terms of this License. + +13. Miscellaneous. This License represents the complete agreement concerning +subject matter hereof. If any provision of this License is held to be unen- +forceable, such provision shall be reformed so as to achieve as nearly as +possible the same economic effect as the original provision and the remainder +of this License will remain in effect. This License shall be governed by and +construed in accordance with the laws of the United States and the State of +California as applied to agreements entered into and to be performed entirely +within California between California residents. Any litigation relating to +this License shall be subject to the exclusive jurisdiction of the Federal +Courts of the Northern District of California (or, absent subject matter +jurisdiction in such courts, the courts of the State of California), with +venue lying exclusively in Santa Clara County, California, with the losing +party responsible for costs, including without limitation, court costs and +reasonable attorneys fees and expenses. The application of the United Nations +Convention on Contracts for the International Sale of Goods is expressly +excluded. Any law or regulation which provides that the language of a con- +tract shall be construed against the drafter shall not apply to this License. + +Exhibit A + +The contents of this file are subject to Sections 2, 3, 4, 7, 8, 10, 12 and +13 of the GLX Public License Version 1.0 (the "License"). You may not use +this file except in compliance with those sections of the License. You may +obtain a copy of the License at Silicon Graphics, Inc., attn: Legal Services, +2011 N. Shoreline Blvd., Mountain View, CA 94043 or at +http://www.sgi.com/software/opensource/glx/license.html. + +Software distributed under the License is distributed on an "AS IS" basis. +ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED +WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF NON- +INFRINGEMENT. See the License for the specific language governing rights and +limitations under the License. + +The Original Software is GLX version 1.2 source code, released February, +1999. The developer of the Original Software is Silicon Graphics, Inc. Those +portions of the Subject Software created by Silicon Graphics, Inc. are Copy- +right (c) 1991-9 Silicon Graphics, Inc. All Rights Reserved. + +3.5 CID Font Code Public License + +CID FONT CODE PUBLIC LICENSE (Version 1.0 (3/31/99))("License") + +Subject to any applicable third party claims, Silicon Graphics, Inc. ("SGI") +hereby grants permission to Recipient (defined below), under SGI's copyrights +in the Original Software (defined below), to use, copy, modify, merge, pub- +lish, distribute, sublicense and/or sell copies of Subject Software (defined +below) in both source code and executable form, and to permit persons to whom +the Subject Software is furnished in accordance with this License to do the +same, subject to all of the following terms and conditions, which Recipient +accepts by engaging in any such use, copying, modifying, merging, publica- +tion, distributing, sublicensing or selling: + +1. Definitions. + + a. "Original Software" means source code of computer software code + that is described in Exhibit A as Original Software. + + b. "Modifications" means any addition to or deletion from the sub- + stance or structure of either the Original Software or any previous + Modifications. When Subject Software is released as a series of + files, a Modification means (i) any addition to or deletion from + the contents of a file containing Original Software or previous + Modifications and (ii) any new file that contains any part of the + Original Code or previous Modifications. + + c. "Subject Software" means the Original Software or Modifications + or the combination of the Original Software and Modifications, or + portions of any of the foregoing. + + d. "Recipient" means an individual or a legal entity exercising + rights under the terms of this License. For legal entities, "Recip- + ient" includes any entity that controls, is controlled by, or is + under common control with Recipient. For purposes of this defini- + tion, "control" of an entity means (i) the power, direct or indi- + rect, to direct or manage such entity, or (ii) ownership of fifty + percent (50%) or more of the outstanding shares or beneficial own- + ership of such entity. + + e. "Required Notice" means the notice set forth in Exhibit A to + this License. + + f. "Accompanying Technology" means any software or other technology + that is not a Modification and that is distributed or made publicly + available by Recipient with the Subject Software. Separate soft- + ware files that do not contain any Original Software or any previ- + ous Modification shall not be deemed a Modification, even if such + software files are aggregated as part of a product, or in any + medium of storage, with any file that does contain Original Soft- + ware or any previous Modification. + +2. License Terms. All distribution of the Subject Software must be made sub- +ject to the terms of this License. A copy of this License and the Required +Notice must be included in any documentation for Subject Software where +Recipient's rights relating to Subject Software and/or any Accompanying Tech- +nology are described. Distributions of Subject Software in source code form +must also include the Required Notice in every file distributed. In addition, +a ReadMe file entitled "Important Legal Notice" must be distributed with each +distribution of one or more files that incorporate Subject Software. That +file must be included with distributions made in both source code and exe- +cutable form. A copy of the License and the Required Notice must be included +in that file. Recipient may distribute Accompanying Technology under a +license of Recipient's choice, which may contain terms different from this +License, provided that (i) Recipient is in compliance with the terms of this +License, (ii) such other license terms do not modify or supersede the terms +of this License as applicable to the Subject Software, (iii) Recipient hereby +indemnifies SGI for any liability incurred by SGI as a result of the distri- +bution of Accompanying Technology or the use of other license terms. + +3. Termination. This License and the rights granted hereunder will terminate +automatically if Recipient fails to comply with terms herein and fails to +cure such breach within 30 days of the breach. Any sublicense to the Subject +Software that is properly granted shall survive any termination of this +License absent termination by the terms of such sublicense. Provisions which, +by their nature, must remain in effect beyond the termination of this License +shall survive. + +4. Trademark Rights. This License does not grant any rights to use any trade +name, trademark or service mark whatsoever. No trade name, trademark or ser- +vice mark of SGI may be used to endorse or promote products derived from or +incorporating any Subject Software without prior written permission of SGI. + +5. No Other Rights. No rights or licenses not expressly granted hereunder +shall arise by implication, estoppel or otherwise. Title to and ownership of +the Original Software at all times remains with SGI. All rights in the Origi- +nal Software not expressly granted under this License are reserved. + +6. Compliance with Laws; Non-Infringement. Recipient shall comply with all +applicable laws and regulations in connection with use and distribution of +the Subject Software, including but not limited to, all export and import +control laws and regulations of the U.S. government and other countries. +Recipient may not distribute Subject Software that (i) in any way infringes +(directly or contributorily) the rights (including patent, copyright, trade +secret, trademark or other intellectual property rights of any kind) of any +other person or entity, or (ii) breaches any representation or warranty, +express, implied or statutory, which under any applicable law it might be +deemed to have been distributed. + +7. Claims of Infringement. If Recipient at any time has knowledge of any one +or more third party claims that reproduction, modification, use, distribu- +tion, import or sale of Subject Software (including particular functionality +or code incorporated in Subject Software) infringes the third party's intel- +lectual property rights, Recipient must place in a well-identified web page +bearing the title "LEGAL" a description of each such claim and a description +of the party making each such claim in sufficient detail that a user of the +Subject Software will know whom to contact regarding the claim. Also, upon +gaining such knowledge of any such claim, Recipient must conspicuously +include the URL for such web page in the Required Notice, and in the text of +any related documentation, license agreement or collateral in which Recipient +describes end user's rights relating to the Subject Software. If Recipient +obtains such knowledge after it makes Subject Software available to any other +person or entity, Recipient shall take other steps (such as notifying appro- +priate mailing lists or newsgroups) reasonably calculated to provide such +knowledge to those who received the Subject Software. + +8. DISCLAIMER OF WARRANTY. SUBJECT SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, +WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT +LIMITATION, WARRANTIES THAT THE SUBJECT SOFTWARE IS FREE OF DEFECTS, MER- +CHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. SGI ASSUMES NO +RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE. SHOULD ANY SOFTWARE +PROVE DEFECTIVE IN ANY RESPECT, SGI ASSUMES NO COST OR LIABILITY FOR ANY SER- +VICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN +ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY SUBJECT SOFTWARE IS AUTHORIZED +HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +9. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, +WHETHER TORT (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE OR STRICT LIABILITY), +CONTRACT, OR OTHERWISE, SHALL SGI OR ANY SGI LICENSOR 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 SUBJECT SOFTWARE OR +THE USE OR OTHER DEALINGS IN THE SUBJECT SOFTWARE. SOME JURISDICTIONS DO NOT +ALLOW THE EXCLUSION OR LIMITATION OF CERTAIN DAMAGES, SO THIS EXCLUSION AND +LIMITATION MAY NOT APPLY TO RECIPIENT TO THE EXTENT SO DISALLOWED. + +10. Indemnity. Recipient shall be solely responsible for damages arising, +directly or indirectly, out of its utilization of rights under this License. +Recipient will defend, indemnify and hold SGI and its successors and assigns +harmless from and against any loss, liability, damages, costs or expenses +(including the payment of reasonable attorneys fees) arising out of (Recipi- +ent's use, modification, reproduction and distribution of the Subject Soft- +ware or out of any representation or warranty made by Recipient. + +11. U.S. Government End Users. The Subject Software is a "commercial item" +consisting of "commercial computer software" as such terms are defined in +title 48 of the Code of Federal Regulations and all U.S. Government End Users +acquire only the rights set forth in this License and are subject to the +terms of this License. + +12. Miscellaneous. This License represents the complete agreement concerning +subject matter hereof. If any provision of this License is held to be unen- +forceable by any judicial or administrative authority having proper jurisdic- +tion with respect thereto, such provision shall be reformed so as to achieve +as nearly as possible the same economic effect as the original provision and +the remainder of this License will remain in effect. This License shall be +governed by and construed in accordance with the laws of the United States +and the State of California as applied to agreements entered into and to be +performed entirely within California between California residents. Any liti- +gation relating to this License shall be subject to the exclusive jurisdic- +tion of the Federal Courts of the Northern District of California (or, absent +subject matter jurisdiction in such courts, the courts of the State of Cali- +fornia), with venue lying exclusively in Santa Clara County, California, with +the losing party responsible for costs, including without limitation, court +costs and reasonable attorneys fees and expenses. The application of the +United Nations Convention on Contracts for the International Sale of Goods is +expressly excluded. Any law or regulation that provides that the language of +a contract shall be construed against the drafter shall not apply to this +License. + +Exhibit A + +Copyright (c) 1994-1999 Silicon Graphics, Inc. + +The contents of this file are subject to the CID Font Code Public License +Version 1.0 (the "License"). You may not use this file except in compliance +with the License. You may obtain a copy of the License at Silicon Graphics, +Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA 94043 +or at http://www.sgi.com/software/opensource/cid/license.html + +Software distributed under the License is distributed on an "AS IS" basis. +ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED +WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF NON- +INFRINGEMENT. See the License for the specific language governing rights and +limitations under the License. + +The Original Software (as defined in the License) is CID font code that was +developed by Silicon Graphics, Inc. Those portions of the Subject Software +(as defined in the License) that were created by Silicon Graphics, Inc. are +Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved. + +[NOTE: When using this text in connection with Subject Software delivered +solely in object code form, Recipient may replace the words "this file" with +"this software" in both the first and second sentences.] + +3.6 Bitstream Vera Fonts Copyright + +The fonts have a generous copyright, allowing derivative works (as long as +"Bitstream" or "Vera" are not in the names), and full redistribution (so long +as they are not *sold* by themselves). They can be be bundled, redistributed +and sold with any software. + +The fonts are distributed under the following copyright: + +Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is +a trademark of Bitstream, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of the fonts accompanying this license ("Fonts") and associated documentation +files (the "Font Software"), to reproduce and distribute the Font Software, +including without limitation the rights to use, copy, merge, publish, dis- +tribute, and/or sell copies of the Font Software, and to permit persons to +whom the Font Software is furnished to do so, subject to the following condi- +tions: + +The above copyright and trademark notices and this permission notice shall be +included in all copies of one or more of the Font Software typefaces. + +The Font Software may be modified, altered, or added to, and in particular +the designs of glyphs or characters in the Fonts may be modified and addi- +tional glyphs or characters may be added to the Fonts, only if the fonts are +renamed to names not containing either the words "Bitstream" or the word +"Vera". + +This License becomes null and void to the extent applicable to Fonts or Font +Software that has been modified and is distributed under the "Bitstream Vera" +names. + +The Font Software may be sold as part of a larger software package but no +copy of one or more of the Font Software typefaces may be sold by itself. + +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, +TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDA- +TION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GEN- +ERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR +INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFT- +WARE. + +Except as contained in this notice, the names of Gnome, the Gnome Foundation, +and Bitstream Inc., shall not be used in advertising or otherwise to promote +the sale, use or other dealings in this Font Software without prior written +authorization from the Gnome Foundation or Bitstream Inc., respectively. For +further information, contact: fonts at gnome dot org. + +3.7 Bigelow & Holmes Inc and URW++ GmbH Luxi font license + +Luxi fonts copyright (c) 2001 by Bigelow & Holmes Inc. Luxi font instruction +code copyright (c) 2001 by URW++ GmbH. All Rights Reserved. Luxi is a regis- +tered trademark of Bigelow & Holmes Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of these Fonts and associated documentation files (the "Font Software"), to +deal in the Font Software, including without limitation the rights to use, +copy, merge, publish, distribute, sublicense, and/or sell copies of the Font +Software, and to permit persons to whom the Font Software is furnished to do +so, subject to the following conditions: + +The above copyright and trademark notices and this permission notice shall be +included in all copies of one or more of the Font Software. + +The Font Software may not be modified, altered, or added to, and in particu- +lar the designs of glyphs or characters in the Fonts may not be modified nor +may additional glyphs or characters be added to the Fonts. This License +becomes null and void when the Fonts or Font Software have been modified. + +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, +TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BIGELOW & HOLMES INC. OR URW++ +GMBH. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GEN- +ERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR +INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFT- +WARE. + +Except as contained in this notice, the names of Bigelow & Holmes Inc. and +URW++ GmbH. shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Font Software without prior written +authorization from Bigelow & Holmes Inc. and URW++ GmbH. + +For further information, contact: + +info@urwpp.de or design@bigelowandholmes.com + + $Id: LICENSE,v 1.3 2004/09/03 23:41:21 kem Exp $ + + +======================================================================== +Certain files in this package (e.g. GL/glx/g_*) are covered by the SGI +Free Software License B, Version 1.1, http://oss.sgi.com/projects/FreeB + +SGI FREE SOFTWARE LICENSE B (Version 1.1 [02/22/2000]) +1. Definitions. +1.1. "Additional Notice Provisions" means such additional provisions as appear +in the Notice in Original Code under the heading "Additional Notice +Provisions." +1.2. "Covered Code" means the Original Code or Modifications, or any +combination thereof. 1.3. "Hardware" means any physical device that accepts +input, processes input, stores the results of processing, and/or provides +output. +1.4. "Larger Work" means a work that combines Covered Code or portions thereof +with code not governed by the terms of this License. +1.5. "Licensable" means having the right to grant, to the maximum extent +possible, whether at the time of the initial grant or subsequently acquired, +any and all of the rights conveyed herein. +1.6. "License" means this document. +1.7. "Licensed Patents" means patent claims Licensable by SGI that are +infringed by the use or sale of Original Code or any Modifications provided by +SGI, or any combination thereof. +1.8. "Modifications" means any addition to or deletion from the substance or +structure of the Original Code or any previous Modifications. When Covered Code +is released as a series of files, a Modification is: +A. Any addition to the contents of a file containing Original Code and/or +addition to or deletion from the contents of a file containing previous +Modifications. +B. Any new file that contains any part of the Original Code or previous +Modifications. +1.9. "Notice" means any notice in Original Code or Covered Code, as required by +and in compliance with this License. +1.10. "Original Code" means source code of computer software code that is +described in the source code Notice required by Exhibit A as Original Code, and +updates and error corrections specifically thereto. +1.11. "Recipient" means an individual or a legal entity exercising rights +under, and complying with all of the terms of, this License or a future version +of this License issued under Section 8. For legal entities, "Recipient" +includes any entity that controls, is controlled by, or is under common control +with Recipient. For purposes of this definition, "control" of an entity means +(a) the power, direct or indirect, to direct or manage such entity, or (b) +ownership of fifty percent (50%) or more of the outstanding shares or +beneficial ownership of such entity. +1.12. "Recipient Patents" means patent claims Licensable by a Recipient that +are infringed by the use or sale of Original Code or any Modifications provided +by SGI, or any combination thereof. +1.13. "SGI" means Silicon Graphics, Inc. +1.14. "SGI Patents" means patent claims Licensable by SGI other than the +Licensed Patents. +2. License Grant and Restrictions. +2.1. SGI License Grant. Subject to the terms of this License and any third +party intellectual property claims, for the duration of intellectual property +protections inherent in the Original Code, SGI hereby grants Recipient a +worldwide, royalty-free, non-exclusive license, to do the following: (i) under +copyrights Licensable by SGI, to reproduce, distribute, create derivative works +from, and, to the extent applicable, display and perform the Original Code +and/or any Modifications provided by SGI alone and/or as part of a Larger Work; +and (ii) under any Licensable Patents, to make, have made, use, sell, offer for +sale, import and/or otherwise transfer the Original Code and/or any +Modifications provided by SGI. Recipient accepts the terms and conditions of +this License by undertaking any of the aforementioned actions. The patent +license shall apply to the Covered Code if, at the time any related +Modification is added, such addition of the Modification causes such +combination to be covered by the Licensed Patents. The patent license in +Section 2.1(ii) shall not apply to any other combinations that include the +Modification. No patent license is provided under SGI Patents for +infringements of SGI Patents by Modifications not provided by SGI or +combinations of Original Code and Modifications not provided by SGI. +2.2. Recipient License Grant. Subject to the terms of this License and any +third party intellectual property claims, Recipient hereby grants SGI and any +other Recipients a worldwide, royalty-free, non-exclusive license, under any +Recipient Patents, to make, have made, use, sell, offer for sale, import and/or +otherwise transfer the Original Code and/or any Modifications provided by SGI. +2.3. No License For Hardware Implementations. The licenses granted in Section +2.1 and 2.2 are not applicable to implementation in Hardware of the algorithms +embodied in the Original Code or any Modifications provided by SGI . +3. Redistributions. +3.1. Retention of Notice/Copy of License. The Notice set forth in Exhibit A, +below, must be conspicuously retained or included in any and all +redistributions of Covered Code. For distributions of the Covered Code in +source code form, the Notice must appear in every file that can include a text +comments field; in executable form, the Notice and a copy of this License +must appear in related documentation or collateral where the Recipient's rights +relating to Covered Code are described. Any Additional Notice Provisions which +actually appears in the Original Code must also be retained or included in any +and all redistributions of Covered Code. +3.2. Alternative License. Provided that Recipient is in compliance with the +terms of this License, Recipient may, so long as without derogation of any of +SGI's rights in and to the Original Code, distribute the source code and/or +executable version(s) of Covered Code under (1) this License; (2) a license +identical to this License but for only such changes as are necessary in order +to clarify Recipient's role as licensor of Modifications; and/or (3) a license +of Recipient's choosing, containing terms different from this License, provided +that the license terms include this Section 3 and Sections 4, 6, 7, 10, 12, and +13, which terms may not be modified or superseded by any other terms of such +license. If Recipient elects to use any license other than this License, +Recipient must make it absolutely clear that any of its terms which differ from +this License are offered by Recipient alone, and not by SGI. It is emphasized +that this License is a limited license, and, regardless of the license form +employed by Recipient in accordance with this Section 3.2, Recipient may +relicense only such rights, in Original Code and Modifications by SGI, as it +has actually been granted by SGI in this License. +3.3. Indemnity. Recipient hereby agrees to indemnify SGI for any liability +incurred by SGI as a result of any such alternative license terms Recipient +offers. +4. Termination. This License and the rights granted hereunder will terminate +automatically if Recipient breaches any term herein and fails to cure such +breach within 30 days thereof. Any sublicense to the Covered Code that is +properly granted shall survive any termination of this License, absent +termination by the terms of such sublicense. Provisions that, by their nature, +must remain in effect beyond the termination of this License, shall survive. +5. No Trademark Or Other Rights. This License does not grant any rights to: (i) +any software apart from the Covered Code, nor shall any other rights or +licenses not expressly granted hereunder arise by implication, estoppel or +otherwise with respect to the Covered Code; (ii) any trade name, trademark or +service mark whatsoever, including without limitation any related right for +purposes of endorsement or promotion of products derived from the Covered Code, +without prior written permission of SGI; or (iii) any title to or ownership of +the Original Code, which shall at all times remains with SGI. All rights in the +Original Code not expressly granted under this License are reserved. +6. Compliance with Laws; Non-Infringement. There are various worldwide laws, +regulations, and executive orders applicable to dispositions of Covered Code, +including without limitation export, re-export, and import control laws, +regulations, and executive orders, of the U.S. government and other countries, +and Recipient is reminded it is obliged to obey such laws, regulations, and +executive orders. Recipient may not distribute Covered Code that (i) in any way +infringes (directly or contributorily) any intellectual property rights of any +kind of any other person or entity or (ii) breaches any representation or +warranty, express, implied or statutory, to which, under any applicable law, it +might be deemed to have been subject. +7. Claims of Infringement. If Recipient learns of any third party claim that +any disposition of Covered Code and/or functionality wholly or partially +infringes the third party's intellectual property rights, Recipient will +promptly notify SGI of such claim. +8. Versions of the License. SGI may publish revised and/or new versions of the +License from time to time, each with a distinguishing version number. Once +Covered Code has been published under a particular version of the License, +Recipient may, for the duration of the license, continue to use it under the +terms of that version, or choose to use such Covered Code under the terms of +any subsequent version published by SGI. Subject to the provisions of Sections +3 and 4 of this License, only SGI may modify the terms applicable to Covered +Code created under this License. +9. DISCLAIMER OF WARRANTY. COVERED CODE IS PROVIDED "AS IS." ALL EXPRESS AND +IMPLIED WARRANTIES AND CONDITIONS ARE DISCLAIMED, INCLUDING, WITHOUT +LIMITATION, ANY IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, +SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +SGI ASSUMES NO RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE. SHOULD +THE SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, SGI ASSUMES NO COST OR LIABILITY +FOR SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY IS AN +ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED +HEREUNDER EXCEPT SUBJECT TO THIS DISCLAIMER. 10. LIMITATION OF LIABILITY. +UNDER NO CIRCUMSTANCES NOR LEGAL THEORY, WHETHER TORT (INCLUDING, WITHOUT +LIMITATION, NEGLIGENCE OR STRICT LIABILITY), CONTRACT, OR OTHERWISE, SHALL SGI +OR ANY SGI LICENSOR BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR +CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES +FOR LOSS OF GOODWILL, WORK STOPPAGE, LOSS OF DATA, COMPUTER FAILURE OR +MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH +PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS +LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL +INJURY RESULTING FROM SGI's NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS +SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF +INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THAT EXCLUSION AND LIMITATION MAY NOT +APPLY TO RECIPIENT. +11. Indemnity. Recipient shall be solely responsible for damages arising, +directly or indirectly, out of its utilization of rights under this License. +Recipient will defend, indemnify and hold harmless Silicon Graphics, Inc. from +and against any loss, liability, damages, costs or expenses (including the +payment of reasonable attorneys fees) arising out of Recipient's use, +modification, reproduction and distribution of the Covered Code or out of any +representation or warranty made by Recipient. +12. U.S. Government End Users. The Covered Code is a "commercial item" +consisting of "commercial computer software" as such terms are defined in title +48 of the Code of Federal Regulations and all U.S. Government End Users acquire +only the rights set forth in this License and are subject to the terms of this +License. +13. Miscellaneous. This License represents the complete agreement concerning +the its subject matter. If any provision of this License is held to be +unenforceable, such provision shall be reformed so as to achieve as nearly as +possible the same legal and economic effect as the original provision and the +remainder of this License will remain in effect. This License shall be governed +by and construed in accordance with the laws of the United States and the State +of California as applied to agreements entered into and to be performed +entirely within California between California residents. Any litigation +relating to this License shall be subject to the exclusive jurisdiction of the +Federal Courts of the Northern District of California (or, absent subject +matter jurisdiction in such courts, the courts of the State of California), +with venue lying exclusively in Santa Clara County, California, with the losing +party responsible for costs, including without limitation, court costs and +reasonable attorneys fees and expenses. The application of the United Nations +Convention on Contracts for the International Sale of Goods is expressly +excluded. Any law or regulation that provides that the language of a contract +shall be construed against the drafter shall not apply to this License. +Exhibit A +License Applicability. Except to the extent portions of this file are made +subject to an alternative license as permitted in the SGI Free Software License +B, Version 1.1 (the "License"), the contents of this file are subject only to +the provisions of the License. You may not use this file except in compliance +with the License. You may obtain a copy of the License at Silicon Graphics, +Inc., attn: Legal Services, 1600 Amphitheatre Parkway, Mountain View, CA 94043- +1351, or at: +http://oss.sgi.com/projects/FreeB +Note that, as provided in the License, the Software is distributed on an "AS +IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS DISCLAIMED, +INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND CONDITIONS OF +MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, AND +NON-INFRINGEMENT. Original Code. The Original Code is: [name of software, +version number, and release date], developed by Silicon Graphics, Inc. The +Original Code is Copyright (c) [dates of first publication, as appearing in the +Notice in the Original Code] Silicon Graphics, Inc. Copyright in any portions +created by third parties is as indicated elsewhere herein. All Rights Reserved. +Additional Notice Provisions: [such additional provisions, if any, as appear in +the Notice in the Original Code under the heading "Additional Notice +Provisions"] + + +============================================================================= +Xprint uses ttf2pt1 for Freetype support. + + -- ttf2pt1 licence -- + +The following copyright notice applies to all the files provided +in this distribution unless explicitly noted otherwise +(the most notable exception being t1asm.c). + + Copyright (c) 1997-2002 by the AUTHORS: + Andrew Weeks + Frank M. Siegert + Mark Heath + Thomas Henlich + Sergey Babkin , + Turgut Uyar + Rihardas Hepas + Szalay Tamas + Johan Vromans + Petr Titera + Lei Wang + Chen Xiangyang + Zvezdan Petkovic + Rigel + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + This product includes software developed by the TTF2PT1 Project + and its contributors. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +For the approximate list of the AUTHORS' responsibilities see the +project history. + +Other contributions to the project are: + +Turgut Uyar + The Unicode translation table for the Turkish language. + +Rihardas Hepas + The Unicode translation table for the Baltic languages. + +Szalay Tamas + The Unicode translation table for the Central European languages. + +Johan Vromans + The RPM file. + +Petr Titera + The Unicode map format with names, the forced Unicode option. + +Frank M. Siegert + Port to Windows + +Lei Wang +Chen Xiangyang + Translation maps for Chinese fonts. + +Zvezdan Petkovic + The Unicode translation tables for the Cyrillic alphabet. + +Rigel + Generation of the dvips encoding files, modification to the Chinese maps. + +I. Lee Hetherington + The Type1 assembler (from the package 't1utils'), its full copyright + notice: + Copyright (c) 1992 by I. Lee Hetherington, all rights reserved. + Permission is hereby granted to use, modify, and distribute this program + for any purpose provided this copyright notice and the one below remain + intact. --- xorg-server-1.4.99.906.orig/debian/changelog +++ xorg-server-1.4.99.906/debian/changelog @@ -0,0 +1,2968 @@ +xorg-server (2:1.4.99.906-1ubuntu2) intrepid; urgency=low + + * Add 135_rethrow_signals.patch + - Currently Xorg "eats" its crash signals, issuing an error message + that it caught the signal and then aborts. This patch raises the + signal it caught, so that subsequent crash handlers (i.e. apport) + can also catch and act on it. + + -- Bryce Harrington Tue, 05 Aug 2008 16:20:46 -0700 + +xorg-server (2:1.4.99.906-1ubuntu1) intrepid; urgency=low + + * Merge with debian experimental, 1.5RC6 (LP: #247120, #253021) + * Drop 120_fedora_xserver-xaa-evict-pixmaps.patch, because offscreen + pixmaps are already disabled by default. + * Drop 124_fix_randr_no_crtc.patch, fixed upstream. + * Add 130_fedora_call_switchcorekeyboard.patch, a hack to fix fd.o bug + #16364. Breaks if the first hotplugged keyboard is not the wanted + keyboard. + * Patches from upstream master: + 131_remove_open-coded_strcasestr.patch + - pre-requisite for the rest + 132_add_parsing_for_xkb.options.patch + - parsing xkb.options didn't work (fd.o #16874) + 133_support_strlist_for_xkboptions.patch + - allow using a list for xkb.options like before. + 134_protect_against_out_of_bounds.patch + - protect against potential out-of-bounds indexing. + + -- Timo Aaltonen Tue, 05 Aug 2008 01:49:42 +0300 + +xorg-server (2:1.4.99.906-1) experimental; urgency=low + + * debian/rules: drop useless handling of nostrip in DEB_BUILD_OPTIONS (this + is taken care of by dh_strip); make the rules files and xsfbs.mk + parallel-safe, and enable parallel=n using example code from Debian + Policy. + * debian/rules: put the source package name and version in builderstring + instead of osvendor, add builder email as well; don't explicitly set + osname, configure sets it to $(uname -srm) by default. + * New upstream release candidate. + - fixes 64-bit Xephyr (closes: #491569) + - work around the DIX losing physical monitor dimensions for randr 1.1 + drivers, in particular nvidia (closes: #488987) + - make sure RANDR reports refresh as 0 if pixel clock is 0 (closes: + #490258) + - doesn't try to load dri2 when it's not built (closes: #491651) + * Switch to running autoreconf at build time, and build-depend on automake, + libtool and xutils-dev. + * Reformat the SGI Free Software License B, to shut up over 1000 lintian + warnings. + + -- Julien Cristau Sun, 27 Jul 2008 18:30:45 +0200 + +xorg-server (2:1.4.99.905-0ubuntu5) intrepid; urgency=low + + * debian/rules: + Added --enable-record. By default, xorg-server does not build the + RECORD extension. Added the record module (for Xnee and other purposes). + + -- Chris Nasho Thu, 31 Jul 2008 17:26:00 -0400 + +xorg-server (2:1.4.99.905-0ubuntu4) intrepid; urgency=low + + * debian/rules: + Add --enable-xcsecurity --enable-appgroup. The SECURITY module was + disabled by default in commit 86b2e59bfb79bd042a13c35fbb4ccecec576f629, + as part of the SELinux merge. However, we need the security module + for xauth on Kubuntu, else ubiquity fails. (Ref. LP 247537) + + -- Bryce Harrington Wed, 16 Jul 2008 06:01:45 -0700 + +xorg-server (2:1.4.99.905-0ubuntu3) intrepid; urgency=low + + * patches/124_fix_randr_no_crtc.patch: + + In certain circumstances, xrandr multiscreen initialization fails + to associate crtcs with monitors, resulting in startup failures + in some GDK-based applications when using -vesa. This occurs + because mode-Clock, mode->HTotal, and mode->VTotal are all 0. + (LP: #246585) + + -- Bryce Harrington Tue, 15 Jul 2008 07:01:13 -0700 + +xorg-server (2:1.4.99.905-0ubuntu2) intrepid; urgency=low + + * Merge with debian git, new changes: + - Build with --enable-glx-tls, we build mesa with TLS support + (otherwise swrast_dri.so might fail to load due to unresolved + symbols). + - Make the servers recommend libgl1-mesa-dri (>= 7.1~rc1). Without + this package, the GLX extension fails to initialise (and takes the + server down) due to missing swrast_dri.so. + + -- Timo Aaltonen Mon, 07 Jul 2008 11:44:39 +0300 + +xorg-server (2:1.4.99.905-0ubuntu1) intrepid; urgency=low + + * Merge with Debian experimental, remaining changes: + * debian/control: + - Change maintainer address. + - xvfb Depends on xauth, xfonts-base. + * debian/patches: + - 100_xserver_exa_force_greedy.patch + Provide a mechanism for drivers to force greedy mode on. + - 101_fedora_xserver-1.3.0-document-fontpath-correctly.patch + Fixes document fontpaths shown in the man page. + - 102_ubuntu_sharevts_load_cpu.patch + Close console fd only when using --sharevts. + - 104_psb_auto.patch + Add automatic detection of Poulsbo hardware when running without a + Device definition. + - 107_fedora_dont_backfill_bg_none.patch + Disable backfilling of windows created with bg=none, which + would otherwise force a framebuffer readback. + - 110_fedora_no_move_damage.patch + Disable damage notifications on move for manually redirected windows. + - 120_fedora_xserver-xaa-evict-pixmaps.patch + A hack to evict XAA pixmaps and disable the pixmap cache when the first + texture is bound. + - 121_only_switch_vt_when_active.diff + Add a check to prevent the X server from changing the VT when + killing GDM from the console. + - 123_no_composite_for_xvfb_run.patch + Use "-extension Composite" to fix xvfb-run crashing. + * Cleaned up patches: + - upstream, either directly or otherwise implemented: + 103_fedora_openchrome.patch, 105_reduce_wakeups_from_smart_scheduler.diff + 108_fedora_honor_displaysize.patch, 109_glx_fail_if_no_texture_bound.diff + 144_fedora_xserver-1.3.0-xnest-exposures.patch, + 146_X86EMU-added-blacklist-for-I-O-port-in-0-0xFF-range.patch, + 147_X86EMU-pass-the-correct-bus-dev-fn-tag-to-pci-emula.patch, + 148_dix_touchscreen_fixes.diff, + 149_add_quirks_for_physical_screen_size_issues.patch, + 150_edid_quirk_lp154w01.patch, 151_x86emu_handle_cpuid.patch, + 153_exa_skip_empty_glyphs.diff, 154_fix_rotation_for_multimon.diff, + 155_exa_fix_off-by-one.diff, 156_resize_composite_overlay.diff, + 157_fix_exa_pixmap_width.diff, 158_xkb_wrapping.diff, + 159_xkb_default_to_null.diff, 160_default_to_intel.diff, + 161_fix_big_endian_cursor.diff, 162_cve-2007-6429.diff, + 163_fix_untrusted_access.diff, 164_fix_context_sharing.diff, + 165_fedora_xserver-1.5.0-xaa-option-inversion.patch, + 166_fix_lpl_monitors.diff, 167_xf86AutoConfig_geode_addition.diff, + 168_closedir.patch, + 170_xorg-xserver-1.4-cve-2008-1377.diff, + 171_xorg-xserver-1.4-cve-2008-1379.diff, + 172_xorg-xserver-1.4-cve-2008-2360.diff, + 173_xorg-xserver-1.4-cve-2008-2361.diff, + 174_xorg-xserver-1.4-cve-2008-2362.diff + - obsolete: + 101_fedora-apm-typedefs.patch + 104_fedora_init_origins_fix.patch + 142_fedora_xserver-1.3.0-no-pseudocolor-composite.patch + 169_xf86AutoConfig_choose_default_driver_if_no_pci.patch + - unnecessary: + 106_ubuntu_fpic_libxf86config.patch (the lib is not shipped) + + -- Timo Aaltonen Fri, 04 Jul 2008 13:39:34 +0300 + +xorg-server (2:1.4.99.905-1) experimental; urgency=low + + [ Julien Cristau ] + * New upstream release candidate + - fixes FTBFS on alpha (closes: #472205); won't work, though, because + of #485528 + - fixes FTBFS on GNU/kFreeBSD (closes: #482550) + * 001_ubuntu_add_extra_modelines_from_xorg.patch: remove, replace with + 001_fedora_extramodes.patch stolen from fedora 9 cvs, rev 1.8. + * xvfb: recommend xauth instead of xbase-clients. + * xserver-xfbdev: recommend xfonts-base. + * debian/rules: drop our special handling for stripping modules, which I + think dates back to the days of the custom module loader. + * debian/rules: drop some remaining xprintisms. + * bump serverminver to 2:1.4.99.905. + * Stop build-depending on mesa-swx11-source (mesa 7.1 will build the + software driver itself), and don't pass --with-mesa-source to configure. + * Build with --enable-glx-tls, we build mesa with TLS support (otherwise + swrast_dri.so might fail to load due to unresolved symbols). + * Make the servers recommend libgl1-mesa-dri (>= 7.1~rc1). Without this + package, the GLX extension fails to initialise (and takes the server down) + due to missing swrast_dri.so. + + [ Timo Aaltonen ] + * Re-enable dri & glx. + * Add a build-dep on mesa-common-dev (>= 7.1~rc1) and bump the desired + version of libgl1-mesa-dev respectively. + * Bump the libdrm-dev build-dep version to 2.3.1. + + -- Julien Cristau Sun, 13 Jul 2008 23:33:05 +0200 + +xorg-server (2:1.4.99.902-1) experimental; urgency=low + + * Add postrm script for xserver-xorg-core, to remove + /var/log/Xorg.*.log{,.old} on purge (closes: #343384). + * Use dh_* -s instead of -a in binary-arch, to fix FTBFS on s390 (which + doesn't build xserver-xfbdev). + * New upstream release candidate. + + refresh 13_debian_add_xkbpath_env_variable.diff + + doesn't crash when there is no pci device (closes: #472823) + + includes a quirk for LPL monitors with broken EDID (closes: #473260) + + XKB is now enabled in Xnest (closes: #164379) + * Stop building Xprt, and drop related patches; it will be provided as a + separate package. + + -- Julien Cristau Fri, 23 May 2008 00:58:45 +0200 + +xorg-server (2:1.4.99.901-2) experimental; urgency=low + + * xserver-xorg-dev needs to depend on libpciaccess-dev. + * Pull from upstream server-1.5-branch as of March 21st (commit 98249dfa). + + fixes build on ia64 (closes: #471663) + * Add missing conflicts on xserver-xorg-input-2. + + -- Julien Cristau Fri, 21 Mar 2008 22:40:36 +0100 + +xorg-server (2:1.4.99.901-1) experimental; urgency=low + + [ Julien Cristau ] + * New upstream release candidate + * Update patches: + + 001_ubuntu_add_extra_modelines_from_xorg.patch: remove useless + whitespace changes + + 02_libvgahw_gcc4_volatile_fix.diff: delete, the gcc bug this was working + around is fixed for a long time + + 03_auto_load_driver.diff, 04_auto_load_driver_no_conf.diff, + 05_kill_type1.diff, 07_autoconfig_screen_with_device_section.diff, + 08_better_dpms_logging.diff, 10_dont_look_in_home_for_config.diff, + 11_dont_crash_on_bad_dri_mode.diff, 14_default_screen_section.diff, + 21_glx_align_fixes.patch, 40_default_dpi_96.patch, + 41_vbe_filter_less.diff, + 42_dont_break_grab_and_focus_for_window_when_redirecting.diff, + 43_allow_override_BIOS_EDID_preferred_mode.diff, + 44_preferredmode_infinite_loop.diff, + 45_only_XF86_APM_CAPABILITY_CHANGED_for_video_change_acpi_events.diff, + 46_reduce_wakeups_from_smart_scheduler.patch, + 47_fbdevhw_magic_numbers.diff, 51_xkb-and-loathing.diff, + 93_xprint_fonts_fix: remove, applied upstream + + 06_use_proc_instead_of_sysfs_for_pci_domains.diff: disable for now, + shouldn't be needed with pciaccess + + 13_debian_add_xkbpath_env_variable.diff: refresh + + 94_xprint_XSERVER_LIBS: disable, should be fixed upstream + * Disable glx, dri and dri2 for now. + * Re-enable dmx, build the xdmx and xdmx-tools packages. + * Add build-deps on libpciaccess-dev and libssl-dev for Xorg, bump build-dep + on libpixman-1-dev to >= 0.9.5. + * Add build-dep on libxv-dev for Xephyr. + * Drop XS- prefix from Vcs-* debian/control fields. + * Bump videoabiver to 2.9, inputabiver to 2.1, serverminver to 2:1.4.99.901. + * Drop obsolete --with-rgb-path configure option. + * /etc/X11/xserver/SecurityPolicy is gone, don't install it. + * Don't build-dep on "foo (>= bar-1)", to fix lintian warnings. + + [ Drew Parsons ] + * Remove 94_xprint_XSERVER_LIBS (not needed in xserver 1.5). + + [ Brice Goglin ] + * Build the Xfbdev server for real now, in new package xserver-xfbdev, + closes: #439764. + + -- Julien Cristau Fri, 14 Mar 2008 13:46:48 +0100 + +xorg-server (2:1.4.2-2) unstable; urgency=low + + [ Julien Cristau ] + * GLX: zero the buffer used in __glXDisp_GetVisualConfigs (backport from + upstream). + + [ Brice Goglin ] + * Cherry-pick various patches from upstream: + - Fix incorrect test regarding keyboard map. + - xfree86: append, not prepend, new input devices to xf86InputDevs. + + -- Julien Cristau Fri, 18 Jul 2008 10:53:26 +0200 + +xorg-server (2:1.4.2-1) unstable; urgency=low + + [ Julien Cristau ] + * New upstream release. + * Security fixes from the previous upload are included upstream. + * Cherry-pick patches from upstream git to make the LeftOf and Above options + in xorg.conf actually work (closes: #466526). + * 48_xaa_nooffscreenpixmaps.diff: disable XAA offscreen pixmaps by default; + they can be enabled with Option "XaaOffscreenPixmaps" (closes: #478277, + #433331). + * Cherry-pick various patches from upstream for Xorg's modes code: + - add quirks for monitors with broken EDID (closes: #473260) + - fix max clock computation + - inherit the preferred mode from the global configuration (so if you have + Modes "800x600" in the Display subsection the server will honor it + instead of ignoring it) + * Backport patch from upstream git to fix emulation of int1A PCI BIOS + services (closes: #404885). Thanks, Robert de Bath! + + [ Brice Goglin ] + * Update patches to not require -p0, closes: #485185. + + -- Julien Cristau Thu, 26 Jun 2008 01:57:18 +0200 + +xorg-server (2:1.4.1~git20080517-2) unstable; urgency=high + + * High urgency upload for security fixes. + * New patch from upstream to fix multiple security issues reported by + iDefense: + CVE-2008-2360 - RENDER Extension heap buffer overflow + CVE-2008-2361 - RENDER Extension crash + CVE-2008-2362 - RENDER Extension memory corruption + CVE-2008-1379 - MIT-SHM arbitrary memory read + CVE-2008-1377 - RECORD and Security extensions memory corruption + + -- Julien Cristau Mon, 09 Jun 2008 14:59:04 +0200 + +xorg-server (2:1.4.1~git20080517-1) unstable; urgency=low + + [ Julien Cristau ] + * Pass -DPRE_RELEASE=0 in CPPFLAGS, so we don't print the pre-release + warning in the Xorg log. + * Pull from upstream server-1.4-branch + + drop patch 40_default_dpi_96.patch applied upstream + + refresh patches 03_auto_load_driver.diff and + 04_auto_load_driver_no_conf.diff + * Don't build-depend on packages with a -1 debian revision. + * Drop the XS- prefix from Vcs-* control fields. + * Add x11-common to the Depends field of xnest, xvfb and xserver-xephyr (its + init script sets up the /tmp/.X11-unix directory). + * Re-enable the dmx DDX, and build the xdmx and xdmx-tools packages (the + build is now fixed upstream); closes: #449254. + + [ Drew Parsons ] + * Patch 95_xprint_disable_dbus disables dbus in Xprint by providing + dummy config functions. Taken from upstream commit + 2a3d1421e0cc18822ae8f478fcc272e16a9e9340, with removal of + CONFIG_LIB from configure.ac shifted to 94_xprint_XSERVER_LIBS. + Closes: #472180. + * Enable the xprint DDX, and build the xprint and xprint-common packages. + + -- Julien Cristau Sun, 18 May 2008 13:36:11 +0200 + +xorg-server (2:1.4.1~git20080507-1) unstable; urgency=low + + * Pull from upstream server-1.4-branch, highlights: + - the server should now scale input events correctly + - xkb keymap failures now give an explanation instead of just a 'failed to + load' message + * Drop patch 51_xkb-and-loathing.diff, applied upstream + * Refresh patches 13_debian_add_xkbpath_env_variable.diff, + 21_glx_align_fixes.patch, 46_reduce_wakeups_from_smart_scheduler.patch and + 94_xprint_XSERVER_LIBS. + * chmod +x configure in debian/rules clean so we can build a git snapshot + where configure is not in the tarball. + * Cherry-pick fix from upstream's master branch to re-arm the DPMS timer + when re-enabling DPMS (closes: #397197). + + -- Julien Cristau Thu, 08 May 2008 15:34:38 +0200 + +xorg-server (2:1.4.1~git20080131-4) unstable; urgency=low + + * fix AlwaysCore handling: enabling AlwaysCore in xorg.conf 1) is the + default, and 2) shouldn't prevent the device from sending core events + (closes: #461760). + + -- Julien Cristau Tue, 29 Apr 2008 20:14:22 +0200 + +xorg-server (2:1.4.1~git20080131-3) unstable; urgency=low + + * XKB: Fix processInputProc wrapping (cherry-picked from upstream). + Thanks to Thomas Jaeger. This should fix the bug with some keys getting + stuck (closes: #473165). + * xkb: when copying the keymap, make sure the structs default to 0/NULL + (cherry-picked from upstream). Fixes a crash and closes: #461783. + * __glXDRIbindTexImage: Fail if no texture bound to pixmap's texture target + (cherry-picked from upstream). + * EXA: Fix off-by-one in polyline drawing (cherry-picked from upstream). + * EXA: Skip empty glyphs (cherry-picked from upstream). + * Fix overly-restrictive integer overflow check in EXA pixmap creation + (cherry-picked from upstream). Fixes BadAlloc errors returned by + XCreatePixmap for pixmaps of width 8192 or greater (closes: #471782). + + Following patches by Bart Trojanowski, stolen from the ubuntu package: + * 15_X86EMU-added-blacklist-for-I-O-port-in-0-0xFF-range.patch + - Restrict access to I/O ports in range 0-0xFF from x86emu. + * 16_X86EMU-pass-the-correct-bus-dev-fn-tag-to-pci-emula.patch + - Fix improper emulation of PCI access General Software BIOS. + * Add 17_x86emu_handle_cpuid.patch to fix X86EMU CPUID handling. + (closes: #451089). + + -- Julien Cristau Wed, 02 Apr 2008 00:20:15 +0200 + +xorg-server (2:1.4.1~git20080131-2) unstable; urgency=low + + [ Brice Goglin ] + * Add 46_reduce_wakeups_from_smart_scheduler.patch to reduce + power consumption, closes: #462700. + + [ Drew Parsons ] + * Restore Xprint, cherry-picking commits + f7f79724fdea0cc6fda0e90e56431df937d49335 and + d67e210f3458b62d7d4a6032aabfda0004d661c1 from master (xserver 1.5). + Include patch 94_xprint_XSERVER_LIBS to give new meaning of + XSERVER_LIBS as expected in configure.ac from master (see commit + a02db0d500cac20d0f0f107d27c064a175018421). Delete + 94_xprint_XSERVER_LIBS when we upgrade to xserver 1.5. + + [ Julien Cristau ] + * Re-enable patch 51_xkb-and-loathing.diff: ignore SIGALRM around calls to + Popen()/Pclose() to fix a hang when opening menus in OpenOffice.org + (once again closes: #433131) + * Refresh all patches to make patch-audit happy. + * Pull from upstream server-1.4-branch as of March 14th. + * 42_dont_break_grab_and_focus_for_window_when_redirecting.diff removed, + applied upstream. + * Don't build xprint just yet, because it needs NEW processing. + + [ David Nusinow ] + * Add 11_dont_crash_on_bad_dri_mode. See bugzilla #13860 + + -- Julien Cristau Fri, 14 Mar 2008 15:18:16 +0100 + +xorg-server (2:1.4.1~git20080131-1ubuntu12) intrepid; urgency=low + + * Fix multiple security issues: + + CVE-2008-2360 - RENDER Extension heap buffer overflow + + CVE-2008-2361 - RENDER Extension crash + + CVE-2008-2362 - RENDER Extension memory corruption + + CVE-2008-1379 - MIT-SHM arbitrary memory read + + CVE-2008-1377 - RECORD and Security extensions memory corruption + + -- Bryce Harrington Wed, 11 Jun 2008 10:54:15 -0700 + +xorg-server (2:1.4.1~git20080131-1ubuntu11) intrepid; urgency=low + + * 169_xf86AutoConfig_choose_default_driver_if_no_pci.patch + - Choose the default driver for the platform instead of the generic + default (vesa) if there is no PCI info. Without this, on platforms + like PS3 where fbdev should be used rather than vesa, the system + will fail to start up. (LP: #219424) + + -- Bryce Harrington Tue, 13 May 2008 13:09:17 -0700 + + +xorg-server (2:1.4.1~git20080131-1ubuntu10) intrepid; urgency=low + + [Timo Aaltonen] + * 166_fix_lpl_monitors.diff: + - fix LPL monitors properly (LP: #204065) + + [Martin-Eric Racine] + * 167_xf86AutoConfig_geode_addition.diff: + - Autodetect geode video devices (LP: #219630) + + [Bryce Harrington] + * 166_fix_lpl_monitors.diff: + - Modified to apply to Ubuntu + * 168_closedir.patch: + - Fix crash on PS3 due to closing a dir that wasn't successfully opened + (LP: #217647) + + -- Bryce Harrington Tue, 13 May 2008 00:03:40 -0700 + +xorg-server (2:1.4.1~git20080131-1ubuntu9) hardy; urgency=low + + * debian/patches/series, + debian/patches/165_fedora_xserver-1.5.0-xaa-option-inversion.patch: + - Turn on patch included in previous commit - obviously accidentially + forgotten. + - Now that its really enabled, make it apply to 1.4.1 code base + accordingly. (LP: #182038) + + -- Alexander Sack Tue, 15 Apr 2008 18:23:51 +0200 + +xorg-server (2:1.4.1~git20080131-1ubuntu8) hardy; urgency=low + + * debian/patches/165_fedora_xserver-1.5.0-xaa-option-inversion.patch: + - Turn XAA Offscreen Pixmaps off by default, and use + XaaOffscreenPixmaps "true" to turn them on. This setting was an + early pre-EXA HW optimization attempt that didn't pan out; upstream is + deprecating XAA in favor of EXA generally, and for situations where + XAA is still in use recommends NOT using this optimization hack, since + they found it often just made performance worse, and sometimes created + visualization bugs. People wishing to gain added performance should be + experimenting with EXA anyway, not this setting. (closes LP: #182038) + + -- Bryce Harrington Mon, 21 Apr 2008 12:30:53 -0700 + +xorg-server (2:1.4.1~git20080131-1ubuntu7) hardy; urgency=low + + * 159_xkb_default_to_null.diff: + When copying the keymap, make sure the structs default to 0/NULL. + (LP: #184651) + * 160_default_to_intel.diff: + Default to using intel instead of i810. (LP: #158709) + * 161_fix_big_endian_cursor.diff: + Fix RandR 1.2 driver interface conversion of two colour cursors to + ARGB. (LP: #141118) + * Fixes from the upstream 1.4-branch: + - 162_cve-2007-6429.diff: + CVE-2007-6429: Always test for size+offset wrapping. + - 163_fix_untrusted_access.diff: + Security: Fix for fdo bug #14480: untrusted access broken in 7.3. + - 164_fix_context_sharing.diff: + Fix context sharing between direct/indirect contexts + + -- Timo Aaltonen Wed, 09 Apr 2008 11:06:04 +0300 + +xorg-server (2:1.4.1~git20080131-1ubuntu6) hardy; urgency=low + + * 157_fix_exa_pixmap_width.diff: + A patch from upstream to allow wider pixmaps with EXA (LP: #205599) + * 158_xkb_wrapping.diff: + A patch reviewed by upstream that prevents keys from getting stuck under + certain situations. (LP: #194214) + * 51_xkb-and-loathing.diff: + Re-enable. Ignore SIGALRM around calls to Popen()/Pclose() to fix a hang + when opening menus in OpenOffice.org. (LP: #204137) + + -- Timo Aaltonen Sun, 30 Mar 2008 19:18:32 +0300 + +xorg-server (2:1.4.1~git20080131-1ubuntu5) hardy; urgency=low + + * Add some patches from upstream 1.4-branch or proposed set: + - 109_glx_fail_if_no_texture_bound.diff + + __glXDRIbindTexImage: Fail if no texture bound to pixmap's texture + target. + - 153_exa_skip_empty_glyphs.diff + + Fix a crasher when EXA and RenderAccel is in use. + - 154_fix_rotation_for_multimon.diff + + Fix rotation for multi-monitor situation. + - 155_exa_fix_off-by-one.diff + + Fix off-by-one in polyline drawing. + - 156_resize_composite_overlay.diff + + Resize composite overlay window when the root window changes. + (LP: #199700) + + -- Timo Aaltonen Thu, 13 Mar 2008 18:21:41 +0200 + +xorg-server (2:1.4.1~git20080131-1ubuntu4) hardy; urgency=low + + * Add 152_xserver_exa_force_greedy.patch to provide a mechanism for + drivers to force greedy mode on. (LP: #177492, others) + + -- Bryce Harrington Tue, 19 Feb 2008 13:38:16 -0800 + +xorg-server (2:1.4.1~git20080131-1ubuntu3) hardy; urgency=low + + [ Bryce Harrington ] + * Add 150_edid_quirk_lp154w01.patch to fix font size on LGPhilipsLCD + LP154W01-TLAE (LP: #127827) + * Add 149_add_quirks_for_physical_screen_size_issues.patch to help + address various common EDID issues (like monitors that report in + centimeters instead of millimeters, etc.) (LP: #151311) + + [ Timo Aaltonen ] + * Add 151_x86emu_handle_cpuid.patch to fix X86EMU CPUID handling. + (LP: #180742) + + -- Timo Aaltonen Tue, 19 Feb 2008 17:48:05 +0200 + +xorg-server (2:1.4.1~git20080131-1ubuntu2) hardy; urgency=low + + * Add patch 148_dix_touchscreen_fixes.diff from Matthew Garrett to fix + touchscreen issues with DIX. + http://lists.freedesktop.org/archives/xorg-commit/2008-February/014648.html + + -- Steve Kowalik Fri, 08 Feb 2008 10:30:04 +1100 + +xorg-server (2:1.4.1~git20080131-1ubuntu1) hardy; urgency=low + + [ Timo Aaltonen ] + * Merge with Debian unstable, remaining changes: + * debian/control: + - Change maintainer address. + - set Conflicts: xkb-data (<< 0.9), since xkb-path is + different compared to Dapper. + - xvfb Depends on xauth, xfonts-base. + * debian/patches: + - 101_fedora-apm-typedefs.patch: + Temporary hack from Fedora for broken kernels that don't publish the + /dev/apm_bios types. + - 102_ubuntu_sharevts_load_cpu.patch: + Close console fd only when using --sharevts. + - 103_fedora_openchrome.patch: + Patch from Fedora to use openchrome instead of via. + - 104_fedora_init_origins_fix.patch + Multihead initialization. + - 105_reduce_wakeups_from_smart_scheduler.diff: + Patch from upstream to reduce wakeups and improve battery life. + - 106_ubuntu_fpic_libxf86config.patch + Add -fPIC to makefiles for xfree86/parser. + - 107_fedora_dont_backfill_bg_none.patch + Disable backfilling of windows created with bg=none, which + otherwise would force a framebuffer readback. + - 110_fedora_no_move_damage.patch + Disable damage notifications on move for manually redirected windows. + - 120_fedora_xserver-xaa-evict-pixmaps.patch: + New version of the hack to copy textures from video memory. Shouldn't + break EXA anymore. + - 121_only_switch_vt_when_active.diff + Add a check to prevent the X server from changing the VT when + killing GDM from the console. + - 123_no_composite_for_xvfb_run.patch + Use "-extension Composite" to fix xvfb-run crashing. + - 133_psb_auto.patch + Add automatic detection of Poulsbo hardware when running + without a Device definition. + - 139_fedora_xserver-1.3.0-document-fontpath-correctly.patch + Fixes document fontpaths shown in the man page. + - 142_fedora_xserver-1.3.0-no-pseudocolor-composite.patch + Composite on 8bpp pseudocolor root windows appears to fail, so just + disable it on anything pseudocolor for safety. + - 144_fedora_xserver-1.3.0-xnest-exposures.patch: + Only collect xnest exposures for xexposes with non-zero height and width. + * 108_fedora_honor_displaysize.patch: + - Patch from upstream/Fedora to honor the DisplaySize-setting. + (LP: #135738, b.fd.o #9758) + * Drop patch 100_avoid_acpi_insanity.diff, superseded by patch 45. + + [ Bart Trojanowski, Martin-Eric Racine ] + * 146_X86EMU-added-blacklist-for-I-O-port-in-0-0xFF-range.patch + - Restrict access to I/O ports in range 0-0xFF from x86emu. + (LP: #140051) + * 147_X86EMU-pass-the-correct-bus-dev-fn-tag-to-pci-emula.patch + - Fix improper emulation of PCI access General Software BIOS. + (LP: #140051) + + -- Timo Aaltonen Tue, 05 Feb 2008 18:57:14 +0200 + +xorg-server (2:1.4.1~git20080131-1) unstable; urgency=low + + [ Brice Goglin ] + * Add 45_only_XF86_APM_CAPABILITY_CHANGED_for_video_change_acpi_events.diff + to prevent XF86_APM_CAPABILITY_CHANGED from being issued for all ACPI + events, thanks Sjoerd Simons, closes: #461463. + + [ David Nusinow ] + * Update Japanese translation from Hideki Yamane. closes: #462761 + * New upstream pull + + Fixes crashes due to absent LED's being referenced + + -- David Nusinow Thu, 31 Jan 2008 21:43:12 -0500 + +xorg-server (2:1.4.1~git20080118-1ubuntu2) hardy; urgency=low + + * Remove the DPI patch for real this time, conflicts with the upstream + commit that was pulled. + * 105_reduce_wakeups_from_smart_scheduler.diff: + Patch from upstream to reduce wakeups and improve battery life. + + -- Timo Aaltonen Sat, 19 Jan 2008 20:26:41 +0200 + +xorg-server (2:1.4.1~git20080118-1ubuntu1) hardy; urgency=low + + * Merge with Debian unstable, remaining changes: + * debian/control: + - Change maintainer address. + - set Conflicts: xkb-data (<< 0.9), since xkb-path is + different compared to Dapper. + - xvfb Depends on xauth, xfonts-base. + * debian/patches: + - 100_avoid_acpi_insanity.diff + Don't send a configuration change event just because somebody's pressed + a brightness key. + - 101_fedora-apm-typedefs.patch: + Temporary hack from Fedora for broken kernels that don't publish the + /dev/apm_bios types. + - 102_ubuntu_sharevts_load_cpu.patch: + Close console fd only when using --sharevts. + - 103_fedora_openchrome.patch: + Patch from Fedora to use openchrome instead of via. + - 104_fedora_init_origins_fix.patch + Multihead initialization. + - 106_ubuntu_fpic_libxf86config.patch + Add -fPIC to makefiles for xfree86/parser. + - 107_fedora_dont_backfill_bg_none.patch + Disable backfilling of windows created with bg=none, which + otherwise would force a framebuffer readback. + - 110_fedora_no_move_damage.patch + Disable damage notifications on move for manually redirected windows. + - 120_fedora_xserver-xaa-evict-pixmaps.patch: + New version of the hack to copy textures from video memory. Shouldn't + break EXA anymore. + - 121_only_switch_vt_when_active.diff + Add a check to prevent the X server from changing the VT when + killing GDM from the console. + - 123_no_composite_for_xvfb_run.patch + Use "-extension Composite" to fix xvfb-run crashing. + - 133_psb_auto.patch + Add automatic detection of Poulsbo hardware when running + without a Device definition. + - 139_fedora_xserver-1.3.0-document-fontpath-correctly.patch + Fixes document fontpaths shown in the man page. + - 142_fedora_xserver-1.3.0-no-pseudocolor-composite.patch + Composite on 8bpp pseudocolor root windows appears to fail, so just + disable it on anything pseudocolor for safety. + - 144_fedora_xserver-1.3.0-xnest-exposures.patch: + Only collect xnest exposures for xexposes with non-zero height and width. + + -- Timo Aaltonen Sat, 19 Jan 2008 02:40:00 +0200 + +xorg-server (2:1.4.1~git20080118-1) unstable; urgency=low + + [ Brice Goglin ] + * Add 42_dont_break_grab_and_focus_for_window_when_redirecting.diff + to prevent password authentication bypass, closes: #449108. + + [ Julien Cristau ] + * New upstream snapshot + + includes the security fixes from the previous version + + fixes regression introduced by the fix for CVE-2007-6429 in the MIT-SHM + extension (closes: #461410) + + -- Brice Goglin Fri, 18 Jan 2008 22:20:32 +0100 + +xorg-server (2:1.4.1~git20080105-2) unstable; urgency=low + + [ David Nusinow ] + * Improve dpms logging patch to correctly label message type + + [ Brice Goglin ] + * Grab upstream commit db9ae863536fff80b5463d99e71dc47ae587980d + to set DEFAULT_DPI to 96 instead of 75. + + [ Julien Cristau ] + * Fix multiple security issues + + CVE-2007-6427: XInput Extension Memory Corruption + + CVE-2007-6428: TOG-CUP Extension Memory Corruption + + CVE-2007-6429: EVI Extension Integer Overflow, + MIT-SHM Extension Integer Overflow + + CVE-2007-5760: XFree86-Misc Extension Invalid Array Index + + CVE-2007-5958: file existence disclosure + + CVE-2008-0006: PCF font parser buffer overflow + * Bump Standards-Version to 3.7.3 (no changes). + + -- Julien Cristau Thu, 17 Jan 2008 15:10:03 +0100 + +xorg-server (2:1.4.1~git20080105-1ubuntu1) hardy; urgency=low + + * Merge with Debian unstable, remaining changes: + * debian/control: + - Change maintainer address. + - set Conflicts: xkb-data (<< 0.9), since xkb-path is + different compared to Dapper. + - xvfb Depends on xauth, xfonts-base. + * debian/patches: + - 100_avoid_acpi_insanity.diff + Don't send a configuration change event just because somebody's pressed + a brightness key. + - 101_fedora-apm-typedefs.patch: + Temporary hack from Fedora for broken kernels that don't publish the + /dev/apm_bios types. + - 102_ubuntu_sharevts_load_cpu.patch: + Close console fd only when using --sharevts. + - 104_fedora_init_origins_fix.patch + Multihead initialization. + - 106_ubuntu_fpic_libxf86config.patch + Add -fPIC to makefiles for xfree86/parser. + - 107_fedora_dont_backfill_bg_none.patch + Disable backfilling of windows created with bg=none, which + otherwise would force a framebuffer readback. + - 110_fedora_no_move_damage.patch + Disable damage notifications on move for manually redirected windows. + - 120_fedora_xserver-xaa-evict-pixmaps.patch: + New version of the hack to copy textures from video memory. Shouldn't + break EXA anymore. + - 121_only_switch_vt_when_active.diff + Add a check to prevent the X server from changing the VT when + killing GDM from the console. + - 123_no_composite_for_xvfb_run.patch + Use "-extension Composite" to fix xvfb-run crashing. + - 133_psb_auto.patch + Add automatic detection of Poulsbo hardware when running + without a Device definition. + - 138_fedora_xserver-1.3.0-default-dpi.patch + Changes default dpi to 96. + - 139_fedora_xserver-1.3.0-document-fontpath-correctly.patch + Fixes document fontpaths shown in the man page. + - 142_fedora_xserver-1.3.0-no-pseudocolor-composite.patch + Composite on 8bpp pseudocolor root windows appears to fail, so just + disable it on anything pseudocolor for safety. + - 144_fedora_xserver-1.3.0-xnest-exposures.patch: + Only collect xnest exposures for xexposes with non-zero height and width. + * debian/patches/103_fedora_openchrome.patch: + - Patch from Fedora to use openchrome instead of via. + + -- Timo Aaltonen Tue, 08 Jan 2008 18:05:21 +0200 + +xorg-server (2:1.4.1~git20080105-1) unstable; urgency=low + + * Don't reference non-existent bug-reporting.txt file in xvfb-run.1 + * New upstream git pull, again from the server-1.4-branch + + Drop 08_xkb_infinite_loop.diff, it's upstream now + * Improve logging when DPMS is enabled implicitly + + Adds 08_better_dpms_logging.diff + + -- David Nusinow Sun, 06 Jan 2008 16:56:38 -0500 + +xorg-server (2:1.4.1~git20071212-1ubuntu2) hardy; urgency=low + + * debian/patches/101_fedora-apm-typedefs.patch: + - Temporary hack from Fedora for broken kernels that don't publish the + /dev/apm_bios types. + + -- Timo Aaltonen Mon, 17 Dec 2007 11:54:46 +0200 + +xorg-server (2:1.4.1~git20071212-1ubuntu1) hardy; urgency=low + + * Merge with Debian unstable, remaining changes: + * debian/control: + - Change maintainer address. + - set Conflicts: xkb-data (<< 0.9), since xkb-path is + different compared to Dapper. + - xvfb Depends on xauth, xfonts-base. + * debian/patches: + - 100_avoid_acpi_insanity.diff + Don't send a configuration change event just because somebody's pressed + a brightness key. + - 102_ubuntu_sharevts_load_cpu.patch: + Close console fd only when using --sharevts. + - 104_fedora_init_origins_fix.patch + Multihead initialization. + - 106_ubuntu_fpic_libxf86config.patch + Add -fPIC to makefiles for xfree86/parser. + - 107_fedora_dont_backfill_bg_none.patch + Disable backfilling of windows created with bg=none, which + otherwise would force a framebuffer readback. + - 110_fedora_no_move_damage.patch + Disable damage notifications on move for manually redirected windows. + - 120_fedora_xserver-xaa-evict-pixmaps.patch: + New version of the hack to copy textures from video memory. Shouldn't + break EXA anymore. + - 121_only_switch_vt_when_active.diff + Add a check to prevent the X server from changing the VT when + killing GDM from the console. + - 123_no_composite_for_xvfb_run.patch + Use "-extension Composite" to fix xvfb-run crashing. + - 133_psb_auto.patch + Add automatic detection of Poulsbo hardware when running + without a Device definition. + - 138_fedora_xserver-1.3.0-default-dpi.patch + Changes default dpi to 96. + - 139_fedora_xserver-1.3.0-document-fontpath-correctly.patch + Fixes document fontpaths shown in the man page. + - 142_fedora_xserver-1.3.0-no-pseudocolor-composite.patch + Composite on 8bpp pseudocolor root windows appears to fail, so just + disable it on anything pseudocolor for safety. + - 144_fedora_xserver-1.3.0-xnest-exposures.patch: + Only collect xnest exposures for xexposes with non-zero height and width. + + -- Timo Aaltonen Thu, 13 Dec 2007 13:43:35 +0200 + +xorg-server (2:1.4.1~git20071212-2) unstable; urgency=low + + * Add patch 08_xkb_infinite_loop.diff from upstream bug#13511: papers over + an infinite loop in event processing (closes: #451989). + + -- Julien Cristau Sat, 22 Dec 2007 00:02:01 +0100 + +xorg-server (2:1.4.1~git20071212-1) unstable; urgency=low + + [ Julien Cristau ] + * debian/rules: Use lsb_release -i -s to get the vendor name, instead of + hardcoding "Debian". + * debian/control: build-dep on lsb-release. + * Cherry-pick commit f30abe30 from master: edid quirk for MAX 0x77e monitor. + * Add patch 44_preferredmode_infinite_loop.diff from upstream git: fixes an + infinite loop when PreferredMode is used in xorg.conf. + + [ David Nusinow ] + * New upstream version. This is based on the server-1.4-branch, and includes + all the changes in the 1.4.0.90 (pre-)release as well as additional fixes. + This is primarily a bugfix release + + Remove 12_bgPixel_fix_64bit_issue.diff. Applied upstream + + -- David Nusinow Wed, 12 Dec 2007 20:19:11 -0500 + +xorg-server (2:1.4.1~git20071119-1ubuntu1) hardy; urgency=low + + * Merge with Debian unstable, remaining changes: + * debian/control: + - Change maintainer address. + - set Conflicts: xkb-data (<< 0.9), since xkb-path is + different compared to Dapper. + - xvfb Depends on xauth, xfonts-base. + * debian/rules: + - --with-os-vendor=Ubuntu + * debian/patches: + - 100_avoid_acpi_insanity.diff + Don't send a configuration change event just because somebody's pressed + a brightness key. + - 102_ubuntu_sharevts_load_cpu.patch: + Close console fd only when using --sharevts. + - 104_fedora_init_origins_fix.patch + Multihead initialization. + - 106_ubuntu_fpic_libxf86config.patch + Add -fPIC to makefiles for xfree86/parser. + - 107_fedora_dont_backfill_bg_none.patch + Disable backfilling of windows created with bg=none, which + otherwise would force a framebuffer readback. + - 110_fedora_no_move_damage.patch + Disable damage notifications on move for manually redirected windows. + - 121_only_switch_vt_when_active.diff + Add a check to prevent the X server from changing the VT when + killing GDM from the console. + - 123_no_composite_for_xvfb_run.patch + Use "-extension Composite" to fix xvfb-run crashing. + - 133_psb_auto.patch + Add automatic detection of Poulsbo hardware when running + without a Device definition. + - 138_fedora_xserver-1.3.0-default-dpi.patch + Changes default dpi to 100. + - 139_fedora_xserver-1.3.0-document-fontpath-correctly.patch + Fixes document fontpaths shown in the man page. + - 142_fedora_xserver-1.3.0-no-pseudocolor-composite.patch + Composite on 8bpp pseudocolor root windows appears to fail, so just + disable it on anything pseudocolor for safety. + - 144_fedora_xserver-1.3.0-xnest-exposures.patch: + Only collect xnest exposures for xexposes with non-zero height and width. + * Bring back old changelog entries. + * debian/patches/120_fedora_xserver-xaa-evict-pixmaps.patch: + - New version of the hack to copy textures from video memory. Shouldn't + break EXA anymore. + + -- Timo Aaltonen Tue, 20 Nov 2007 15:35:59 +0200 + +xorg-server (2:1.4.1~git20071119-1) unstable; urgency=low + + * Ship a .orig.tar.gz that's been autoreconf'ed. Closes: #451891 + * Re-enable validation of the screen section of xorg.conf + Modify 14_default_screen_section.diff. This also fixes a problem where the + server can't find the device section when it is specified in the screen + section. Closes: #451950 + + -- David Nusinow Mon, 19 Nov 2007 20:38:04 -0500 + +xorg-server (2:1.4.1~git20071117-1) unstable; urgency=low + + [ Julien Cristau ] + * Add conflict on xserver-xorg-input-wacom (<< 0.7.8) to xserver-xorg-core. + That driver is built against the old ABI, but doesn't provide + xserver-xorg-input. + + [ David Nusinow ] + * Add 14_default_screen_section.diff. This allows you to not have a screen + section in your xorg.conf. A basic default one with a simple identifier + will be created for you in this case using all default values + + [ Christian Perrier ] + * Debconf translations: + * Galician. Closes: #444764 + * German. Closes: #444917 + * Brazilian Portuguese. Closes: #445266 + * Russian. Closes: #443859 + * Portuguese. Closes: #445051 + * Slovak. Closes: #446418, #448220 + + [ Brice Goglin ] + * Bump x11proto-core-dev build-dependency to >= 7.0.9, + thanks Max Kellermann, closes: #446869. + + [ David Nusinow ] + * New upstream stable snapshot + + fixes a bunch of input-related bugs, notably keyboard leds + (closes: #440743 and its pile of duplicates) + * Remove patches merged in this snapshot + + 08_exa_fix_exaFillRegionTiled_fallback.diff + + 11_exa_no_negative_tile_offsets.diff + + 42_fix_RemoveGeneralSocket_crash_from_dbus.diff + + 44_XKB_mapping_changes_for_all_core-sending_devices.diff + + 45_GetKeyboardEvents_reject_out-of-range_keycodes.diff + * Make xephyr recommend xfonts-base. Closes: #451542 + + -- David Nusinow Sat, 17 Nov 2007 18:54:02 -0500 + +xorg-server (2:1.4.1~git20071105-1ubuntu2) hardy; urgency=low + + * Brown paper bag release: include all the patches. + + -- Timo Aaltonen Sat, 10 Nov 2007 15:24:28 +0200 + +xorg-server (2:1.4.1~git20071105-1ubuntu1) hardy; urgency=low + + * Merge with Debian unstable, remaining changes: + * debian/control: + - Change maintainer address. + - set Conflicts: xkb-data (<< 0.9), since xkb-path is + different compared to Dapper. + - xvfb Depends on xauth, xfonts-base. + * debian/rules: + - --with-os-vendor=Ubuntu + * debian/patches: + - 100_avoid_acpi_insanity.diff + Don't send a configuration change event just because somebody's pressed + a brightness key. + - 102_ubuntu_sharevts_load_cpu.patch: + Close console fd only when using --sharevts. + - 104_fedora_init_origins_fix.patch + Multihead initialization. + - 106_ubuntu_fpic_libxf86config.patch + Add -fPIC to makefiles for xfree86/parser. + - 107_fedora_dont_backfill_bg_none.patch + Disable backfilling of windows created with bg=none, which + otherwise would force a framebuffer readback. + - 110_fedora_no_move_damage.patch + Disable damage notifications on move for manually redirected windows. + - 121_only_switch_vt_when_active.diff + Add a check to prevent the X server from changing the VT when + killing GDM from the console. + - 123_no_composite_for_xvfb_run.patch + Use "-extension Composite" to fix xvfb-run crashing. + - 133_psb_auto.patch + Add automatic detection of Poulsbo hardware when running + without a Device definition. + - 138_fedora_xserver-1.3.0-default-dpi.patch + Changes default dpi to 100. + - 139_fedora_xserver-1.3.0-document-fontpath-correctly.patch + Fixes document fontpaths shown in the man page. + - 142_fedora_xserver-1.3.0-no-pseudocolor-composite.patch + Composite on 8bpp pseudocolor root windows appears to fail, so just disable + it on anything pseudocolor for safety. + - 144_fedora_xserver-1.3.0-xnest-exposures.patch: + Only collect xnest exposures for xexposes with non-zero height and width. + + -- Timo Aaltonen Sat, 10 Nov 2007 13:07:55 +0200 + +xorg-server (2:1.4-3) unstable; urgency=low + + [ David Nusinow ] + * Minor cleanups of 03_autoload_drivers.diff. Thanks to Julien for + spotting all these ugly bits + + Newline after #else when picking the driver (this is the failsafe + choice) + + Change by hacked "ids" file name suffix check to use strncmp and check + for ".ids" + + Use strncpy instead of strncat unnecessarily + * Add support for a partially configured device section + Implemented in 03_autoload_driver.diff. Now if you have a device section + but lack a driver, it'll use the settings. This will allow you to just + have a device section and enable EXA but not have to specify the driver or + anything else. + * Add 07_autoconfig_screen_with_device_section.diff + This patch allows the Screen section to not specify a device section. If + this happens, the server will automatically use the first device section + listed in the xorg.conf instead + + [ Brice Goglin ] + * Allow building the Xfbdev server in new package xserver-xfbdev, but leave + it disabled for now (see #439764). + * Add upstream commit 27ad5d74c20f01516a1bff73be283f8982fcf0fe as patch + 44_XKB_mapping_changes_for_all_core-sending_devices.diff to fix broken + xmodmap invocation in .xsession, closes: #443044. + * Add upstream commit 0e800ca4651a947ccef239e6fe7bf64aab92257c as patch + 45_GetKeyboardEvents_reject_out-of-range_keycodes.diff to fix crash + in GetKeyboardValuatorEvents, closes: #443697. + + [ Christian Perrier ] + * Debconf templates and debian/control reviewed by the debian-l10n- + english team as part of the Smith review project. Closes: #442210 + * Debconf translation updates: + - Swedish. Closes: #443047 + - Czech. Closes: #443100 + - French + - Vietnamese. Closes: #443174 + - Italian. Closes: #422414 + * New debconf translations + - Hungarian. Closes: #442956 + - Thai. Closes: #442962 + - Tamil. Closes: #443027 + - Basque. Closes: #443156 + - Hebrew. Closes: #443204 + - Bulgarian. Closes: #443226 + - Finnish. Closes: #443611 + + [ Julien Cristau ] + * Add patch backported from upstream commit + 13949f997289068354e83bc83e50d97b8232efb1 to remove the type1 module: patch + 05_kill_type1.diff replaces 48_disable_type1.diff, and is now enabled in + debian/patches/series. + * Don't build kdrive-based servers we're not shipping. + * Use ${binary:Version} instead of ${Source-Version}. + * Add 08_exa_fix_exaFillRegionTiled_fallback.diff by Michel Dänzer to punt + on fallback case not handled correctly in exaFillRegionTiled (backported + from master's c7d6d1f5); closes: #444203. + * Add 11_exa_no_negative_tile_offsets.diff by Michel Dänzer to make sure + tile offsets passed to drivers are never negative (backported from + master's 006f6525). + * Add 12_bgPixel_fix_64bit_issue.diff by Hong Liu: bgPixel (unsigned long) + is 64-bit on x86_64, so -1 != 0xffffffff (master's 9adea807). + + -- Julien Cristau Sat, 29 Sep 2007 16:14:35 +0200 + +xorg-server (2:1.4-2) unstable; urgency=low + + [ Brice Goglin ] + * Add 42_fix_RemoveGeneralSocket_crash_from_dbus.diff to fix a crash + when leaving, closes: #440547. + * Add 43_allow_override_BIOS_EDID_preferred_mode.diff to allow overriding + BIOD/EDID preferred mode with Option PreferredMode in the config file. + + [ David Nusinow ] + * Upload to unstable + + -- David Nusinow Sun, 16 Sep 2007 14:24:18 -0400 + +xorg-server (2:1.4-1) experimental; urgency=low + + * New upstream release (X.Org 7.3) + + RandR doesn't mark Xinerama as active when no crtcs are enabled + (closes: #431746) + * Add proper depends to xserver-xorg-dev: + x11proto-core-dev, x11proto-input-dev (>= 1.4), x11proto-xext-dev, + x11proto-video-dev, x11proto-randr-dev (>= 1.2), x11proto-render-dev (>= + 2:0.9.3), x11proto-fonts-dev + * Bump serverminver to 2:1.4, videoabiver to 2, inputabiver to 2. + + -- Julien Cristau Mon, 10 Sep 2007 14:35:38 +0200 + +xorg-server (2:1.3.99.2-1) experimental; urgency=low + + [ David Nusinow ] + * Refactor auto_load_driver patch to allow the same method to be used when + there is no xorg.conf present + * Add 04_auto_load_driver_no_config.diff to use my auto_load_driver method + when there's no xorg.conf present + + [ Brice Goglin ] + * Simplify output redirections in the reportbug script, + thanks Justin Pryzby, closes: #358390. + * Add missing URL in long descriptions, update links to the upstream + module, fix some capitalization, thanks Christian Perrier. + + [ Julien Cristau ] + * New upstream release candidate. + + bump build dep on renderproto to >= 0.9.3, and on pixman to >= 0.9.4-2. + + bump video abi version and serverminver. + * Drop the Conflict on fglrx-driver, which is taken care of by the abi + version. + + -- Julien Cristau Tue, 04 Sep 2007 17:32:19 +0200 + +xorg-server (2:1.3.99.0-2) experimental; urgency=low + + * Improve 03_auto_load_driver.diff + + Move memory cleanup and directory closing to after the end label to + prevent leaks. Thanks Julien. + + Allow a driver to claim everything from a specific vendor. It does so by + only specifying a vendor ID and leaving the latter four digits empty. + + -- David Nusinow Sun, 19 Aug 2007 16:06:54 -0400 + +xorg-server (2:1.3.99.0-1) experimental; urgency=low + + [ Julien Cristau, David Nusinow ] + * New upstream release candidate. + + X is now more tolerant of devices without a CtrlProc (closes: #269860). + + cvt(1) and gtf(1) typos fixed (closes: #432065). + + Make sure DRIScreenPrivIndex is -1 when no DRI screen private is + allocated. (closes: #413697). + + __glXDRIscreenProbe: Use drmOpen/CloseOnce (closes: #419614). + + segfault in swrast_Triangle fixed in mesa (closes: #407502). + + the Xvfb manpage doesn't refer to /usr/tmp anymore (closes: #270257). + + typos in Xserver(1) fixed (closes: #306688). + + * Remove patches that were pushed upstream + + 03_xnest_manpage_overhaul.diff + + 04_read_rom_in_chunks.diff + + 05_module_defaults.diff + + 07_stolen_from_HEAD_xorgconf_manpage.diff + + 08_s390_servermd.diff + + 12_security_policy_in_etc.diff + + 16_s390_fix.diff + + 18_execinfo_configured.patch + + 23_kfreebsd_support.diff + + 24_hurd_ioperm_fix.diff + + 32_disable_sparc_pci_bridge.diff + + 39_alpha_build_flags.patch + + 40_consolidate_portPriv_pDraw_assignments.diff + + 42_only_run_special_key_behaviours_on_non-XKB.diff + + 44_fedora-xephyr-keysym-madness.diff (different fix applied upstream) + + 45_CVE-2007-2437.diff + + 46_export-ramdac-symbols.diff + + 49_map_keyboard_driver_to_kbd.diff + + 50_alpha_no_include_asm_pci.h.diff + + 94_use_default_font_path.diff + + 125_glx_remove-stray__GLinterface.diff, + 126_glxproxy_remove-stray__GLinterface.diff and + 127_mesa-6.5.3-compat.diff (obsolete) + + * Update other patches: + + 09_debian_xserver_rtff.diff disabled (doesn't apply, and isn't even + used AFAICS; + + 11_define_XFree86Server.diff dropped, to be fixed in drivers instead; + + 13_debian_add_xkbpath_env_variable.diff refreshed; + + 21_glx_align_fixes.patch updated; + + 43_xephyr_crash_at_exit.diff dropped (doesn't apply); + + 47_fbdevhw_magic_numbers.diff disabled for now; + + 48_disable_type1.diff disabled for now; + + 51_xkb-and-loathing.diff disabled for now. + + [ Julien Cristau ] + * Add build-dep on x11proto-input-dev (>= 1.4.2), libpixman-1-dev + (>= 0.9.0), libdbus-1-dev, libhal-dev (except on hurd-i386 for the last + two). + * Bump build-dep on mesa-swx11-source to >> 7.0.1~rc2-1. + * Bump serverminver to this version, videoabiver to 1.9, inputabiver to + 0.9 (so this doesn't clash with a release and drivers have to be + rebuilt). + * Bump build-dep on compositeproto to >= 0.4. + * Install the upstream changelog. + * Disable the xprint and dmx DDX for now, they fail to build. + * xserver-xorg-dev needs a dependency on libpixman-1-dev. + * Add explanations about our tarball and upstream URL to debian/copyright. + + [ Drew Parsons ] + * Update Xprint build to include pixman. + + [ David Nusinow ] + * Add 03_auto_load_driver.diff. This patch allows the server to select a + driver and automatically create a Devices section when none is specified + in your xorg.conf. It chooses the driver based on a set of PCI ID's that + the driver itself provides in /usr/share/xserver-xorg/pci. If no driver + claims the PCI ID of your primary video card, then it will choose a + fallback based on your system. + + -- Julien Cristau Sat, 18 Aug 2007 18:28:49 +0200 + +xorg-server (2:1.3.0.0.dfsg-13) UNRELEASED; urgency=low + + [ Debconf templates translations ] + * Italian added. Closes: #422414 + * Slovak added. Closes: #438578 + + -- Christian Perrier Sun, 26 Aug 2007 12:09:52 +0200 + +xorg-server (2:1.3.0.0.dfsg-12ubuntu8) gutsy; urgency=low + + * Add 145_glx_visuals_bound_check.patch to fix issue where mesa + incorrectly counts its visuals and can free too many of them during + video mode changes (VT switch, restart, hibernate, etc.) such as + when running Compiz. (closes LP: #127101) + + -- Bryce Harrington Fri, 28 Sep 2007 15:48:08 -0700 + +xorg-server (2:1.3.0.0.dfsg-12ubuntu7) gutsy; urgency=low + + * Drop 143_fedora_xserver-1.3.0-randr12-config-hack.patch + as it causes failure to detect proper resolution on some intel + hardware. (closes LP: #144956) + + -- Bryce Harrington Tue, 25 Sep 2007 14:42:59 -0700 + +xorg-server (2:1.3.0.0.dfsg-12ubuntu6) gutsy; urgency=low + + * Drop 214_Bug_9680-_Remove_bogus_blank_length_limiting_in_xf86SetModeCrtc.patch + as it is causing black bars to appear on screen for i810 users. + (closes LP: #137604 + several dupes) + + -- Bryce Harrington Thu, 20 Sep 2007 14:35:54 -0700 + +xorg-server (2:1.3.0.0.dfsg-12ubuntu5) gutsy; urgency=low + + [ Kees Cook ] + * debian/patches/132_composite-no-clipping.diff: Adjusted WindowRec + structure order and RedirectDraw logic to avoid nvidia crashes + (fixes LP: #130325). + * debian/patches/100_security_fdo-bug-7447.diff: Composite used for + pixmap population on redirect. [CVE-2007-4730] + + -- Bryce Harrington Tue, 18 Sep 2007 17:20:14 -0700 + +xorg-server (2:1.3.0.0.dfsg-12ubuntu4) gutsy; urgency=low + + * debian/patches/133_psb_auto.patch: Add automatic detection of + Poulsbo hardware when running without a Device definition. + * Added some cherry-picked patches from fedora: + - 134_fedorda_xorg-x11-server-1.1.1-vt-activate-is-a-terrible-api.patch: + Fixes race condition where someone does a VT_ACTIVATE + between another ACTIVATE/WAITACTIVE by adding a fail. + (Potentially might address Ubuntu bugs 134478 and/or 134982) + - 135_fedora_xorg-x11-server-1.1.1-xkb-in-xnest.patch: Fixes issue when + starting a session in an xnest nest environment as a different user, + where keyboard map does not get preserved. Removes + NO_HW_ONLY_EXTS check to address this issue. (RedHat bug 193431; + Potentially may address Ubuntu bug 44846) + - 136_fedora_xserver-1.2.0-honor-displaysize.patch: Fixes issue if monitor + width and height have been specified, xserver would override them + with the hsize/vsize detected from DDC. + - 137_fedora_xserver-1.2.0-vfprintf.patch: Fixes typo 'vfprinf' + - 138_fedora_xserver-1.3.0-default-dpi.patch: Changes default dpi to 100. + (Addresses Ubuntu bugs 118745, 107320, many others...) + - 139_fedora_xserver-1.3.0-document-fontpath-correctly.patch: Fixes + document fontpaths shown in the man page. + - 140_fedora_xserver-1.3.0-domain-obiwan.patch: Fixes longstanding bug in + domain support. + - 141_fedora_xserver-1.3.0-edid-quirk-backports.patch: Adds quirk for + Samsung SyncMaster 225BW. + - 142_fedora_xserver-1.3.0-no-pseudocolor-composite.patch: Composite on + 8bpp pseudocolor root windows appears to fail, so just disable it + on anything pseudocolor for safety. + - 143_fedora_xserver-1.3.0-randr12-config-hack.patch: Adds check to use + the screen's xrandr modes if a preferred mode was not specified. + - 144_fedora_xserver-1.3.0-xnest-exposures.patch: Only collect xnest + exposures for xexposes with non-zero height and width. + + -- Bryce Harrington Fri, 7 Sep 2007 14:23:23 -0700 + +xorg-server (2:1.3.0.0.dfsg-12ubuntu3) gutsy; urgency=low + + * Added some cherry-picked patches from xserver 1.3.99: + - 202_Add_quirk_for_Acer_AL1706_monitor_to_force_60hz_refresh.patch: + The Acer AL1706 monitor reports support for 75hz via EDID, but + does not sync when this range is given, so force it to 60hz. + - 205_Bug_10770-_Inputdevs_isnt_a_valid_config_file_keyword.patch: + Fixes typo in config file parser. + - 208_Bug_6620-_Fixed_a_missing_else_in_ATIPseudoDMAInit.patch: + Fixes issue where registers were written twice on R200, sometimes + also putting bad values in atis->cce_pri_size. + - 214_Bug_9680-_Remove_bogus_blank_length_limiting_in_xf86SetModeCrtc.patch: + Fixes situation where when a specific mode is requested by monitor + or user, xorg would tweak it to something incorrect. + - 216_Bug_9041-_Check_the_return_code_in_xf86MapDomainMemory.patch: + Fixes issue where mmap return value was being ignored and failing + to issue fatal error as it should. + - 221_ExaOffscreenMarkUsed-_Dont_crash_when_theres_no_offscreen_memory.patch: + Fixes crash when there is no offscreen memory for EXA. + - 222_Fix_a_crash_when_rotating_the_screen.patch: + Fixes crash when rotating screen with xrandr. + - 223_Fix_bug_8871-scrolling_corruption_with_a_compositing_manager.patch: + Fixes scrolling corruption with composite due to incorrectly + generated GraphicsExposes. + - 224_Fix_calculations_in_x86_emulator_for_the_long_long_case_Andreas_Schwab.patch: + Fixes long long multiplication when in x86 emulator. + - 227_Fix_sync_polarity_on_Samsung_SyncMaster_205BW_monitor.patch: + Adds quirk for Samsung SyncMaster 205BW + - 230_In___glXCreateARGBConfig_insert_the_new_GL_mode_at_the__end__of_the_linked_list.patch: + Fixes insertion order of linked list that can cause GLX clients to + fail when attempting to use the last GLX mode/visual. + - 231_In_dmxBackendMouGetInfo_initialize_the_info-minval_maxval_arrays_to_the_size_of_the_backend_display.patch: + Fixes potential issue in X input where axis clipping code in + GetPointerEvents() constrains the pointer's coordinate range to a + max of 0, causing the mouse to not move. + - 234_Reapply_patch_to_fix_AMD_CPU_detection.patch: + Fixes AMD Geode CPU detection. + - 236_Syncmaster_226_monitor_needs_60Hz_refresh_10545.patch: + Adds quirk for Samsung SyncMaster 226BW. + - 238_Update_pci.ids_to_2007-07-16_snapshot.patch: + Updates our pci ids to support more current hardware. + Remove nvidia ids in extrapci.ids that are now in pci.ids. + Add nvidia ids to extrapci.ids that are in xf86-video-nv but not pci.ids + - 241_XFree86-_Treat_evdev_and_vmmouse_as_mouse_drivers_bug_10512_10559.patch: + Fix issue where a default mouse device gets automatically added + when an evdev or vmmouse section has already been specified. + - 243_exaDriverInit-_Fail_if_pScreenInfo_or_a_member_of_it_is_invalid.patch: + Fix crash in EXA when pScreenInfo or a member of it is invalid. + - 244_fix_an_occasional_crash_in_GetWindowName_bug-_9798.patch: + Fixes crash by adding check of XmbTextPropertyToTextList()'s + return code. + - 245_regenerated_to_fix_bug_10371.patch: + Fixes issue where if DRI is disabled, GL_MAX_TEXTURE_COORDS_ARB + value is not returned correctly from glGetIntegerv(). + + -- Bryce Harrington Fri, 31 Aug 2007 18:36:22 -0700 + +xorg-server (2:1.3.0.0.dfsg-12ubuntu2) gutsy; urgency=low + + * Don't send a configuration change event just because somebody's pressed + a brightness key + + -- Matthew Garrett Sun, 26 Aug 2007 16:17:15 +0100 + +xorg-server (2:1.3.0.0.dfsg-12ubuntu1) gutsy; urgency=low + + * Merge from debian unstable, remaining changes: + - debian/control: + + set Conflicts: xkb-data (<< 0.9), since xkb-path is + different from previous releases + + do not Conflict with xserver-xorg-video + + xvfb Depends on xauth, xfonts-base + + Set Maintainer to Ubuntu Core Developers + - debian/rules: + + --with-os-vendor=Ubuntu + - debian/xserver-xorg-core.install: + + Add ioport, pcitweak, scanpci scripts & man pages + - debian/patches: + + 102_ubuntu_sharevts_load_cpu.patch: + close console fd only when ShareVTs + + 104_fedora_init_origins_fix.patch: + multihead initialization + + 106_ubuntu_fpic_libxf86config.patch: + Add -fPIC to makefiles for xfree86/parser + + 107_fedora_dont_backfill_bg_none.patch + 110_fedora_no_move_damage.patch, + 114_fedora_no_composite_in_xnest.patch, + 120_fedora_disable_offscreen_pixmaps.patch: + further aiglx support + + 119_ubuntu_enable_composite.diff: + enable composite + + 121_only_switch_vt_when_active.diff: + Add a check to prevent the X server from changing the VT when killing + GDM from the console. + + 123_no_composite_for_xvfb_run.patch: + use "-extension Composite" to fix xvfb-run crashing + + 125_glx_remove-stray__GLinterface.diff, + 126_glxproxy_remove-stray__GLinterface.diff, + 127_mesa-6.5.3-compat.diff: + Patches needed to build against newer Mesa. + + 132_composite-no-clipping.diff: + Change the semantics of manual-redirect Composite windows so that + they do not clip sibling or parent drawing. Needed by hildon-desktop + to prevent home applets from clipping. + - debian/apport.py: Add apport hook for automatically attaching + files useful for debugging X crashes: Xorg.0.log, xorg.conf, + lsmod, lspci, and /proc/version + + -- Timo Aaltonen Tue, 21 Aug 2007 22:01:38 +0300 + +xorg-server (2:1.3.0.0.dfsg-12) unstable; urgency=low + + [ Brice Goglin ] + * Add 51_xkb-and-loathing.diff to fix a hang in OpenOffice.org + when opening menus, closes: #433131. + * Install the exa(4) and fbdevhw(4) manpages. + + [ Julien Cristau ] + * Update the xorg.conf(5) manpage to get documentation for RandR 1.2 + options: + + 07_stolen_from_HEAD_xorgconf_manpage.diff: new patch; + + 07_xorgconf_manpage_overhaul.diff dropped; + + 34_xorg.conf_man_typos.patch dropped; + + 05_module_defaults.diff, 94_use_default_font_path.diff: dropped hunks + applying to hw/xfree86/doc/man/xorg.conf.man.pre. + * Add patch 11_define_XFree86Server.diff: XFree86Server needs to be defined + in xorg-server.h and exported to drivers. + * Add patches 125_glx_remove-stray__GLinterface.diff + 126_glxproxy_remove-stray__GLinterface.diff and 127_mesa-6.5.3-compat.diff + to build with mesa >= 6.5.3, and bump build-dependency on + mesa-swx11-source. + * Include the Debian package version in OSVENDOR to make it appear in the + X log. + + -- Julien Cristau Thu, 09 Aug 2007 16:32:14 +0200 + +xorg-server (2:1.3.0.0.dfsg-11) unstable; urgency=low + + * Yet another alpha build fix: also remove the asm/pci.h include from + os-support/linux/lnx_axp.c. Include "lnx.h" and instead. + + -- Julien Cristau Sat, 14 Jul 2007 20:09:35 +0200 + +xorg-server (2:1.3.0.0.dfsg-10) unstable; urgency=medium + + * hw/xfree86/common/compiler.h and declare incompatible + prototypes for outb and friends, so change the patch from -9 to not + #include and rely on declarations in lnx.h itself for the + IOBASE_* macros. + + -- Julien Cristau Sat, 14 Jul 2007 18:06:14 +0200 + +xorg-server (2:1.3.0.0.dfsg-9) unstable; urgency=medium + + * Include instead of in + hw/xfree86/os-support/linux/lnx.h, as the latter isn't exported to + userspace anymore; fixes FTBFS on alpha. Thanks, Steve Langasek! + + -- Julien Cristau Sat, 14 Jul 2007 12:17:10 +0200 + +xorg-server (2:1.3.0.0.dfsg-8) unstable; urgency=medium + + * Medium-urgency upload to get the fix for #428794 in testing faster, + hopefully. + + [ Brice Goglin ] + * Add 47_fbdevhw_magic_numbers.diff: patch by Adam Jackson to keep the + fbdev2xfree_timing() function from changing the pixel clock value if the + fbdev driver claims that it is 0. + + [ Julien Cristau ] + * Don't build the type1 font module. + * Add patch by Alan Coopersmith to map (case-insensitively) the old + "keyboard" input driver to "kbd" (addresses: #428794). I'm not + reassigning the bug to xserver-xorg-core for now so as not to break + testing by letting xserver-xorg-input-keyboard transition before the fixed + xorg-server. + + -- Julien Cristau Sat, 14 Jul 2007 01:48:20 +0200 + +xorg-server (2:1.3.0.0.dfsg-7) unstable; urgency=low + + [ Brice Goglin ] + * Add 40_consolidate_portPriv_pDraw_assignments.diff to avoid a crash + in xf86XVReputVideo (closes: #424899, #431655). + * Add 41_vbe_filter_less.diff to not reject VESA modes early since + xf86ValidateModes should handle them just fine (closes: #424684). + * Add 42_only_run_special_key_behaviours_on_non-XKB.diff to fix special + keys in Xephyr (closes: #415025). + * Add 43_xephyr_crash_at_exit.diff to avoid crashing Xephyr when first + client disconnect (closes: #420421). + + -- Julien Cristau Wed, 04 Jul 2007 23:42:40 +0200 + +xorg-server (2:1.3.0.0.dfsg-6ubuntu3) gutsy; urgency=low + + * debian/patches/series: + - Re-enable 132_composite-no-clipping.diff with fix from upstream + + -- Bryce Harrington Wed, 25 Jul 2007 16:39:29 -0700 + +xorg-server (2:1.3.0.0.dfsg-6ubuntu2) gutsy; urgency=low + + * debian/patches/series: + - don't apply 132_composite-no-clipping.diff for now, it doesn't work + correctly when using compiz + + -- Sebastien Bacher Fri, 13 Jul 2007 17:03:42 +0100 + +xorg-server (2:1.3.0.0.dfsg-6ubuntu1) gutsy; urgency=low + + * Merge from Debian unstable. Remaining Ubuntu changes: + - debian/control: + + set Conflicts: xkb-data (<< 0.9), since xkb-path is + different from previous releases + + do not Conflict with xserver-xorg-video + + xvfb Depends on xauth, xfonts-base + + Set Maintainer to Ubuntu Core Developers + - debian/rules: + + build using -fno-stack-protector + + --with-os-vendor=Ubuntu + - debian/xserver-xorg-core.install: + + Add ioport, pcitweak, scanpci scripts & man pages + - debian/patches: + + 102_ubuntu_sharevts_load_cpu.patch: + close console fd only when ShareVTs + + 104_fedora_init_origins_fix.patch: + multihead initialization + + 106_ubuntu_fpic_libxf86config.patch: + Add -fPIC to makefiles for xfree86/parser + + 107_fedora_dont_backfill_bg_none.patch: + Re-enable to see if it helps with performance regressions. + + 108_fedora_gl_include_inferiors.patch, + 110_fedora_no_move_damage.patch, + 114_fedora_no_composite_in_xnest.patch: + further aiglx support + + 119_ubuntu_enable_composite.diff: + enable composite + + 120_fedora_disable_offscreen_pixmaps.patch: + update to the latest version from Fedora (rev. 1.6, was 1.1) + Despite being a hack, it works and is needed for compositing + managers to work properly. + + 121_only_switch_vt_when_active.diff: + Add a check to prevent the X server from changing the VT when killing + GDM from the console. + + 123_no_composite_for_xvfb_run.patch: + use "-extension Composite" to fix xvfb-run crashing + - 125_glx_remove-stray__GLinterface.diff, + 126_glxproxy_remove-stray__GLinterface.diff, + 127_mesa-6.5.3-compat.diff: + Mesa 6.5.3 build support + * debian/apport.py: Add apport hook for automatically attaching + files useful for debugging X crashes: Xorg.0.log, xorg.conf, + lsmod, lspci, and /proc/version + * debian/patches/132_composite-no-clipping.diff: Change the + semantics of manual-redirect Composite windows so that they do not + clip sibling or parent drawing. Needed by hildon-desktop to prevent + home applets from clipping. + + -- Bryce Harrington Mon, 2 Jul 2007 12:47:44 -0700 + +xorg-server (2:1.3.0.0.dfsg-6) unstable; urgency=low + + * Change fglrx conflict to << 8.37.6 (closes: #424975). + + -- Julien Cristau Fri, 01 Jun 2007 14:58:39 +0200 + +xorg-server (2:1.3.0.0.dfsg-5) unstable; urgency=low + + [ Brice Goglin ] + * Add 24_hurd_ioperm_fix.diff to fix xf86Enable/DisableIO on Hurd with + recent GNU Mach. Thanks Samuel Thibault! + * Add 06_use_proc_instead_of_sysfs_for_pci_domains.diff since sysfs-based + PCI management code is broken at least on sparc and powerpc. + Closes: #422077, #422095. Thanks to Jim Watson for testing! + * Install the Xephyr README, closes: #395888. + * Update 07_xorgconf_manpage_overhaul.diff to drop the reference to the + xorg.conf example which we do not install since Xserver 1.3 does automatic + configuration, the manpage is very well documented, and we generate a + config file during installation. Closes: #222932. + * Fix warning in /etc/init.d/xprint when /usr/lib/X11/fonts does not exist. + Closes: #422352. Thanks Cristian Ionescu-Idbohrn! + * Pull upstream commit 9c80eda826448822328bb678a7d284cc43fffb17 to disable + RandR's fake xinerama geometry when there's more than one protocol screen + (closes: #420679). + + [ Julien Cristau ] + * Add patch to make sure that the ramdac symbols are present in the server + and drivers can use them (closes: #423129). + * xserver-xorg-core Conflicts with fglrx-driver, which broke with 1.3. + We'll need to make this versioned (or drop it) when fglrx is fixed. + + -- Julien Cristau Wed, 16 May 2007 15:17:55 +0200 + +xorg-server (2:1.3.0.0.dfsg-4ubuntu2) gutsy; urgency=low + + * Build-Depend on mesa 6.5.3 + * Apply Mandriva patches to build against mesa 6.5.3 + - 125_glx_remove-stray__GLinterface.diff + - 126_glxproxy_remove-stray__GLinterface.diff + - 127_mesa-6.5.3-compat.diff + + -- Kyle McMartin Sat, 26 May 2007 18:12:35 +0000 + +xorg-server (2:1.3.0.0.dfsg-4ubuntu1) gutsy; urgency=low + + * Merge from Debian unstable. Remaining Ubuntu changes: + - debian/control: + + set Conflicts: xkb-data (<< 0.9), since xkb-path is + different from previous releases + + do not Conflict with xserver-xorg-video + + xvfb Depends on xauth, xfonts-base + + Set Maintainer to Ubuntu Core Developers + - debian/rules: + + build using -fno-stack-protector + + --with-os-vendor=Ubuntu + - debian/xserver-xorg-core.install: + + Add ioport, pcitweak, scanpci scripts & man pages + - debian/patches: + + 102_ubuntu_sharevts_load_cpu.patch: + close console fd only when ShareVTs + + 104_fedora_init_origins_fix.patch: + multihead initialization + + 106_ubuntu_fpic_libxf86config.patch: + Add -fPIC to makefiles for xfree86/parser + + 107_fedora_dont_backfill_bg_none.patch: + Re-enable to see if it helps with performance regressions. + + 108_fedora_gl_include_inferiors.patch, + 110_fedora_no_move_damage.patch, + 114_fedora_no_composite_in_xnest.patch: + further aiglx support + + 119_ubuntu_enable_composite.diff: + enable composite + + 120_fedora_disable_offscreen_pixmaps.patch: + update to the latest version from Fedora (rev. 1.6, was 1.1) + Despite being a hack, it works and is needed for compositing + managers to work properly. + + 121_only_switch_vt_when_active.diff: + Add a check to prevent the X server from changing the VT when killing + GDM from the console. + + 123_no_composite_for_xvfb_run.patch: + use "-extension Composite" to fix xvfb-run crashing + * Drop 124_fix-pdripriv_null_deref.patch. Already fixed in GLX code. + See upstream FDO bug #8537 + + -- Bryce Harrington Mon, 14 May 2007 16:40:03 -0700 + +xorg-server (2:1.3.0.0.dfsg-4) unstable; urgency=low + + * Cherry-pick patch from upstream git to fix security issue in the Xrender + extension: malicious clients can cause a division by zero in the server + (closes: #422936). Reference: CVE-2007-2437. Thanks, Micah Anderson! + + -- Julien Cristau Wed, 09 May 2007 02:11:08 +0200 + +xorg-server (2:1.3.0.0.dfsg-3) unstable; urgency=low + + * Include 94_use_default_font_path.diff. This patch is like Eugene's patch + to always look in the default font path from the past, but now we provide + an option to disable looking in the default font path at runtime. This + will allow people to specify additional font paths in their xorg.conf + without losing their current paths. This will also help avoid people + having ye olde "fixed font" problem. + * Fix compilation warnings for 05_module_defaults.diff. Previously the patch + used a generic pointer for the options record, but now we use the actual + XF86OptionsPtr type. + + -- David Nusinow Thu, 26 Apr 2007 22:39:52 -0400 + +xorg-server (2:1.3.0.0.dfsg-2) unstable; urgency=low + + * Add Brice Goglin's fix for 05_module_defaults.diff, so that it also works + when there is no module section at all. Thanks to Michel Dänzer for + helping also. + + -- David Nusinow Sat, 21 Apr 2007 09:34:12 -0400 + +xorg-server (2:1.3.0.0.dfsg-1) unstable; urgency=low + + * Upload to unstable. + * Add XS-Vcs-* to debian/control. + * Remove non-free file hw/xfree86/doc/README.DRI from the upstream tarball. + * Bump serverminver to 2:1.3.0.0. + + -- Julien Cristau Fri, 20 Apr 2007 07:54:14 +0200 + +xorg-server (2:1.3.0.0-1) experimental; urgency=low + + * New upstream release + + -- David Nusinow Thu, 19 Apr 2007 22:27:05 -0400 + +xorg-server (2:1.2.99.905-3) experimental; urgency=low + + [ Julien Cristau ] + * xvfb now Recommends: xfonts-base (closes: #314598). + + [ David Nusinow ] + * Add 05_module_defaults.diff. This provides default modules loading + capabilities for the server that may be overrided easily. Previously the + server would load a set of default modules, but only if none were + specified in the xorg.conf, or if you didn't have a xorg.conf at all. This + patch provides a default set and you can add only the "Load" instructions + to xorg.conf that you want without losing the defaults. Similarly, if you + don't want to load a module that's loaded by default, you can add + "Disable modulename" to your xorg.conf (see man xorg.conf in this release + for details). See upstream bug #10541 for more. + + -- David Nusinow Sun, 15 Apr 2007 11:17:45 -0400 + +xorg-server (2:1.2.99.905-2) experimental; urgency=low + + * Install the cvt and gtf utilities and their manpages (closes: #414792). + * Build the xserver-xorg-core-dbg package, which contains debugging symbols + for Xorg and /usr/lib/xorg/modules/**/*.so + + -- Julien Cristau Mon, 09 Apr 2007 20:38:22 +0200 + +xorg-server (2:1.2.99.905-1) experimental; urgency=low + + * New upstream release candidate. + + includes fix for CVE-2007-1003: XC-MISC Extension ProcXCMiscGetXIDList() + Memory Corruption. + + -- Julien Cristau Fri, 06 Apr 2007 12:05:40 +0200 + +xorg-server (2:1.2.99.903-1) experimental; urgency=low + + [ Drew Parsons ] + * Add exclude entries to dh_install in debian/rules. + + [ Julien Cristau ] + * Prepare packaging to ship debugging symbols for xserver-xorg-core in + xserver-xorg-core-dbg, but leave it commented out so we can get rc3 in the + archive first. + * New upstream release candidate. + + bump serverminver to 2:1.2.99.903. + + -- Julien Cristau Tue, 27 Mar 2007 07:33:29 +0200 + +xorg-server (2:1.2.99.902-1) experimental; urgency=low + + [ Drew Parsons ] + * Bring xprint back into the xorg fold. + - include existing patches: + - 91_ttf2pt1 allows Xprint to use ttf2pt1 for Type1 font handling + (but extract and apply manually the patch to + hw/xprint/ps/Makefile.am so it may be applied by autoconf) + - 91_ttf2pt1_updates brings ttf2pt1 into the modern X11R7.1 world + - 92_xprint-security-holes-fix.patch places PS/PDF file output + into the user's home directory (~/Xprintjobs), more secure than + a shared /tmp/Xprintjobs + - 93_spooltodir_check_file_exists ensures output filenames are + less than 256 characters in length + - 93_xprint_fonts_fix released references to font names after use. + - enable freetype support for Xprint. + - add descriptions to debian/control and Build-Dependency on + x11proto-print-dev + * Run autoreconf to update changes to hw/xprint/ps/Makefile.am. + + [ Brice Goglin ] + * Apply patch from adrian@smop.co.uk to our xvfb-run wrapper + to check whether Xvfb started ok and fix its cleanup + (closes: #351042). + + [ Julien Cristau ] + * New upstream release candidate. + * Bump serverminver to 2:1.2.99.902. + * Drop patch 42_build_int10_submodules.diff, and use x86emu on all + architectures instead (closes: #410879). + * Refresh patches: + + 12_security_policy_in_etc.diff + + 21_glx_align_fixes.patch + + 23_kfreebsd_support.diff + * Delete a few files generated by configure on clean, since they seem to + have been included in the tarball. + + -- Julien Cristau Thu, 15 Mar 2007 04:28:00 +0100 + +xorg-server (2:1.2.99.901-1) experimental; urgency=low + + * New upstream release candidate. + + Remove patches 24 (hurd support), 35 (randr byteswap) and 43 (set damage + version), applied upstream. + + Bump build-dep on x11proto-randr-dev to >= 1.2, and on + x11proto-damage-dev to >= 1.1. + + -- Julien Cristau Wed, 7 Mar 2007 19:58:53 +0100 + +xorg-server (2:1.2.0-6) experimental; urgency=low + + * Set videoabiver to 1.0, same as in xorg-server 1.1. + + -- Julien Cristau Fri, 2 Mar 2007 16:38:12 +0100 + +xorg-server (2:1.2.0-5) experimental; urgency=low + + * Add input ABI versioning metadata. Rename serverabiver file to + videoabiver, and add inputabiver. Bump serverminver to 2:1.2.0-5 to deal + with this change. + + -- David Nusinow Thu, 1 Mar 2007 22:09:45 -0500 + +xorg-server (2:1.2.0-4) experimental; urgency=low + + [ Julien Cristau ] + * Don't strip modules when DEB_BUILD_OPTIONS contains nostrip. Thanks, + Cyril Brulebois! + + [ David Nusinow ] + * Move serverabiver file to serverminver. Use serverabiver to store the + actual video ABI version number (1.1 right now). This will allow drivers + to automatically generate their Provides: xserver-xorg-video-* line when + built against a particular server version. The rename of the files + is to better denote what they actually are. + * Bump the serverminver to 2:1.2.0-4 because of this change + + -- David Nusinow Wed, 21 Feb 2007 21:53:51 -0500 + +xorg-server (2:1.2.0-3ubuntu8) feisty; urgency=low + + * SECURITY UPDATE: arbitrary code execution with root privs via integer + overflows in MISC-XC. + * Add debian/patches/131_misc_xc_overflows.patch: upstream fixes. + * References + CVE-2007-1003 + + -- Kees Cook Thu, 29 Mar 2007 17:46:44 -0700 + +xorg-server (2:1.2.0-3ubuntu7) feisty; urgency=low + + * debian/patches/120_fedora_disable_offscreen_pixmaps.patch + - update to the latest version from Fedora (rev. 1.6, was 1.1) + + -- Timo Aaltonen Fri, 30 Mar 2007 10:39:01 +0300 + +xorg-server (2:1.2.0-3ubuntu6) feisty; urgency=low + + * debian/{rules,xsfbs/xsfbs.mk,serverminver,inputabiver} + - Import changes from current debian package, needed for the new intel + driver. + - Rename serverabiver to videoabiver, value 1.0. + - Set serverminver as this version. + * debian/patches: + 129_remove_extra_i2c_bittimeout.patch + 130_slow_down_ddc_i2c.patch + - Patches from server-1.3 branch, which make probing the monitor more + robust. + + -- Timo Aaltonen Thu, 29 Mar 2007 00:56:17 +0300 + +xorg-server (2:1.2.0-3ubuntu5) feisty; urgency=low + + * debian/patches/120_fedora_disable_offscreen_pixmaps.diff + - Re-enable. Despite being a hack, it works and is needed for compositing + managers to work properly. (LP: #89189) + + -- Timo Aaltonen Tue, 27 Mar 2007 02:33:31 +0300 + +xorg-server (2:1.2.0-3ubuntu4) feisty; urgency=low + + * debian/patches/107_fedora_dont_backfill_bg_none.patch: + - Re-enable to see if it helps with performance regressions. + * debian/patches/127_check_for_clientgone.patch: + - A fix from upstream. (LP: #60288) + * debian/patches/128_fix_client_privates_leak.patch + - Plug a memory leak. (LP: #92882) + * debian/rules + - Fix a typo in --with-default-font-path. + + -- Timo Aaltonen Sat, 17 Mar 2007 00:38:09 +0200 + +xorg-server (2:1.2.0-3ubuntu3) feisty; urgency=low + + * debian/patches: + - Rename 019_ubuntu_enable_composite.diff to 119_* so that it is in line + with the rest of our patches + - Re-add 126_debian_always_use_default_font_path.diff. This was dropped + by Debian but needed by us since we still have legacy fontpaths in + old configurations, so new paths need to be appended to the list. + + -- Timo Aaltonen Wed, 28 Feb 2007 11:54:18 +0200 + +xorg-server (2:1.2.0-3ubuntu2) feisty; urgency=low + + * debian/control: + - xvfb Depends on xauth, xfonts-base + + -- Sebastien Bacher Tue, 27 Feb 2007 23:31:06 +0100 + +xorg-server (2:1.2.0-3ubuntu1) feisty; urgency=low + + * Don't drop 42_build_int10_submodules.diff, it's useful + * 019_ubuntu_enable_composite.diff: + - enable composite + * debian/control: + - fixed Maintainer email + * debian/xserver-xorg-core.install: + - list ioport, gtf, pcitweak and scanpci + and manpages for scanpci, gtf, pcitweak + + [ Timo Aaltonen ] + * Merge with Debian, remaining changes: + - debian/rules: + + build using -fno-stack-protector + + --with-os-vendor=Ubuntu + - debian/control: + + don't Conflict with xserver-xorg-video + - refreshed and renamed patches + 102_ubuntu_sharevts_load_cpu.patch + 104_fedora_init_origins_fix.patch + 106_ubuntu_fpic_libxf86config.patch + 114_fedora_no_composite_in_xnest.patch + 121_only_switch_vt_when_active.diff + 124_fix-pdripriv_null_deref.patch + - dropped for now: + 42_build_int10_submodules.diff - causes "some regression" + * dropped patches (comments from Michel Daenzer): + - 107_fedora_dont_backfill_bg_none.patch + "Breaks X semantics and thus can't go in upstream. Apps/toolkits + need to be fixed not to use background none windows." + - 108_fedora_gl_include_inferiors.patch + "Breaks GLX semantics and should no longer be necessary now that + the GLX compositing managers default to using the Composite + Overlay Window." + - 120_fedora_disable_offscreen_pixmaps.diff + "Last time I looked at this, it was a gross hack to work around XAA + deficiencies in offscreen pixmap handling, which makes the server + die immediately when trying to use GLX_EXT_texture_from_pixmap + with EXA, due to calling XAA functions without checking it's + active or even loaded." + * debian/control: + - set Conflicts: xkb-data (<< 0.9), since xkb-path is + different from previous releases + * debian/patches/125_randr-version-supported.diff: + - The server supports protocol 1.1, make sure we use it. + + -- Sebastien Bacher Mon, 26 Feb 2007 09:36:38 +0100 + +xorg-server (2:1.2.0-3) experimental; urgency=low + + [ Julien Cristau ] + * Pass --with-os-name and --with-os-vendor to configure. + * Bump serverabiver to 2:1.2.0-1. + * Add patch from upstream git to set the supported damage version from the + server, instead of from the damage headers. xserver 1.2.0 supports damage + 1.0, not 1.1. + + -- Julien Cristau Sat, 17 Feb 2007 12:03:03 +0100 + +xorg-server (2:1.2.0-2) experimental; urgency=low + + * Delete useless debian/substvars. + * Change my email address in debian/control. + * Fix patch 42_build_int10_submodules.diff. The definition of + xf86InitInt10() was moved to int10/helper_exec.c between 1.1.1 and 1.2.0, + so we move it to int10/helper_mem.c, which we build in the main int10 + module, not the vm86 and x86emu submodules. Thanks to Cédric Augonnet and + Brice Goglin for the report and testing. + + -- Julien Cristau Sat, 10 Feb 2007 20:57:57 +0100 + +xorg-server (2:1.2.0-1) experimental; urgency=low + + * New upstream release. + + 40_xorg-xserver-1.1.0-dbe-render.diff dropped. + + 38_GetDrawableAttributes.patch dropped. + + 37_build-mesa-mipmap.patch dropped. + + 33_Xserver_man_typos.patch dropped. + + 24_hurd_support.diff massively reduced. + + 13_debian_add_xkbpath_env_variable.diff refreshed. + + 07_xorgconf_manpage_overhaul.diff updated. + + 42_build_int10_submodules.diff updated. + * Bump build-dep on mesa-swx11-source to >= 6.5.2. + * Version build-dependencies on x11proto-composite-dev and x11proto-kb-dev + to match configure.ac. + * Add build-dep on libxfixes-dev (needed for Xdmx). + + -- Julien Cristau Fri, 9 Feb 2007 20:54:27 +0100 + +xorg-server (2:1.1.99.903-1) experimental; urgency=low + + * New upstream release candidate. + * Forward-port patches: + * 07_xorgconf_manpage_overhaul.diff: refresh + * 12_security_policy_in_etc.diff: refresh + * 21_glx_align_fixes.patch: refresh + * 23_kfreebsd_support.diff: refresh + * 24_hurd_support.diff: refresh + * 34_xorg.conf_man_typos.patch: refresh + * 36_fix_ffs.patch: remove, applied upstream + * Bump build-dependency on libdrm-dev to (>= 2.3.0) because that is the X + server's minimum requirement. + + -- Thierry Reding Sat, 2 Dec 2006 12:44:59 +0100 + +xorg-server (2:1.1.99.902-1) experimental; urgency=low + + * Update to latest upstream release candidate. + * Forward-port patches: + * 02_libvgahw_gcc4_volatile_fix.diff: update + * 04_read_rom_in_chunks.diff: update + * 05_arm_cache_flush.diff: remove, applied upstream + * 06_arm_is_not_x86_and_has_no_vga.diff: remove, applied upstream + * 07_xorgconf_manpage_overhaul.diff: update + * 08_s390_servermd.diff: update + * 09_debian_xserver_rtff.diff: update + * 12_security_policy_in_etc.diff: update + * 13_debian_add_xkbpath_env_variable.diff: update + * 15_symlink_mesa.diff: remove, fixed upstream + * 16_s390_fix.diff: update + * 17_ignoreabi.diff: remove, applied upstream + * 18_execinfo_only_for_backtrace.patch: remove, applied upstream + * 18_execinfo_configured.patch: remove, applied upstream + * 19_configurable_misc_utils.patch: remove, applied upstream + * 20_mesa_6.5.1.diff: remove, applied upstream + * 21_glx_align_fixes.patch: update + * 22_xkb_cycle_3layouts.diff: remove, applied upstream + * 23_kfreebsd_support.diff: update, partially applied upstream + * 24_hurd_support.diff: update, partially applied upstream + * 25_tfp_damage.diff: remove, applied upstream + * 26_aiglx_happy_vt_switch.diff: remove, applied upstream + * 27_aiglx_locking.diff: remove, applied upstream + * 28_mesa_copy_sub_buffer.diff: remove, applied upstream + * 29_mesa_reseed_makefile.diff: remove, fixed upstream + * 30_fix_vmode_switch.diff: remove, fixed upstream + * 31_blocksigio.diff: remove, fixed upstream + * 32_disable_sparc_pci_bridge.diff: update + * 34_xorg.conf_man_typos.patch: update + * 35_randr_byteswap.patch: update + * 36_fix_ffs.patch: update + * 37_Fix-__glXDRIbindTexImage-for-32-bpp-on-big-endian-platforms.diff: + remove, applied upstream + * Upstream no longer ships a changelog, so don't try to install it. + * Add 37_build-mesa-mipmap.patch that adds the missing mipmap.c to libmain's + sources. + * Add 38_GetDrawableAttributes.patch which readds support for the + GetDrawableAttributes extension that's needed for compiz to work properly. + + -- Thierry Reding Fri, 1 Dec 2006 20:32:34 +0100 + +xorg-server (2:1.1.1-21) unstable; urgency=emergency + + * Security update. + * Fix integer overflow in the ProcXCMiscGetXIDList() function in the XC-MISC + extension. Reference: CVE-2007-1003. + + -- Julien Cristau Wed, 04 Apr 2007 00:34:51 +0200 + +xorg-server (2:1.1.1-20) unstable; urgency=low + + * xephyr: Add patch from upstream git to fix memory leak in + ephyrScreenFini(). Thanks, Guillem Jover! + + -- Julien Cristau Tue, 6 Mar 2007 22:20:14 +0100 + +xorg-server (2:1.1.1-19) unstable; urgency=high + + [ Drew Parsons ] + * Removed spurious space in default font line + (/usr/X11R6/lib/X11/fonts/Type1 not "/usr/X11R6/lib/ X11/fonts/Type1") + + [ David Nusinow ] + * Conflict with and replace xserver-common, because that package used to + provide the SecurityPolicy file. This is an RC bugfix because it breaks + upgrades, so it gets a high urgency. Thanks Christian Tsotras and Lionel + Elie Mamane for reporting and it. Closes: #402658 + + -- David Nusinow Wed, 28 Feb 2007 21:48:19 -0500 + +xorg-server (2:1.1.1-18) unstable; urgency=medium + + * Add patch from Fedora to make xephyr work on 64bit architectures + (closes: #405928). + + -- Julien Cristau Fri, 16 Feb 2007 22:20:08 +0100 + +xorg-server (2:1.1.1-17) unstable; urgency=medium + + * Make the int10 module usable on i386 with a 64bit kernel (closes: #409730). + + New patch 42_build_int10_submodules.diff, which allows us to build vm86 + and x86emu as two separate submodules, and make the int10 module itself + fall back to loading x86emu if vm86 calls fail. + + Add workaround for https://bugs.freedesktop.org/show_bug.cgi?id=7299 to + the above patch: move definition of Int10Current from int10/xf86int10.c + to int10/helper_mem.c. + + Drop the part of 39_alpha_build_flags.patch applying to + hw/xfree86/os-support/linux/Makefile.in, and run autoreconf with all + patches applied. + + -- Julien Cristau Wed, 7 Feb 2007 20:37:19 +0100 + +xorg-server (2:1.1.1-16) unstable; urgency=medium + + * New patch 41_xfree86_linux_acpi_fix_tokenizing.diff from upstream git to + fix a crash on acpi events (closes: #409443). + + -- Julien Cristau Sat, 3 Feb 2007 22:56:04 +0100 + +xorg-server (2:1.1.1-15) unstable; urgency=high + + * High-urgency upload for security bugfix. + * New patch 40_xorg-xserver-1.1.0-dbe-render.diff to fix multiple integer + overflows in the dbe and render extensions. + CVE IDs: CVE-2006-6101 CVE-2006-6102 CVE-2006-6103 + * Add myself to Uploaders, and remove Fabio and Branden, with their + permission. They're of course welcome back when they have more time! + + -- Julien Cristau Tue, 9 Jan 2007 15:45:46 +0100 + +xorg-server (2:1.1.1-14) unstable; urgency=high + + * The "let's drop 20 years of build logic and replace it with autoconf in a + single release, trust me, what could go wrong? " release + * High-urgency upload for RC bugfix + * New patch 39_alpha_build_flags.patch: no really, when they said + lnx_ev56.c should be built with -mcpu=ev56, they really meant it. + Closes: #392500. + + -- Steve Langasek Sun, 7 Jan 2007 15:19:08 -0800 + +xorg-server (2:1.1.1-13) unstable; urgency=medium + + [ Julien Cristau ] + * xserver-xorg-core recommends xfonts-base and suggests xfonts-100dpi | + xfonts-75dpi and xfonts-scalable. Also add explanation about fonts to the + long description, stolen from the old xserver-common package (closes: + #400654). + + [ David Nusinow ] + * This is important for upgrades to etch, and has no notable risk, so bump + priority to medium. + + -- David Nusinow Fri, 29 Dec 2006 19:57:51 -0500 + +xorg-server (2:1.1.1-12) unstable; urgency=low + + [ Julien Cristau ] + * Delete hw/xfree86/common/xf86Build.h in debian/rules clean, since it's + wrongly included in the upstream tarball. + + [ David Nusinow ] + * Pull fix for the ignore_abi.diff patch. This one's a major brown bag on my + part. Thanks Michel Dänzer. + * Add 38_wait_for_something_force_timer_reset.diff which forces the server + to reset timers when they've overrun in some cases rather than wait + forever. Patch by Daniel Stone. Thanks Michel Dänzer for pointing the + changes out. Closes: #374026 + + -- David Nusinow Tue, 12 Dec 2006 21:13:20 -0500 + +xorg-server (2:1.1.1-11) unstable; urgency=low + + [ Drew Parsons ] + * Patches 33_Xserver_man_typos.patch and 34_xorg.conf_man_typos.patch + fix minor typos in Xserver and xorg.conf man pages. + Closes: #364556, #308899. + * Add patch 35_randr_byteswap.patch from upstream. Fixes a client/server + byteswapping problem. Closes: #291100. + + [ Julien Cristau ] + * Don't build-depend on libdrm-dev on hurd-i386 (closes: #358015). Thanks, + Samuel Thibault. + * Update hurd support patch (closes: #356300). Thanks, Samuel Thibault. + * Add reportbug script stolen from the monolith, to add the user's config + and log file in every bug report. + * Delete hw/xfree86/common/xf86Build.h from our source tree, so that the + build date is correctly calculated at build time, and not hardcoded to + 07 July 2006. Thanks to Jurij Smakov for noticing. + * Add patch 36_fix_ffs.patch by Jurij Smakov to fix infinite loop in ffs() + if called with an argument of 0 (closes: #395564). + * Add patch 37_Fix-__glXDRIbindTexImage-for-32-bpp-on-big-endian-platforms + from upstream git to fix color issue on big endian platforms + (closes: #392453). Thanks to Michel Dänzer for the patch! + * Fix typo in xvfb-run (closes: #337703). + * Install xdmxconfig and its manpage in xdmx-tools (closes: #393991). + * Add Replaces: xdmx (<= 2:1.1.1-10) to xdmx-tools because of the xmdxconfig + manpage move. + + -- David Nusinow Fri, 24 Nov 2006 15:44:52 -0500 + +xorg-server (2:1.1.1-10) unstable; urgency=low + + [ Denis Barbier ] + * Fix video mode switching. Closes: #391052 + * Fix FTBFS on kfreebsd-i386 and kfreebsd-amd64. Thanks Petr Salinger. + Closes: #363517 + + [ David Nusinow ] + * Add depends on xserver-xorg so that /etc/X11/X gets installed. Thanks + Frans Pop. Closes: #392295 + * Add 31_blocksigio.diff. This patch by Alan Hourihane, and it prevents a + race condition when a driver tries to set the cursor state when the server + is in the middle of switching resolution. Thanks to Frans Pop for + reporting the bug, Michel Dänzer for reading through the backtrace and + diagnosing the problem, and Alan for the final patch. Closes: #390646. + + [ Jurij Smakov ] + * Add 32_disable_sparc_pci_bridge.diff. Disable PCI bridge handling on + sparc, which is broken and causes filesystem corruption (by poking + the PCI bus in the wrong places) on some machines. Closes: #392312. + + [ Drew Parsons ] + * Use __appmansuffix__ not __mansuffix__ in + 03_xnest_manpage_overhaul.diff. Closes: #390599. + * Install upstream ChangeLog. Closes: #365274. + + -- David Nusinow Mon, 16 Oct 2006 21:59:51 -0400 + +xorg-server (2:1.1.1-9) unstable; urgency=low + + [ Jurij Smakov ] + * Add 21_glx_align_fixes.patch to reintroduce the setting of __GLX_ALIGN64 + variable, lost during the modular transition. This setting is essential + for architectures with strong alignment requirements. Patch affects + alpha, sparc, amd64, ia64 and s390, mimicking the behaviour of the + monolithic build. Closes: #388125. + + [ Denis Barbier ] + * Add 22_xkb_cycle_3layouts.diff to fix layout switching when 3 layouts + are present. Thanks Ivan Pascal for the patch. Closes: #345803 + + [ David Nusinow ] + * Add kFreeBSD support patch (23). Thanks to Robert Millan, Petr Salinger, + Daniel Stone, and Michael Banck for input and patch writing. + Closes: #363517 + * Add hurd support patch (24). Thanks Samuel Thibault, Daniel Stone, and + Michael Banck. Closes: #356300 + * Disable the explicit enabling of dri in the configure. The configure + script autodetects whether or not to use this anyway, and enabling it + explicitly breaks the build on hurd. Thanks Samuel Thibault and Michael + Banck. Closes: #358015 + * Add several patches written by Kristian Høgsberg for allowing compiz to + work with AIGLX. These patches were vetted by Theirry Reding with valuable + advice from Michel Dänzer, and feedback from Kristian himself. + - 25_tfp_damage.diff + - 26_aiglx_happy_vt_switch.diff + - 27_aiglx_locking.diff + - 28_mesa_copy_sub_buffer.diff + - 29_mesa_reseed_makefile.diff + - update of 20_mesa_6.5.1.diff + * Remove bizarre wholesale inclusion of another patch in the 23_kbsd patch + + [ Eugene Konev ] + * Use --with-default-font-path instead of --with-fontdir. + * Set RGBPath through --with-rgb-path. + * Drop 11_debian_always_use_default_font_path.diff. + * Drop 14_debian_always_look_in_our_module_path.diff. + * Ship SecurityPolicy in xserver-xorg-core. + + -- David Nusinow Thu, 28 Sep 2006 23:59:35 -0400 + +xorg-server (2:1.1.1-8) unstable; urgency=low + + * Update mesa symlink patch to the latest from HEAD + * Add 20_mesa_6.5.1.diff to allow the server to build with mesa 6.5.1 + * Bump build-dep versions on x11proto-gl to 1.4.8, and mesa to 6.5.1 + + -- David Nusinow Mon, 25 Sep 2006 22:21:37 -0400 + +xorg-server (2:1.1.1-7) unstable; urgency=low + + * Fix s390 build issue. Thanks Bastian Blank for the report and Eugene Konev + for the patch. Closes: #388628. + * Disable build of various utilities that we don't ship anyway. Patch thanks + to Eugene Konev. + + -- David Nusinow Thu, 21 Sep 2006 23:07:16 -0400 + +xorg-server (2:1.1.1-6) unstable; urgency=low + + * Upload 7.1 to unstable. + + [ Drew Parsons ] + * Added SGI FreeB licence to debian/copyright. Closes: #368563. + * Apply upstream patches 18_execinfo_only_for_backtrace.patch, to use + execinfo.h for and only for backtrace. Applied git patch + 5a3488ccac8e5dabd9fc98bc41ef178ead1b2faf directly into configure scripts, + activated with autoreconf. Closes: #363218. + * Only requires build-depends version of x11proto-gl-dev on 1.4.6. + + [ Steve Langasek ] + * Add versioned build-depends on x11proto-fixes-dev (>= 4.0), to + ensure the package is built against the right protocol version. + Closes: #383778. + + -- David Nusinow Mon, 18 Sep 2006 18:30:07 -0400 + +xorg-server (2:1.1.1-5) experimental; urgency=low + + * Fix error in 16_s390_fix.diff caused by my idiot copying. Thanks Yannick + Roehlly and Daniel Stone. + + -- David Nusinow Sun, 27 Aug 2006 23:25:21 +0000 + +xorg-server (2:1.1.1-4) experimental; urgency=low + + [ Drew Parsons ] + * Tighten dependencies between X11R7.1 server and video drivers. + xserver-xorg-core no longer Depends: xserver-xorg-video-all + | xserver-xorg-video but instead Conflicts: xserver-xorg-video. + (closes: #383873) + The dependency on xserver-xorg-video-all | xserver-xorg-video-1.0 is + managed by the xserver-xorg binary package (not included here in + order to avoid circular dependencies). (closes: #362313) + * Likewise remove Depends: xserver-xorg-input-all | xserver-xorg-input + (again, handled by xserver-xorg) to avoid circular dependency with drivers. + + [ David Nusinow ] + * Epoch bump + * Add 17_ignoreabi.diff to allow users to simply set a value in xorg.conf + rather than pass -ignoreABI to the server every time it starts + + -- David Nusinow Wed, 23 Aug 2006 22:03:06 +0000 + +xorg-server (1:1.1.1-3) unstable; urgency=low + + * Add 16_s390_fix.diff to fix FTBFS on s390. Thanks Bastian Blank. + (closes: #362641) + * Bump build-depends version of libgl1-mesa-dev to 6.5.x package we have in + experimental currently + * Bump build-depends version of x11proto-gl-dev to 1.4.7 or greater + + -- David Nusinow Tue, 22 Aug 2006 00:57:31 +0000 + +xorg-server (1:1.1.1-2) experimental; urgency=low + + [ Drew Parsons ] + * Updated mesa-swx11-source build-depends to (>> 6.5.0), required + for xserver 1.1.1. (closes: #383334) + + [ David Nusinow ] + * Enable and ship xephyr + * Hack off the 'x' manpage suffix + * Install Xnest manpage + * Bump policy version to 3.7.2.0. No changes necessary. + + -- David Nusinow Wed, 16 Aug 2006 21:14:44 +0000 + +xorg-server (1:1.1.1-1) experimental; urgency=low + + [ David Nusinow ] + * New upstream release + * Move patch target call so that we don't try and build twice + * Remove obsolete 15_security_allocate_local.diff and + 16_SECURITY_setuid.diff + * Add 15_symlink_mesa.diff + + -- David Nusinow Sun, 6 Aug 2006 16:12:25 +0000 + +xorg-server (2:1.0.2-10) unstable; urgency=low + + * Upload to unstable to fixed messed up last upload which was supposed to go + to experimental. Brown bag o' joy. + + -- David Nusinow Tue, 22 Aug 2006 19:31:08 +0000 + +xorg-server (1:1.1.1-0ubuntu14) feisty; urgency=low + + * Add 'debian/patches/38_Fix-pDRIPriv_NULL_deref.patch': NULL-init DRI + screen private data, thanks to Tormod Volden (LP: #60288). + + -- Kees Cook Sat, 10 Feb 2007 20:27:44 -0800 + +xorg-server (1:1.1.1-0ubuntu13) feisty; urgency=low + + * 19_revert_xkb_change_breaking_XkbGetKeyboard.patch: + - patch from fedora (with extra Makefile.in change), revert change that + broke XkbGetKeyboard() (Ubuntu: #58083) + * 37_Fix-__glXDRIbindTexImage-for-32-bpp-on-big-endian-platforms.diff: + - upstream patch copied from the Debian package, fix blue screen with + compiz on ppc (Ubuntu: #58373) + + -- Sebastien Bacher Fri, 12 Jan 2007 12:17:28 +0100 + +xorg-server (1:1.1.1-0ubuntu12.1) edgy-security; urgency=low + + * SECURITY UPDATE: Arbitrary code execution with root privileges via heap + overflows in DBE and Render extensions. + * Add 'debian/patches/021_ubuntu_dbe-render_overflows.diff' from + upstream + * References + CVE-2006-6101 CVE-2006-6102 CVE-2006-6103 + + -- Kees Cook Mon, 8 Jan 2007 12:45:41 -0800 + +xorg-server (1:1.1.1-0ubuntu12) edgy; urgency=low + + * debian/patches/17_no_composite_for_xvfb.patch: + - fix a crasher by not using composite for Xvfb when using -render + * debian/patches/18_no_composite_for_xvfb_run.patch: + - use "-extension Composite" to fix xvfb-run crashing + + -- Sebastien Bacher Fri, 13 Oct 2006 17:12:49 +0200 + +xorg-server (1:1.1.1-0ubuntu11) edgy; urgency=low + + * debian/patches/16_only_switch_vt_when_active.patch: + Add a check to prevent the X server from changing the VT when killing + GDM from the console. + + -- Ryan Lortie Thu, 21 Sep 2006 01:26:35 -0400 + +xorg-server (1:1.1.1-0ubuntu10) edgy; urgency=low + + * Build xserver-xephyr from xorg-server package. Malone: #57077, #57084 + + -- Tollef Fog Heen Wed, 6 Sep 2006 12:57:32 +0200 + +xorg-server (1:1.1.1-0ubuntu9) edgy; urgency=low + + * Enable composite extension by default + * Add patch from fd.o bugzilla #7916 to avoid aiglx hangs on vt + switches + + -- Matthew Garrett Sat, 26 Aug 2006 03:20:31 +0100 + +xorg-server (1:1.1.1-0ubuntu8) edgy; urgency=low + + * Steal patch from Fedora to allow compiz to trigger the disabling of + XAA off-screen pixmaps + + -- Matthew Garrett Wed, 23 Aug 2006 21:26:08 +0100 + +xorg-server (1:1.1.1-0ubuntu7) edgy; urgency=low + + * (temporarily) Removed Breaks: section from xserver-xorg-core (necessary + until apt-get properly supports this feature) + * Tightened Build-Depends: mesa-swx11-source to >= + 6.5.0.git.20060810-0ubuntu1 + * Tightened Build-Depends of libgl1-mesa-dev to >= + 6.5.0.git.20060810-0ubuntu1 + + -- Rodrigo Parra Novo Tue, 15 Aug 2006 07:26:07 -0300 + +xorg-server (1:1.1.1-0ubuntu6) edgy; urgency=low + + * Tightened Build-Depends of mesa-swx11-source to version 6.5.0.git.20060809 + * Removed patch 003_fedora_root_window_black_pattern.patch (not necessary + for Ubuntu) + + -- Rodrigo Parra Novo Fri, 11 Aug 2006 11:41:29 -0300 + +xorg-server (1:1.1.1-0ubuntu5) edgy; urgency=low + + * Renamed 003_ubuntu_sharevts_load_cpu.patch to + 002_ubuntu_sharevts_load_cpu.patch + * Added 003_fedora_root_window_black_pattern.patch (black background + pattern instead of default X background pattern. Feel free to revert if + you feel strongly against this one) + * Added 005_fdo4320_composite_fastpath.patch and + 016_fdo7482_xdmx_render_fix.patch (upstream bug fixes, bug numbers + annotated on patch names) + * Added 004_fedora_init_origins_fix.patch (multihead initialization) + * Added 006_ubuntu_fpic_libxf86config.patch + * Added 007_fedora_dont_backfill_bg_none.patch + * Added 008_fedora_gl_include_inferiors.patch, + 009_fedora_mesa_copy_sub_buffer.patch, + 010_fedora_no_move_damage.patch, + 012_fedora_tfp_damage.patch and + 014_fedora_no_composite_in_xnest.patch (further aiglx support) + * 011_fedora_pci_scan_fixes.patch (pci scan fixes - testing is needed to + check if an extra upstream patch for pci domains is also necessary) + * Added 015_fedora_sane_default_mode.patch (tweak default mode - please feel + free to revert this patch if you feel strongly against it) + * Added 017_fedora_add_missing_headers_to_sdk.patch + * Added 018_ubuntu_linux_kernel_include_fixes.patch and + 013_ubuntu_symlink_mesa_source.patch (build fixes against current + linux-kernel-modules * mesa-swx11-source - these already existed before, + but were applied directly to the source tree, instead of being quilt + patches) + * Just for reference: debian patch #02 is candidate for removal on next + upload. I'll refrain from removing it now to diminish the chances of this + being a breaks-for-everyone release + * Moved SecurityPolicy example from /usr/share/doc/examples/ to + /usr/share/doc/xserver-xorg-core/ + + -- Rodrigo Parra Novo Mon, 7 Aug 2006 17:21:05 -0300 + +xorg-server (1:1.1.1-0ubuntu4) edgy; urgency=low + + * Added new Breaks: section to xorg-server-core: + xserver-xorg-driver-all, xserver-xorg-driver-apm, + xserver-xorg-driver-ark, xserver-xorg-driver-ati, + xserver-xorg-driver-chips, xserver-xorg-driver-cirrus, + xserver-xorg-driver-cyrix, xserver-xorg-driver-dummy, + xserver-xorg-driver-fbdev, xserver-xorg-driver-glint, + xserver-xorg-driver-i128, xserver-xorg-driver-i740, + xserver-xorg-driver-i810, xserver-xorg-driver-imstt, + xserver-xorg-driver-mga, xserver-xorg-driver-neomagic, + xserver-xorg-driver-newport, xserver-xorg-driver-nsc, + xserver-xorg-driver-nv, xserver-xorg-driver-rendition, + xserver-xorg-driver-s3, xserver-xorg-driver-s3virge, + xserver-xorg-driver-savage, xserver-xorg-driver-siliconmotion, + xserver-xorg-driver-sis, xserver-xorg-driver-sisusb, + xserver-xorg-driver-tdfx, xserver-xorg-driver-tga, + xserver-xorg-driver-trident, xserver-xorg-driver-tseng, + xserver-xorg-driver-v4l, xserver-xorg-driver-vesa, + xserver-xorg-driver-vga, xserver-xorg-driver-via, + xserver-xorg-driver-vmware, xserver-xorg-driver-voodoo, + xserver-xorg-video-all (<< 7.0.22ubuntu7), + xserver-xorg-video-apm (<< 1:1.1.1-0ubuntu1), + xserver-xorg-video-ark (<< 1:0.6.0-0ubuntu1), + xserver-xorg-video-ati (<< 1:6.6.1-0ubuntu1), + xserver-xorg-video-chips (<< 1:1.1.1-0ubuntu1), + xserver-xorg-video-cirrus (<< 1:1.1.0-0ubuntu1), + xserver-xorg-video-cyrix (<< 1:1.1.0-0ubuntu1), + xserver-xorg-video-dummy (<< 1:0.2.0-0ubuntu1), + xserver-xorg-video-fbdev (<< 1:0.3.0-0ubuntu1), + xserver-xorg-video-glint (<< 1:1.1.1-0ubuntu1), + xserver-xorg-video-i128 (<< 1:1.2.0-0ubuntu1), + xserver-xorg-video-i740 (<< 1:1.1.0-0ubuntu1), + xserver-xorg-video-i810 (<< 1:1.6.1-0ubuntu1), + xserver-xorg-video-imstt (<< 1:1.1.0-0ubuntu1), + xserver-xorg-video-mga (<< 1:1.4.1-0ubuntu1), + xserver-xorg-video-neomagic (<< 1:1.1.1-0ubuntu1), + xserver-xorg-video-newport (<< 1:0.2.0-0ubuntu1), + xserver-xorg-video-nsc (<< 1:2.8.1-0ubuntu1), + xserver-xorg-video-nv (<< 1:1.2.0-0ubuntu1), + xserver-xorg-video-rendition (<< 1:4.1.0-0ubuntu1), + xserver-xorg-video-s3 (<< 1:0.4.1-0ubuntu1), + xserver-xorg-video-s3virge (<< 1:1.9.1-0ubuntu1), + xserver-xorg-video-savage (<< 1:2.1.1-0ubuntu1), + xserver-xorg-video-siliconmotion (<< 1:1.4.1-0ubuntu1), + xserver-xorg-video-sis (<< 1:0.9.1-0ubuntu1), + xserver-xorg-video-sisusb (<< 1:0.8.1-0ubuntu1), + xserver-xorg-video-tdfx (<< 1:1.2.1-0ubuntu1), + xserver-xorg-video-tga (<< 1:1.1.0-0ubuntu1), + xserver-xorg-video-trident (<< 1:1.2.1-0ubuntu1), + xserver-xorg-video-tseng (<< 1:1.1.0-0ubuntu1), + xserver-xorg-video-v4l (<< 1:0.1.1-0ubuntu1), + xserver-xorg-video-vesa (<< 1:1.2.1-0ubuntu1), + xserver-xorg-video-vga (<< 1:4.1.0-0ubuntu1), + xserver-xorg-video-via (<< 1:0.2.1-0ubuntu1), + xserver-xorg-video-vmware (<< 1:10.13.0-0ubuntu1), + xserver-xorg-video-voodoo (<< 1:1.1.0-oubuntu1) + + -- Rodrigo Parra Novo Tue, 1 Aug 2006 22:59:55 -0300 + +xorg-server (1:1.1.1-0ubuntu3) edgy; urgency=low + + * Build with -fno-stack-protector (see LP#54650) + + -- Matt Zimmerman Mon, 31 Jul 2006 16:28:59 -0700 + +xorg-server (1:1.1.1-0ubuntu2) edgy; urgency=low + + * (sparc only) removed stale inclusion of asm/kbio.h on + hw/xfree86/os-support/linux/lnx_io.c and + hw/xfree86/os-support/linux/lnx_kbd.c + * Update debian/serverabiver to 1:1.1.1 + + -- Rodrigo Parra Novo Mon, 31 Jul 2006 12:53:22 -0300 + +xorg-server (1:1.1.1-0ubuntu1) edgy; urgency=low + + * New Upstream version + * Changed Build-Depends from mesa-swrast-source to mesa-swx11-source, + following Debian package nomenclature + * Re-did 12_security_policy_in_etc.diff for 1.1.1 + * Dropped 15_security_allocate_local.diff (applied upstream) + * Dropped 16_SECURITY_setuid.diff (applied upstream) + * Dropped 000_ubuntu_fix_read_kernel_mapping.patch (applied upstream) + * Dropped 002_ubuntu_fix_for_certain_intel_chipsets.patch (applied upstream) + * Updated versioned Build-Depends on mesa-swx11-source to version + 6.5.0.cvs.20060725-0ubuntu1 + * Added arrayobj.c, arrayobj.h, bitset.h & rbadaptors.h to + GL/symlink-mesa.sh (linked from mesa-swx11-source) + * Added arrayobj.c to default build target on GL/mesa/main + + -- Rodrigo Parra Novo Tue, 25 Jul 2006 20:06:28 -0300 + +xorg-server (2:1.0.2-10) unstable; urgency=low + + * Upload to unstable to fixed messed up last upload which was supposed to go + to experimental. Brown bag o' joy. + + -- David Nusinow Tue, 22 Aug 2006 19:31:08 +0000 + +xorg-server (1:1.0.2-9) UNRELEASED; urgency=high + + [ Denis Barbier ] + * Fix 13_debian_add_xkbpath_env_variable.diff, XKBPATH environment + variable was not always taken into account. + + [ David Nusinow ] + * Remove two Ubuntu packaging holdovers. Have xvfb recommend xbase-clients + rather than xauth, and have xserver-xorg-core recommend xkb-data rather + than xkeyboard-config. Thanks Sterling MacNay. + * Security update. Fix for setuid privledge escalation vulernabilities. + See http://lists.freedesktop.org/archives/xorg/2006-June/016146.html for + the full advisory. + + [ Jurij Smakov ] + * Stop including the non-existent asm/kbio.h header file in + hw/xfree86/os-support/linux/lnx_{io,kbd}.c to avoid the build failure + on sparc. + + -- David Nusinow Sat, 1 Jul 2006 17:20:45 -0400 + +xorg-server (1:1.0.2-8) unstable; urgency=low + + * Move xserverrc back to xbase-clients. Thanks Benjamin Mesing. + * Add 15_security_allocate_local.diff. This fixes Bug fd.o bug #6642. + Fix buffer overflow in Render. (CVE 2006-1526). Patch by Eric Anholt. + + -- David Nusinow Tue, 2 May 2006 21:47:17 -0400 + +xorg-server (1:1.0.2-7) unstable; urgency=low + + * Ship xserverrc again in /etc/X11/xinit. Thanks Bastian Kleineidam and + Vasilis Vasaitis. (closes: #357713) + + -- David Nusinow Wed, 26 Apr 2006 00:01:16 -0400 + +xorg-server (1:1.0.2-6) unstable; urgency=low + + [ David Nusinow ] + * Use -DNO_INLINE on s390. Thanks Bastian Blank and Julien Cristau. + (closes: #362641) + * Re-add xvfb-run and manpage to xvfb package. Thanks Josselin Mouette and + Jamie Wilkinson. (closes: #363494) + * Add 014_debian_always_look_in_our_module_path.diff. This will cause the + server to always look in the default module path even if they've specified + an alternate path in their xorg.conf file via the ModulePath option. A + note to users: you should remove this part of your xorg.conf unless you + need it, as the server will look in the right place for modules if you + don't specify a location. + * Run dh_install with --list-missing + * Add missing manpages all around. Thanks Roland Mas and Jan Hudec. + (closes: #362489, #364199) + * Actually install apps to xdmx-tools. Thanks Xavier Bestel. + (closes: #356813) + + [ Denis Barbier ] + * Add 13_debian_add_xkbpath_env_variable.diff so that the server takes + the XKBPATH environment variable into account. (closes: #363229) + + -- David Nusinow Sat, 22 Apr 2006 17:06:23 -0400 + +xorg-server (1:1.0.2-5) unstable; urgency=low + + * Add 11_debian_always_use_default_font_path.diff from Eugene Konev. This + patch causes the server to add the default font path to whatever the user + has specified. Right now, that's /usr/share/fonts/X11, as defined on + configure in debian/rules. Thanks Eugene, this will definitely go a long + way. + * Document how to get rid of error loading glcore (and other modules) in + NEWS.Debian. Thanks Matej Vela and others. + * Provide the virtual 'xserver' package. Thanks Steve Langasek and Daniel + Stone. (closes: #362750) + * Add 12_security_policy_in_etc.diff from Eugene Konev. This will allow us + to tell the server on configure to look in /etc/X11/xserver for the + SecurityPolicy file. Thanks Joey Hess and Eugene. (closes: #362246) + + -- David Nusinow Mon, 17 Apr 2006 00:34:08 -0400 + +xorg-server (1:1.0.2-4) unstable; urgency=low + + * Document the need to update paths in xserver-xorg-core's NEWS file. + (closes: #362077, #362244, #362431) + * Make xserver-xorg-core Architecture: any. (closes: #362150) + * Build with --with-fontdir=/usr/share/fonts/X11. Remove + --with-default-font-path option to make this work. Thanks Eugene Konev. + + -- David Nusinow Thu, 13 Apr 2006 23:54:06 -0400 + +xorg-server (1:1.0.2-3) unstable; urgency=low + + * Add build-conflicts on xlibs-static-dev. Thanks Zephaniah E. Hull. + + -- David Nusinow Tue, 11 Apr 2006 18:44:51 -0400 + +xorg-server (1:1.0.2-2) unstable; urgency=low + + * Upload to unstable + * Add versioned build-dep on libdmx-dev. Thanks Frank Lichtenheld. + (closes: #361752) + + -- David Nusinow Mon, 10 Apr 2006 19:34:04 -0400 + +xorg-server (1:1.0.2-1) experimental; urgency=low + + [ David Nusinow ] + * New upstream release. Fixes CVE-2006-0745 + + [ Denis Barbier ] + * Set XKB base path to /usr/share/X11/xkb. + + -- David Nusinow Mon, 20 Mar 2006 21:41:04 -0500 + +xorg-server (1:1.0.2-0ubuntu10) dapper; urgency=low + + * Backport a fix for Intel bridge handling: + debian/patches/002_fix_for_certain_intel_chipsets.patch + (Closes Ubuntu: #29880) + + -- Paul Sladen Sun, 14 May 2006 19:01:32 +0100 + +xorg-server (1:1.0.2-0ubuntu9) dapper; urgency=low + + * Add 1680x1050 60 and 85Hz Modelines. Thanks to Bart Verwilst for the data. + (Closes Ubuntu: #6096) + + -- Fabio M. Di Nitto Fri, 05 May 2006 12:38:22 +0200 + +xorg-server (1:1.0.2-0ubuntu8) dapper; urgency=low + + * Fix "XCB rendertest crashes server": + - Add patch 001-CVE-2006-1526.patch.dpatch. + (CVE-2006-1526) + + -- Fabio M. Di Nitto Wed, 03 May 2006 09:01:09 +0200 + +xorg-server (1:1.0.2-0ubuntu7) dapper; urgency=low + + * Ship again xorg.conf(5) + (Closes Ubuntu: #33703) + + -- Fabio M. Di Nitto Mon, 01 May 2006 13:37:40 +0200 + +xorg-server (1:1.0.2-0ubuntu6) dapper; urgency=low + + * Fix severe internal memory corruption: + - Add patch: 000-fix-read-kernel-mapping.patch.dpatch. + (freedesktop bugzilla: #6472) + + -- Fabio M. Di Nitto Fri, 21 Apr 2006 08:07:33 +0200 + +xorg-server (1:1.0.2-0ubuntu5) dapper; urgency=low + + * Fix CPU load when using -sharevts: + - Add patch: 991_sharevts-load-cpu.patch + (Thanks for the initial patch to Michael Witrant) + (Closes Ubuntu: #33611) + + -- Fabio M. Di Nitto Mon, 10 Apr 2006 13:30:26 +0200 + +xorg-server (1:1.0.2-0ubuntu4) dapper; urgency=low + + * Fix SecurityPolicy path to /etc/X11/xserver/SecurityPolicy + and ship an example. NOTE: this file is NOT installed by default, + the WARNING you see in Xorg.0.log is an harmless WARNING. + Add patch: 990_ubuntu_fix_security_policy_path.patch. + (Close Ubuntu: #31608) + + * Readd manpages to the different packages. + + * Ship again ioport, gtf, pcitweak and scanpci. + (Closes Ubuntu: #37720) + + -- Fabio M. Di Nitto Tue, 04 Apr 2006 16:33:00 +0200 + +xorg-server (1:1.0.2-0ubuntu3) dapper; urgency=low + + * What about shipping xorg-server.m4 to make developer life easier? + + -- Fabio M. Di Nitto Thu, 23 Mar 2006 10:32:55 +0100 + +xorg-server (1:1.0.2-0ubuntu2) dapper; urgency=low + + * xserver-xorg-dev Depends: x11proto-randr-dev. + (Closes Ubuntu: #35594) + + -- Fabio M. Di Nitto Wed, 22 Mar 2006 08:09:46 +0100 + +xorg-server (1:1.0.2-0ubuntu1) dapper; urgency=low + + * New upstream release: + - Drop patches: + + CVE-2006-0745 + + add-missing-sparc-include + + fix-backtrace + + fix-crash-on-null-addr + + * UVF execption granted by mdz. + + -- Fabio M. Di Nitto Tue, 21 Mar 2006 05:39:01 +0100 + +xorg-server (1:1.0.1-2) experimental; urgency=low + + [ David Nusinow ] + * Add versioned dependency on x11-common + * Remove old cruft in our patches directory + * Port patches from trunk + + 030_libvgahw_gcc4_volatile_fix.diff + + general/026_xc_programs_manpage_overhaul.diff + + arm/303_arm_cache_flush.diff + + arm/315_arm_is_not_x86_and_has_no_vga.diff + + general/099e_xorgconf_manpage_overhaul.diff + + s390/500_s390_support.diff + + debian/910_debian_Xserver_RTFF.diff + * add 04_read_rom_in_chunks.diff. This reads PCI ROM in large chunks rather + than one byte at a time. This patch by Alex Williamson and forwarded to us + by Dann Frazier. Thanks to both of them. (closes: #353168) + * Don't build xserver-xorg-core on s390. This means putting all the other + arches as being explicitly listed. Damn !s390. + * Version the conflict with xserver-xfree86 to allow for the transition + package to be installed + * Remove README.DRI, as it is non-free. Add it to prune list. + * Add 10_dont_look_in_home_for_config.diff to prevent looking in a user's + home directory for xorg.conf. Thanks Daniel Stone for the patch. + + -- David Nusinow Sun, 12 Mar 2006 16:18:13 -0500 + +xorg-server (1:1.0.1-1) experimental; urgency=low + + * First upload to Debian + * Add bison and flex to the build-depends + * Define INSTALL in debian/rules + * Add xserver-xorg-core dependency xserver-xorg-video-all | + xserver-xorg-video. The former is a metapackage that depends on all the + video drivers we ship and the latter is a virtual package that each video + driver provides. This scheme will install the metapackage by default but + will permit any single video driver to satsify the dependency. Do the same + thing for the input drivers. + * switch dpatch build-dependency to quilt + * Deal with mesa packaging rename: build-dep on mesa-swrast-source -> + mesa-swx11-source + * Change xserver-core depends to be on x11-common rather than xorg-common + * Have xserver-xorg-dev install the files in /usr/share/aclocal so we get + xorg-server.m4 + * Manually set permissions on serverabiver installation + * Set the default font path to /usr/share/fonts/X11 instead of + /usr/share/X11/fonts. Thanks Eugene Konev. + + -- David Nusinow Mon, 20 Feb 2006 00:18:45 -0500 + +xorg-server (1:1.0.1-0ubuntu8) dapper; urgency=low + + * [SECURITY] Fix CVE-2006-0745. + + -- Fabio M. Di Nitto Tue, 21 Mar 2006 05:33:50 +0100 + +xorg-server (1:1.0.1-0ubuntu7) dapper; urgency=low + + * debian/control: + - xvfb Depends on xfonts-base too, fix pointed by fabbione + + -- Sebastien Bacher Fri, 3 Mar 2006 22:21:56 +0100 + +xorg-server (1:1.0.1-0ubuntu5) dapper; urgency=low + + * Add missing include on sparc. Fix FTBFS. + + -- Fabio M. Di Nitto Wed, 01 Feb 2006 13:45:41 +0100 + +xorg-server (1:1.0.1-0ubuntu4) dapper; urgency=low + + * Backport from upstream HEAD at Daniel's request: + - Add forgotten HAVE_BACKTRACE define, so that we actually get + backtraces when Xorg segfaults. + + -- Colin Watson Fri, 27 Jan 2006 13:47:56 +0000 + +xorg-server (1:1.0.1-0ubuntu3) dapper; urgency=low + + * Depend on x11-common rather than xorg-common and xserver-common + + -- Tollef Fog Heen Wed, 18 Jan 2006 17:13:12 +0100 + +xorg-server (1:1.0.1-0ubuntu2) dapper; urgency=low + + * Add flex to build-deps, fixing FTBFS. + + -- Tollef Fog Heen Wed, 18 Jan 2006 12:34:03 +0100 + +xorg-server (1:1.0.1-0ubuntu1) dapper; urgency=low + + * New upstream release. + + -- Daniel Stone Fri, 6 Jan 2006 08:00:52 +1100 + +xorg-server (1:1.0.0-0ubuntu1) dapper; urgency=low + + * New upstream release. + + fbCompositeGeneral is now around 97.3% less stuffed (closes: + Ubuntu#20286). + + 'Fix' mouse issues in the DIX by adding XFree86Server defines (sigh; + closes: Ubuntu#20200). + + Fix Emulate3Buttons mouse posting (closes: Ubuntu#11308). + * Bump Build-Depends on libxt-dev (appdefaultdir), libdrm-dev (libdrm2), and + mesa-swrast-source (new files). + * Add --with-fontdir and scotch --with-default-font-path to fix font paths + for non-Xorg servers (closes: Ubuntu#20157). + * Fix path to SecurityPolicy and RGB_DB. + * Move update-linux-hardened-support call to xserver-xorg-core postinst + (from xserver-xorg postinst). + * Add patch to os/access.c so we don't crash on a null-addressed interface + (closes: Ubuntu#20414). + + -- Daniel Stone Tue, 13 Dec 2005 07:27:13 +1100 + +xorg-server (1:0.99.3-0ubuntu6) dapper; urgency=low + + * Fix xserver-xorg-dev Depends field to only depend on the headers this + this package actually uses. + * Re-add xvfb-run to xfvb (closes: Ubuntu#20157). + + -- Daniel Stone Mon, 5 Dec 2005 15:04:14 +1100 + +xorg-server (1:0.99.3-0ubuntu5) dapper; urgency=low + + * Add -ffunction-sections where needed + * Depend: xserver-common: needed for dexconf and /usr/X11R6/bin/X + + -- LaMont Jones Sat, 26 Nov 2005 05:15:36 +0000 + +xorg-server (1:0.99.3-0ubuntu4) dapper; urgency=low + + * Add two more dependencies to build the other half of the video drivers: + - x11proto-xext-dev, x11proto-video-dev + + -- Adam Conrad Fri, 25 Nov 2005 02:36:44 +1100 + +xorg-server (1:0.99.3-0ubuntu3) dapper; urgency=low + + * Add a few dependencies to xorg-server-dev as the path of least resistance + to get all the various input and video drivers to build again: + - For the video drivers: x11proto-randr-dev, x11proto-render-dev, + x11proto-fonts-dev, x11proto-xf86dri-dev, libdrm-dev + - For the input drivers: x11proto-core-dev, x11proto-input-dev, + x11proto-randr-dev (why do input drivers want randr?) + + -- Adam Conrad Thu, 24 Nov 2005 18:51:25 +1100 + +xorg-server (1:0.99.3-0ubuntu2) dapper; urgency=low + + * Add missing libfreetype6-dev build-depends. + + -- Daniel Stone Thu, 24 Nov 2005 10:26:44 +1100 + +xorg-server (1:0.99.3-0ubuntu1) dapper; urgency=low + + * New upstream release. + + -- Daniel Stone Mon, 21 Nov 2005 14:13:41 +1100 + +xorg-server (1:0.99.2+cvs.20051025-3) dapper; urgency=low + + * Version mesa-swrast-source Build-Dep to 6.4.0 or higher, so GLcore is a + little less crash-happy (e.g. when moving your glxgears window). + * Export /usr/share/xserver-xorg/serverabiver to xserver-xorg-dev, which + describes the relationship needed from a driver on xserver-xorg-core. + + -- Daniel Stone Fri, 28 Oct 2005 13:00:26 +1000 + +xorg-server (1:0.99.2+cvs.20051025-2) dapper; urgency=low + + * Add Build-Deps on libxaw7-dev, libxmu-dev, libxt-dev, libxpm-dev, + libx11-dev, libxtst-dev, and libxres-dev for DMX utils. + + -- Daniel Stone Wed, 26 Oct 2005 14:34:40 +1000 + +xorg-server (1:0.99.2+cvs.20051025-1) dapper; urgency=low + + * Update to new upstream version. + * All applicable patches have been committed upstream, bar #989 and #990. + + -- Daniel Stone Thu, 20 Oct 2005 10:26:33 +1000 + +xorg-server (1:0.99.0+cvs.20050901-1) breezy; urgency=low + + * First xorg-server release. + + -- Daniel Stone Wed, 6 Jul 2005 15:48:17 +1000 --- xorg-server-1.4.99.906.orig/debian/prune/non-free +++ xorg-server-1.4.99.906/debian/prune/non-free @@ -0,0 +1 @@ +hw/xfree86/doc/README.DRI --- xorg-server-1.4.99.906.orig/debian/xvfb.install +++ xorg-server-1.4.99.906/debian/xvfb.install @@ -0,0 +1,4 @@ +usr/bin/Xvfb +usr/bin/xvfb-run +usr/share/man/man1/xvfb-run.1 +usr/share/man/man1/Xvfb.1 --- xorg-server-1.4.99.906.orig/debian/inputabiver +++ xorg-server-1.4.99.906/debian/inputabiver @@ -0,0 +1 @@ +2.1 --- xorg-server-1.4.99.906.orig/debian/watch +++ xorg-server-1.4.99.906/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://xorg.freedesktop.org/releases/individual/xserver/ xorg-server-(.*)\.tar\.gz --- xorg-server-1.4.99.906.orig/debian/xdmx-tools.install +++ xorg-server-1.4.99.906/debian/xdmx-tools.install @@ -0,0 +1,7 @@ +usr/bin/dmx* +usr/bin/vdltodmx +usr/bin/xdmx +usr/bin/xdmxconfig +usr/share/man/man1/vdltodmx.1 +usr/share/man/man1/dmxtodmx.1 +usr/share/man/man1/xdmxconfig.1 --- xorg-server-1.4.99.906.orig/debian/xserver-xfbdev.install +++ xorg-server-1.4.99.906/debian/xserver-xfbdev.install @@ -0,0 +1 @@ +usr/bin/Xfbdev --- xorg-server-1.4.99.906.orig/debian/rules +++ xorg-server-1.4.99.906/debian/rules @@ -0,0 +1,178 @@ +#!/usr/bin/make -f +# debian/rules for the Debian xorg-server package. +# Copyright © 2004 Scott James Remnant +# Copyright © 2005 Daniel Stone +# Copyright © 2005 David Nusinow + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +include debian/xsfbs/xsfbs.mk + +CFLAGS = -Wall -g +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif +ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) + NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) + MAKEFLAGS += -j$(NUMJOBS) +endif + +#CPPFLAGS += -DPRE_RELEASE=0 + +DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS) +ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) + confflags += --build=$(DEB_HOST_GNU_TYPE) +else + confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) +endif + +ifeq ($(DEB_HOST_ARCH_OS), linux) + build_xfbdev = --enable-xfbdev +else + build_xfbdev = --disable-xfbdev +endif + +INSTALL=/usr/bin/install + +VENDOR = $(shell lsb_release -i -s) + +# disable-static is so we don't get libfoo.a for modules. now if only we could +# kill the .las. +confflags += --disable-static \ + --enable-xorg \ + --with-default-font-path="/usr/share/fonts/X11/misc,/usr/share/fonts/X11/cyrillic,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType" \ + --with-serverconfig-path=/etc/X11/xserver \ + --enable-xtrap \ + --enable-glx-tls \ + --enable-dmx \ + --enable-record \ + --enable-vfb \ + --enable-kdrive \ + --enable-xephyr \ + --enable-xcsecurity \ + --enable-appgroup \ + --disable-xsdl \ + --disable-xfake \ + $(build_xfbdev) \ + --disable-kdrive-vesa \ + --disable-lbx \ + --disable-xprint \ + --disable-xorgconfig \ + --disable-xorgcfg \ + --with-xkb-path=/usr/share/X11/xkb \ + --with-xkb-output=/var/lib/xkb \ + --enable-xfree86-utils \ + --with-os-vendor="$(VENDOR)" \ + --with-builderstring="$(SOURCE_NAME) $(SOURCE_VERSION) ($(BUILDER))" \ + --with-int10=x86emu \ + --disable-dri2 + +configure: $(STAMP_DIR)/patch + dh_testdir + autoreconf -vfi + +obj-$(DEB_BUILD_GNU_TYPE)/config.status: configure + dh_testdir + mkdir -p obj-$(DEB_BUILD_GNU_TYPE) + cd obj-$(DEB_BUILD_GNU_TYPE) && \ + ../configure --prefix=/usr --mandir=\$${prefix}/share/man \ + --infodir=\$${prefix}/share/info --sysconfdir=/etc \ + --localstatedir=/var $(confflags) CFLAGS="$(CFLAGS)" \ + CPPFLAGS="$(CPPFLAGS)" + + +build: build-stamp +build-stamp: obj-$(DEB_BUILD_GNU_TYPE)/config.status + dh_testdir + cd obj-$(DEB_BUILD_GNU_TYPE) && $(MAKE) + >$@ + +clean: xsfclean + dh_testdir + dh_testroot + rm -f build-stamp + + rm -f config.cache config.log config.status + rm -f */config.cache */config.log */config.status + rm -f conftest* */conftest* + rm -rf autom4te.cache */autom4te.cache + rm -rf obj-* + # generated file, left over in the upstream tarball + # see https://bugs.freedesktop.org/show_bug.cgi?id=9277 + rm -f hw/xfree86/common/xf86Build.h + # more generated files + rm -f include/dix-config.h include/do-not-use-config.h \ + include/xorg-config.h include/xorg-server.h + rm -f $$(find -name Makefile.in) + rm -f compile config.guess config.sub configure depcomp install-sh + rm -f ltmain.sh missing INSTALL aclocal.m4 ylwrap + rm -f include/do-not-use-config.h.in + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + cd obj-$(DEB_BUILD_GNU_TYPE) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install + + # oh, yuck. + find $(CURDIR)/debian/tmp/usr/lib/xorg -type f -name '*.la' | \ + xargs rm -f + + install -m 755 debian/local/xvfb-run debian/tmp/usr/bin + install debian/local/xvfb-run.1 debian/tmp/usr/share/man/man1 + + +# stub to start building deb files, used by binary-indep and binary-arch +binary-initial: + dh_testdir + dh_testroot + +# stub to build deb files, used by binary-indep and binary-arch +# (cf. /usr/share/debhelper/dh_make/debianm/rules) +binary-deb: + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +# Build architecture-dependent files here. +binary-arch: build install + $(MAKE) -f debian/rules DH_OPTIONS=-s binary-initial + + dh_installdocs -s + dh_installchangelogs -s ChangeLog + dh_install -s --sourcedir=debian/tmp --list-missing + $(INSTALL) -d $(CURDIR)/debian/xserver-xorg-dev/usr/share/xserver-xorg + $(INSTALL) -m644 $(CURDIR)/debian/videoabiver \ + $(CURDIR)/debian/xserver-xorg-dev/usr/share/xserver-xorg/videoabiver + $(INSTALL) -m644 $(CURDIR)/debian/inputabiver \ + $(CURDIR)/debian/xserver-xorg-dev/usr/share/xserver-xorg/inputabiver + $(INSTALL) -m644 $(CURDIR)/debian/serverminver \ + $(CURDIR)/debian/xserver-xorg-dev/usr/share/xserver-xorg/serverminver + $(INSTALL) -m 755 -d debian/xserver-xorg-core/usr/share/bug/xserver-xorg-core + $(INSTALL) -m 755 debian/xserver-xorg-core.bug.script debian/xserver-xorg-core/usr/share/bug/xserver-xorg-core/script + dh_installdebconf -s + dh_installman -s + dh_link -s + dh_strip -s --dbg-package=xserver-xorg-core + $(MAKE) -f debian/rules DH_OPTIONS=-s binary-deb + + +# Build architecture-independent files here +binary-indep: + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install --- xorg-server-1.4.99.906.orig/debian/xserver-xorg-dev.install +++ xorg-server-1.4.99.906/debian/xserver-xorg-dev.install @@ -0,0 +1,3 @@ +usr/include/xorg/* +usr/lib/pkgconfig/xorg-server.pc +usr/share/aclocal/* --- xorg-server-1.4.99.906.orig/doc/c-extensions +++ xorg-server-1.4.99.906/doc/c-extensions @@ -0,0 +1,33 @@ +Use of extensions throughout the X server tree +---------------------------------------------- + +Optional extensions: +The server will still build if your toolchain does not support these +extensions, although the results may not be optimal. + + * _X_SENTINEL(x): member x of the passed structure must be NULL, e.g.: + void parseOptions(Option *options _X_SENTINEL(0)); + parseOptions("foo", "bar", NULL); /* this is OK */ + parseOptions("foo", "bar", "baz"); /* this is not */ + This definition comes from Xfuncproto.h in the core + protocol headers. + * _X_ATTRIBUTE_PRINTF(x, y): This function has printf-like semantics; + check the format string when built with + -Wformat (gcc) or similar. + * _X_EXPORT: this function should appear in symbol tables. + * _X_HIDDEN: this function should not appear in the _dynamic_ symbol + table. + * _X_INTERNAL: like _X_HIDDEN, but attempt to ensure that this function + is never called from another module. + * _X_INLINE: inline this functon if possible (generally obeyed unless + disabling optimisations). + * _X_DEPRECATED: warn on use of this function. + +Mandatory extensions: +The server will not build if your toolchain does not support these extensions. + + * named initialisers: explicitly initialising structure members, e.g.: + struct foo bar = { .baz = quux, .brian = "dog" }; + * variadic macros: macros with a variable number of arguments, e.g.: + #define DebugF(x, ...) /**/ + * interleaved code and declarations: { foo = TRUE; int bar; do_stuff(); } --- xorg-server-1.4.99.906.orig/xkb/xkbPrOtherEv.c +++ xorg-server-1.4.99.906/xkb/xkbPrOtherEv.c @@ -0,0 +1,82 @@ +/************************************************************ +Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc. + +Permission to use, copy, modify, and distribute this +software and its documentation for any purpose and without +fee is hereby granted, 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 Silicon Graphics not be +used in advertising or publicity pertaining to distribution +of the software without specific prior written permission. +Silicon Graphics makes no representation about the suitability +of this software for any purpose. It is provided "as is" +without any express or implied warranty. + +SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON +GRAPHICS 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_DIX_CONFIG_H +#include +#endif + +#include +#include +#define NEED_EVENTS 1 +#include +#include +#include +#include "misc.h" +#include "inputstr.h" +#include "xkbsrv.h" + +#include +#include + +extern void ProcessOtherEvent( + xEvent * /* xE */, + DeviceIntPtr /* dev */, + int /* count */ +); + +/***====================================================================***/ + +void +XkbProcessOtherEvent(xEvent *xE,DeviceIntPtr dev,int count) +{ +Bool xkbCares,isBtn; + + xkbCares= True; + isBtn= False; + switch ( xE->u.u.type ) { + case KeyPress: xE->u.u.type= DeviceKeyPress; break; + case KeyRelease: xE->u.u.type= DeviceKeyRelease; break; + case ButtonPress: xE->u.u.type= DeviceButtonPress; + isBtn= True; + break; + case ButtonRelease: xE->u.u.type= DeviceButtonRelease; + isBtn= True; + break; + default: xkbCares= False; break; + } + if (xkbCares) { + if ((!isBtn)||((dev->button)&&(dev->button->xkb_acts))) { + DeviceIntPtr kbd; + if (dev->key) kbd= dev; + else kbd= inputInfo.keyboard; + XkbHandleActions(dev,kbd,xE,count); + return; + } + } + ProcessOtherEvent(xE,dev,count); + return; +} +