diff options
author | alanh <alanh> | 2000-10-18 13:02:15 +0000 |
---|---|---|
committer | alanh <alanh> | 2000-10-18 13:02:15 +0000 |
commit | 4d5686d53505da10dc32507adbb14aecf86b84eb (patch) | |
tree | eed3a4dbe12ccb1989c4598fb5c2cd1381145bb2 | |
parent | c329755dc8b65d5f7aabfcc0f555babbfdb75dec (diff) |
merge trunk into radeon branch.radeon-1-0-0-20001017
115 files changed, 3959 insertions, 5498 deletions
diff --git a/xc/config/cf/linux.cf b/xc/config/cf/linux.cf index 761255335..8e63ac181 100644 --- a/xc/config/cf/linux.cf +++ b/xc/config/cf/linux.cf @@ -180,6 +180,8 @@ XCOMM binutils: (LinuxBinUtilsMajorVersion) # endif # elif defined(SparcArchitecture) # define BuildXF86DRI YES +# elif defined(AlphaArchitecture) +# define BuildXF86DRI YES # else # define BuildXF86DRI NO # endif diff --git a/xc/config/cf/xfree86.cf b/xc/config/cf/xfree86.cf index e1ab679fa..6e88852b0 100644 --- a/xc/config/cf/xfree86.cf +++ b/xc/config/cf/xfree86.cf @@ -70,6 +70,15 @@ XCOMM $TOG: xfree86.cf /main/38 1997/10/22 13:01:59 kaleb $ #define GlideDriver /**/ #endif +/* Use the binary-only library from Matrox? */ +#ifndef UseMatroxHal +#define UseMatroxHal NO +#endif + +#ifndef BuildMatroxHal +#define BuildMatroxHal NO +#endif + /* * For Intel platforms, the default is to build all modules which * are supported on this platform. @@ -610,7 +619,12 @@ IPLAN2P8_DEFS = -DUSE_IPLAN2P8 # if defined(SparcArchitecture) || defined(ia64Architecture) # define GlxArchDefines -D__GLX_ALIGN64 # else -# define GlxArchDefines /**/ +# if defined(AlphaArchitecture) +/* On the Alpha we need to ensure floating point accuracy for 3D */ +# define GlxArchDefines -mieee +# else +# define GlxArchDefines /**/ +# endif # endif # ifndef GlxExtraDefines diff --git a/xc/doc/specs/GL/Imakefile b/xc/doc/specs/GL/Imakefile deleted file mode 100644 index f112c4d1e..000000000 --- a/xc/doc/specs/GL/Imakefile +++ /dev/null @@ -1,4 +0,0 @@ -XCOMM $XFree86: xc/doc/specs/GL/Imakefile,v 1.1 2000/03/02 17:52:57 dawes Exp $ - -InstallDoc(libGL,libGL.txt) - diff --git a/xc/doc/specs/GL/libGL.txt b/xc/doc/specs/GL/libGL.txt deleted file mode 100644 index cb9884043..000000000 --- a/xc/doc/specs/GL/libGL.txt +++ /dev/null @@ -1,197 +0,0 @@ - - - -Introduction ------------- - -This document describes the implementation of the XFree86 4.0 libGL.so -library defined by the Linux/OpenGL Base specification found at -http://reality.sgi.com/opengl/linux/linuxbase.html. - -The documentation is divided into two sections: - User's Guide - Driver Developer's Guide - -Author: Brian Paul (brian@precisioninsight.com) -Date: February 2000 - - - -User's Guide ------------- - -Using libGL.so - -The libGL.so library defines the gl- and glX-prefixed functions needed to -run OpenGL programs. OpenGL client applications should link with the --lGL option to use it. - -libGL.so serves two primary functions: GLX protocol generation for indirect -rendering and loading/management of hardware drivers for direct rendering. - -When libGL.so initializes itself it uses the DRI to determine the -appropriate hardware driver for each screen on the local X display. -The hardware drivers are expected to be in the /usr/X11R6/lib/modules/dri/ -directory. Drivers are named with the convention <name>_dri.so where -<name> is a driver such as "tdfx", "i810", "gamma", etc. - -The LIBGL_DRIVERS_DIR environment variable may be used to specify a -different DRI modules directory, overriding /usr/X11R6/lib/modules/dri/. -This environment variable is ignored in setuid programs for security -reasons. - -When libGL.so is unable to locate appropriate hardware drivers it will -fall back to using indirect GLX rendering. - -To aid in solving problems, libGL.so will print diagnostic messages to -stderr if the LIBGL_DEBUG environment variable is defined. - -libGL.so is thread safe. The overhead of thread safety for common, -single-thread clients is negligible. However, the overhead of thread -safety for multi-threaded clients is significant. Each GL API call -requires two calls to pthread_get_specific() which can noticably -impact performance. Warning: libGL.so is thread safe but individual -DRI drivers may not be. Please consult the documentation for a driver -to learn if it is thread safe. - - - -Indirect Rendering - -You can force indirect rendering mode by setting the LIBGL_ALWAYS_INDIRECT -environment variable. Hardware acceleration will not be used. - - - -libGL.so Extensibility - -libGL.so is designed to be extended without upgrading. That is, -drivers may install new OpenGL extension functions into libGL.so -without requiring libGL.so to be replaced. Clients of libGL.so should -use the glXGetProcAddressEXT() function to obtain the address of -functions by name. For more details of GLX_ARB_get_proc_address see -http://oss.sgi.com/projects/ogl-sample/registry/ARB/get_proc_address.spec - -libGL.so is also designed with flexibility such that it may be used -with many generations of hardware drivers to come. - - - - -Driver Developer's Guide ------------------------- - -This section describes the requirements to make an XFree86 4.0 -libGL.so-compatible hardware driver. It is not intended for end -users of libGL.so. - - -XFree86 source files - -libGL.so is built inside XFree86 with sources found in xc/lib/GL/. -Specifically, libGL.so is built from: - - xc/lib/GL/glx/*.c - xc/lib/dri/XF86dri.c - xc/lib/dri/dri_glx.c - xc/lib/GL/mesa/src/glapi.c - xc/lib/GL/mesa/src/glapitemp.h - xc/lib/GL/mesa/src/glapitable.h - xc/lib/GL/mesa/src/glapioffsets.h - xc/lib/GL/mesa/src/glapinoop.c - xc/lib/GL/mesa/src/glheader.h - xc/lib/GL/mesa/src/glthread.c - xc/lib/GL/mesa/src/glthread.h - xc/lib/GL/mesa/src/X86/glapi_x86.S - xc/lib/GL/mesa/src/X86/assyntax.h - -Understand that the mesa/src/gl*.[ch] files are not tied to Mesa. They -have no dependencies on the rest of Mesa and are designed to be reusable -in a number of projects. - -The glapi_x86.X and assyntax.h files implement x86-optimized dispatch -of GL functions. They are not required; C-based dispatch can be used -instead, with a slight performance penalty. - - - -Driver loading and binding - -When libGL.so initializes itself (via the __glXInitialize function) a -call is made to driCreateDisplay(). This function uses DRI facilities -to determine the driver file appropriate for each screen on the local -display. Each screen's driver is then opened with dlopen() and asked -for its __driCreateScreen() function. The pointers to the __driCreateScreen() -functions are kept in an array, indexed by screen number, in the -__DRIdisplayRec struct. - -When a driver's __driCreateScreen() function is called, it must initialize -a __DRIscreenRec struct. This struct acts as the root of a tree of -function pointers which are called to create and destroy contexts and -drawables and perform all the operations needed by the GLX interface. -See the xc/lib/GL/glx/glxclient.h file for details. - - - -Dynamic Extension Function Registration - -In order to provide forward compatibility with future drivers, libGL.so -allows drivers to register new OpenGL extension functions which weren't -known when libGL.so was built. - -The register_extensions() function in xc/lib/GL/dri/dri_glx.c is called -as soon as libGL.so is loaded. This is done with gcc's constructor -attribute. This mechanism will likely have to be changed for other compilers. - -register_extensions() loops over all local displays and screens, determines -the DRI driver for each, and calls the driver's __driRegisterExtensions() -function, if present. - -The __driRegisterExtensions() function can add new entrypoints to libGL -by calling: - - GLboolean _glapi_add_entrypoint(const char *funcName, GLuint offset) - -The parameters are the name of the function (such as "glFoobarEXT") and the -offset of the dispatch slot in the API dispatch table. The return value -indicates success (GL_TRUE) or failure (GL_FALSE). - -_glapi_add_entrypoint() will synthesize entrypoint code in assembly -language. Assembly languages is required since parameter passing -can't be handled correctly using a C-based solution. - -The address of the new entrypoint is obtained by calling the -glXGetProcAddressARB() function. - -The dispatch offset number MUST be a number allocated by SGI in the same -manner in which new GL_* constants are allocated. Using an arbitrary -offset number will result in many problems. - - - -Dispatch Management - -When a GL context is made current, the driver must install its dispatch -table as the current dispatch table. This is done by calling - - void _glapi_set_dispatch(struct _glapi_table *dispatch); - -This will install the named dispatch table for the calling thread. -The current dispatch table for a thread can be obtained by calling - - struct _glapi_table *_glapi_get_dispatch(void); - -For higher performance in the common single-thread case, the global -variable _glapi_Dispatch will point to the current dispatch table. -This variable will be NULL when in multi-thread mode. - - - -Context Management - -libGL.so uses the XFree86 xthreads package to manage a thread-specific -current context pointer. See __glXGet/SetCurrentContext() in glext.c - -Drivers may use the _glapi_set/get_context() functions to maintain -a private thread-specific context pointer. - diff --git a/xc/extras/Mesa/src/fog.c b/xc/extras/Mesa/src/fog.c index c3d023727..15dad1d36 100644 --- a/xc/extras/Mesa/src/fog.c +++ b/xc/extras/Mesa/src/fog.c @@ -426,4 +426,3 @@ _mesa_fog_ci_pixels( const GLcontext *ctx, return; } } - diff --git a/xc/extras/Mesa/src/teximage.c b/xc/extras/Mesa/src/teximage.c index c79156370..8f55409e6 100644 --- a/xc/extras/Mesa/src/teximage.c +++ b/xc/extras/Mesa/src/teximage.c @@ -1,7 +1,7 @@ /* * Mesa 3-D graphics library - * Version: 3.3 + * Version: 3.4 * * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * @@ -139,21 +139,23 @@ logbase2( int n ) GLint _mesa_base_tex_format( GLcontext *ctx, GLint format ) { + /* + * Ask the driver for the base format, if it doesn't + * know, it will return -1; + */ + if (ctx->Driver.BaseCompressedTexFormat) { + GLint ifmt = (*ctx->Driver.BaseCompressedTexFormat)(ctx, format); + if (ifmt >= 0) { + return ifmt; + } + } switch (format) { - case GL_COMPRESSED_ALPHA_ARB: - if (ctx && !ctx->Extensions.HaveTextureCompression) - return -1; - /* fall-through */ case GL_ALPHA: case GL_ALPHA4: case GL_ALPHA8: case GL_ALPHA12: case GL_ALPHA16: return GL_ALPHA; - case GL_COMPRESSED_LUMINANCE_ARB: - if (ctx && !ctx->Extensions.HaveTextureCompression) - return -1; - /* fall-through */ case 1: case GL_LUMINANCE: case GL_LUMINANCE4: @@ -161,10 +163,6 @@ _mesa_base_tex_format( GLcontext *ctx, GLint format ) case GL_LUMINANCE12: case GL_LUMINANCE16: return GL_LUMINANCE; - case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: - if (ctx && !ctx->Extensions.HaveTextureCompression) - return -1; - /* fall-through */ case 2: case GL_LUMINANCE_ALPHA: case GL_LUMINANCE4_ALPHA4: @@ -174,31 +172,12 @@ _mesa_base_tex_format( GLcontext *ctx, GLint format ) case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: return GL_LUMINANCE_ALPHA; - case GL_COMPRESSED_INTENSITY_ARB: - if (ctx && !ctx->Extensions.HaveTextureCompression) - return -1; - /* fall-through */ case GL_INTENSITY: case GL_INTENSITY4: case GL_INTENSITY8: case GL_INTENSITY12: case GL_INTENSITY16: return GL_INTENSITY; - case GL_COMPRESSED_RGB_ARB: - if (ctx && ctx->Extensions.HaveTextureCompression) - return GL_RGB; - else - return -1; - case GL_COMPRESSED_RGB_FXT1_3DFX: - if (ctx && ctx->Extensions.HaveTextureCompressionFXT1) - return GL_RGB; - else - return -1; - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - if (ctx && ctx->Extensions.HaveTextureCompressionS3TC) - return GL_RGB; - else - return -1; case 3: case GL_RGB: case GL_R3_G3_B2: @@ -209,23 +188,6 @@ _mesa_base_tex_format( GLcontext *ctx, GLint format ) case GL_RGB12: case GL_RGB16: return GL_RGB; - case GL_COMPRESSED_RGBA_ARB: - if (ctx && ctx->Extensions.HaveTextureCompression) - return GL_RGBA; - else - return -1; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - if (ctx && ctx->Extensions.HaveTextureCompressionFXT1) - return GL_RGBA; - else - return -1; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - if (ctx && ctx->Extensions.HaveTextureCompressionS3TC) - return GL_RGBA; - else - return -1; case 4: case GL_RGBA: case GL_RGBA2: @@ -328,25 +290,12 @@ components_in_intformat( GLint format ) * otherwise. */ static GLboolean -is_compressed_format(GLenum internalFormat) +is_compressed_format(GLcontext *ctx, GLenum internalFormat) { - switch (internalFormat) { - case GL_COMPRESSED_ALPHA_ARB: - case GL_COMPRESSED_LUMINANCE_ARB: - case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: - case GL_COMPRESSED_INTENSITY_ARB: - case GL_COMPRESSED_RGB_ARB: - case GL_COMPRESSED_RGBA_ARB: - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_COMPRESSED_RGB_FXT1_3DFX: - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return GL_TRUE; - default: - return GL_FALSE; - } + if (ctx->Driver.IsCompressedFormat) { + return (*ctx->Driver.IsCompressedFormat)(ctx, internalFormat); + } + return GL_FALSE; } @@ -511,13 +460,14 @@ _mesa_alloc_texture_image( void ) * Initialize most fields of a gl_texture_image struct. */ static void -init_texture_image( struct gl_texture_image *img, +init_texture_image( GLcontext *ctx, + struct gl_texture_image *img, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum internalFormat ) { ASSERT(img); ASSERT(!img->Data); - img->Format = (GLenum) _mesa_base_tex_format(NULL, internalFormat); + img->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat); set_teximage_component_sizes( img ); img->IntFormat = (GLenum) internalFormat; img->Border = border; @@ -537,7 +487,7 @@ init_texture_image( struct gl_texture_image *img, img->Height2 = 1 << img->HeightLog2; img->Depth2 = 1 << img->DepthLog2; img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); - img->IsCompressed = is_compressed_format(internalFormat); + img->IsCompressed = is_compressed_format(ctx, internalFormat); } @@ -556,13 +506,26 @@ _mesa_free_texture_image( struct gl_texture_image *teximage ) /* * Return number of bytes of storage needed to store a compressed texture - * image. + * image. Only the driver knows for sure. If the driver can't help us, + * we must return 0. */ GLuint -_mesa_compressed_image_size(GLenum internalFormat, - GLint width, GLint height, GLint depth) +_mesa_compressed_image_size(GLcontext *ctx, + GLenum internalFormat, + GLint numDimensions, + GLint width, + GLint height, + GLint depth) { - return 0; + if (ctx->Driver.CompressedImageSize) { + return (*ctx->Driver.CompressedImageSize)(ctx, internalFormat, + numDimensions, + width, height, depth); + } + else { + /* Shouldn't this be an internal error of some sort? */ + return 0; + } } @@ -878,6 +841,40 @@ make_null_texture( struct gl_texture_image *texImage ) /* + * This is called when a proxy texture test fails, we set all the + * image members (except DriverData) to zero. + */ +static void +clear_proxy_teximage(struct gl_texture_image *img) +{ + ASSERT(img); + img->Format = 0; + img->IntFormat = 0; + img->RedBits = 0; + img->GreenBits = 0; + img->BlueBits = 0; + img->AlphaBits = 0; + img->IntensityBits = 0; + img->LuminanceBits = 0; + img->IndexBits = 0; + img->Border = 0; + img->Width = 0; + img->Height = 0; + img->Depth = 0; + img->Width2 = 0; + img->Height2 = 0; + img->Depth2 = 0; + img->WidthLog2 = 0; + img->HeightLog2 = 0; + img->DepthLog2 = 0; + img->Data = NULL; + img->IsCompressed = 0; + img->CompressedSize = 0; +} + + + +/* * Test glTexImage[123]D() parameters for errors. * Input: * dimensions - must be 1 or 2 or 3 @@ -999,7 +996,7 @@ texture_error_check( GLcontext *ctx, GLenum target, return GL_TRUE; } - if (!is_compressed_format(internalFormat)) { + if (!is_compressed_format(ctx, internalFormat)) { if (!_mesa_is_legal_format_and_type( format, type )) { /* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there * is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4. @@ -1125,7 +1122,7 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions, } } - if (!is_compressed_format(destTex->IntFormat)) { + if (!is_compressed_format(ctx, destTex->IntFormat)) { if (!_mesa_is_legal_format_and_type(format, type)) { char message[100]; sprintf(message, "glTexSubImage%dD(format or type)", dimensions); @@ -1344,6 +1341,105 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions, /* + * Turn generic compressed formats into specific compressed format. + * Some of the compressed formats we don't support, so we + * fall back to the uncompressed format. (See issue 15 of + * the GL_ARB_texture_compression specification.) + */ +static GLint +get_specific_compressed_tex_format(GLcontext *ctx, + GLint ifmt, GLint numDimensions) +{ + char message[100]; + GLint internalFormat = ifmt; + + if (ctx->Extensions.HaveTextureCompression + && ctx->Driver.SpecificCompressedTexFormat) { + /* + * First, ask the driver for the specific format. + */ + switch (internalFormat) { + case GL_COMPRESSED_ALPHA_ARB: + case GL_COMPRESSED_LUMINANCE_ARB: + case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: + case GL_COMPRESSED_INTENSITY_ARB: + case GL_COMPRESSED_RGB_ARB: + case GL_COMPRESSED_RGBA_ARB: + internalFormat = (*ctx->Driver.SpecificCompressedTexFormat) + (ctx, internalFormat, numDimensions); + /* XXX shouldn't we return now? */ + break; + default: + /* silence compiler warnings */ + ; + } + } + + /* + * Now, convert any generic format left to an uncompressed + * specific format. If the driver does not support compression + * of the format, we must drop back to the uncompressed format. + * See issue 15 of the GL_ARB_texture_compression specification. + */ + switch (internalFormat) { + case GL_COMPRESSED_ALPHA_ARB: + if (ctx && !ctx->Extensions.HaveTextureCompression) { + sprintf(message, "glTexImage%dD(internalFormat)", numDimensions); + gl_error(ctx, GL_INVALID_VALUE, message); + return -1; + } + internalFormat = GL_ALPHA; + break; + case GL_COMPRESSED_LUMINANCE_ARB: + if (ctx && !ctx->Extensions.HaveTextureCompression) { + sprintf(message, "glTexImage%dD(internalFormat)", numDimensions); + gl_error(ctx, GL_INVALID_VALUE, message); + return -1; + } + internalFormat = GL_LUMINANCE; + break; + case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: + if (ctx && !ctx->Extensions.HaveTextureCompression) { + sprintf(message, "glTexImage%dD(internalFormat)", numDimensions); + gl_error(ctx, GL_INVALID_VALUE, message); + return -1; + } + internalFormat = GL_LUMINANCE_ALPHA; + break; + case GL_COMPRESSED_INTENSITY_ARB: + if (ctx && !ctx->Extensions.HaveTextureCompression) { + sprintf(message, "glTexImage%dD(internalFormat)", numDimensions); + gl_error(ctx, GL_INVALID_VALUE, message); + return -1; + } + internalFormat = GL_INTENSITY; + break; + case GL_COMPRESSED_RGB_ARB: + if (ctx && !ctx->Extensions.HaveTextureCompression) { + sprintf(message, "glTexImage%dD(internalFormat)", numDimensions); + gl_error(ctx, GL_INVALID_VALUE, message); + return -1; + } + internalFormat = GL_RGB; + break; + case GL_COMPRESSED_RGBA_ARB: + if (ctx && !ctx->Extensions.HaveTextureCompression) { + sprintf(message, "glTexImage%dD(internalFormat)", numDimensions); + gl_error(ctx, GL_INVALID_VALUE, message); + return -1; + } + internalFormat = GL_RGBA; + break; + default: + /* silence compiler warning */ + ; + } + return internalFormat; +} + + + +/* * Called from the API. Note that width includes the border. */ void @@ -1358,6 +1454,19 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; struct gl_texture_image *texImage; + GLint ifmt; + + ifmt = get_specific_compressed_tex_format(ctx, internalFormat, 1); + if (ifmt < 0) { + /* + * The error here is that we were sent a generic compressed + * format, but the extension is not supported. + */ + return; + } + else { + internalFormat = ifmt; + } if (texture_error_check(ctx, target, level, internalFormat, format, type, 1, width, 1, 1, border)) { @@ -1382,7 +1491,7 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, } /* setup the teximage struct's fields */ - init_texture_image(texImage, width, 1, 1, border, internalFormat); + init_texture_image(ctx, texImage, width, 1, 1, border, internalFormat); /* process the texture image */ if (pixels) { @@ -1433,13 +1542,12 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, format, type, 1, width, 1, 1, border)) { /* if error, clear all proxy texture image parameters */ if (level>=0 && level<ctx->Const.MaxTextureLevels) { - MEMSET( ctx->Texture.Proxy1D->Image[level], 0, - sizeof(struct gl_texture_image) ); + clear_proxy_teximage(ctx->Texture.Proxy1D->Image[level]); } } else { /* if no error, update proxy texture image parameters */ - init_texture_image(ctx->Texture.Proxy1D->Image[level], + init_texture_image(ctx, ctx->Texture.Proxy1D->Image[level], width, 1, 1, border, internalFormat); } } @@ -1466,6 +1574,19 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; struct gl_texture_image *texImage; + GLint ifmt; + + ifmt = get_specific_compressed_tex_format(ctx, internalFormat, 2); + if (ifmt < 0) { + /* + * The error here is that we were sent a generic compressed + * format, but the extension is not supported. + */ + return; + } + else { + internalFormat = ifmt; + } if (texture_error_check(ctx, target, level, internalFormat, format, type, 2, width, height, 1, border)) { @@ -1491,7 +1612,8 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, } /* setup the teximage struct's fields */ - init_texture_image(texImage, width, height, 1, border, internalFormat); + init_texture_image(ctx, texImage, width, height, + 1, border, internalFormat); /* process the texture image */ if (pixels) { @@ -1551,13 +1673,13 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, format, type, 2, width, height, 1, border)) { /* if error, clear all proxy texture image parameters */ if (level>=0 && level<ctx->Const.MaxTextureLevels) { - MEMSET( ctx->Texture.Proxy2D->Image[level], 0, - sizeof(struct gl_texture_image) ); + clear_proxy_teximage(ctx->Texture.Proxy2D->Image[level]); } } else { /* if no error, update proxy texture image parameters */ - init_texture_image(ctx->Texture.Proxy2D->Image[level], + init_texture_image(ctx, + ctx->Texture.Proxy2D->Image[level], width, height, 1, border, internalFormat); } } @@ -1586,6 +1708,20 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; struct gl_texture_image *texImage; + GLint ifmt; + + ifmt = get_specific_compressed_tex_format(ctx, internalFormat, 3); + if (ifmt < 0) { + /* + * The error here is that we were sent a generic compressed + * format, but the extension is not supported. + */ + return; + } + else { + internalFormat = ifmt; + } + if (texture_error_check(ctx, target, level, internalFormat, format, type, 3, width, height, depth, border)) { return; /* error in texture image was detected */ @@ -1609,7 +1745,7 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, } /* setup the teximage struct's fields */ - init_texture_image(texImage, width, height, depth, + init_texture_image(ctx, texImage, width, height, depth, border, internalFormat); /* process the texture image */ @@ -1661,13 +1797,12 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, format, type, 3, width, height, depth, border)) { /* if error, clear all proxy texture image parameters */ if (level>=0 && level<ctx->Const.MaxTextureLevels) { - MEMSET( ctx->Texture.Proxy3D->Image[level], 0, - sizeof(struct gl_texture_image) ); + clear_proxy_teximage(ctx->Texture.Proxy3D->Image[level]); } } else { /* if no error, update proxy texture image parameters */ - init_texture_image(ctx->Texture.Proxy3D->Image[level], + init_texture_image(ctx, ctx->Texture.Proxy3D->Image[level], width, height, depth, border, internalFormat); } } @@ -2511,10 +2646,25 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCompressedTexImage1DARB"); + switch (internalFormat) { + case GL_COMPRESSED_ALPHA_ARB: + case GL_COMPRESSED_LUMINANCE_ARB: + case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: + case GL_COMPRESSED_INTENSITY_ARB: + case GL_COMPRESSED_RGB_ARB: + case GL_COMPRESSED_RGBA_ARB: + gl_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage1DARB"); + return; + default: + /* silence compiler warning */ + ; + } + if (target == GL_TEXTURE_1D) { struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; struct gl_texture_image *texImage; + GLsizei computedImageSize; if (texture_error_check(ctx, target, level, internalFormat, GL_NONE, GL_NONE, 1, width, 1, 1, border)) { @@ -2539,23 +2689,32 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level, } /* setup the teximage struct's fields */ - init_texture_image(texImage, width, 1, 1, border, internalFormat); + init_texture_image(ctx, texImage, width, 1, 1, + border, internalFormat); /* process the texture image */ if (data) { GLboolean retain = GL_TRUE; GLboolean success = GL_FALSE; if (ctx->Driver.CompressedTexImage1D) { - success = (*ctx->Driver.CompressedTexImage1D)( ctx, target, level, - data, texObj, texImage, &retain); + success = (*ctx->Driver.CompressedTexImage1D)(ctx, target, level, + imageSize, data, texObj, texImage, &retain); } if (retain || !success) { /* make internal copy of the texture image */ - GLuint imageSize = _mesa_compressed_image_size(internalFormat, - width, 1, 1); - texImage->Data = MALLOC(imageSize); + computedImageSize = _mesa_compressed_image_size(ctx, + internalFormat, + 1, /* num dims */ + width, + 1, /* height */ + 1); /* depth */ + if (computedImageSize != imageSize) { + gl_error(ctx, GL_INVALID_VALUE, "glCompressedTexImage1DARB(imageSize)"); + return; + } + texImage->Data = MALLOC(computedImageSize); if (texImage->Data) { - MEMCPY(texImage->Data, data, imageSize); + MEMCPY(texImage->Data, data, computedImageSize); } } if (!retain && texImage->Data) { @@ -2567,8 +2726,9 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level, make_null_texture(texImage); if (ctx->Driver.CompressedTexImage1D) { GLboolean retain; - (*ctx->Driver.CompressedTexImage1D)( ctx, target, level, - texImage->Data, texObj, texImage, &retain); + (*ctx->Driver.CompressedTexImage1D)(ctx, target, level, 0, + texImage->Data, texObj, + texImage, &retain); } } @@ -2582,13 +2742,12 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level, GL_NONE, GL_NONE, 1, width, 1, 1, border)) { /* if error, clear all proxy texture image parameters */ if (level>=0 && level<ctx->Const.MaxTextureLevels) { - MEMSET( ctx->Texture.Proxy1D->Image[level], 0, - sizeof(struct gl_texture_image) ); + clear_proxy_teximage(ctx->Texture.Proxy1D->Image[level]); } } else { /* if no error, update proxy texture image parameters */ - init_texture_image(ctx->Texture.Proxy1D->Image[level], + init_texture_image(ctx, ctx->Texture.Proxy1D->Image[level], width, 1, 1, border, internalFormat); } } @@ -2608,6 +2767,20 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCompressedTexImage2DARB"); + switch (internalFormat) { + case GL_COMPRESSED_ALPHA_ARB: + case GL_COMPRESSED_LUMINANCE_ARB: + case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: + case GL_COMPRESSED_INTENSITY_ARB: + case GL_COMPRESSED_RGB_ARB: + case GL_COMPRESSED_RGBA_ARB: + gl_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage2DARB"); + return; + default: + /* silence compiler warning */ + ; + } + if (target==GL_TEXTURE_2D || (ctx->Extensions.HaveTextureCubeMap && target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && @@ -2615,6 +2788,7 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level, struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; struct gl_texture_image *texImage; + GLsizei computedImageSize; if (texture_error_check(ctx, target, level, internalFormat, GL_NONE, GL_NONE, 1, width, height, 1, border)) { @@ -2639,23 +2813,37 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level, } /* setup the teximage struct's fields */ - init_texture_image(texImage, width, height, 1, border, internalFormat); + init_texture_image(ctx, texImage, width, height, 1, border, internalFormat); /* process the texture image */ if (data) { GLboolean retain = GL_TRUE; GLboolean success = GL_FALSE; if (ctx->Driver.CompressedTexImage2D) { - success = (*ctx->Driver.CompressedTexImage2D)( ctx, target, level, - data, texObj, texImage, &retain); + success = (*ctx->Driver.CompressedTexImage2D)( ctx, + target, + level, + imageSize, + data, + texObj, + texImage, + &retain); } if (retain || !success) { /* make internal copy of the texture image */ - GLuint imageSize = _mesa_compressed_image_size(internalFormat, - width, height, 1); - texImage->Data = MALLOC(imageSize); + computedImageSize = _mesa_compressed_image_size(ctx, + internalFormat, + 2, /* num dims */ + width, + height, + 1); /* depth */ + if (computedImageSize != imageSize) { + gl_error(ctx, GL_INVALID_VALUE, "glCompressedTexImage2DARB(imageSize)"); + return; + } + texImage->Data = MALLOC(computedImageSize); if (texImage->Data) { - MEMCPY(texImage->Data, data, imageSize); + MEMCPY(texImage->Data, data, computedImageSize); } } if (!retain && texImage->Data) { @@ -2667,8 +2855,9 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level, make_null_texture(texImage); if (ctx->Driver.CompressedTexImage2D) { GLboolean retain; - (*ctx->Driver.CompressedTexImage2D)( ctx, target, level, - texImage->Data, texObj, texImage, &retain); + (*ctx->Driver.CompressedTexImage2D)( ctx, target, level, 0, + texImage->Data, texObj, + texImage, &retain); } } @@ -2682,13 +2871,12 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level, GL_NONE, GL_NONE, 1, width, 1, 1, border)) { /* if error, clear all proxy texture image parameters */ if (level>=0 && level<ctx->Const.MaxTextureLevels) { - MEMSET( ctx->Texture.Proxy2D->Image[level], 0, - sizeof(struct gl_texture_image) ); + clear_proxy_teximage(ctx->Texture.Proxy2D->Image[level]); } } else { /* if no error, update proxy texture image parameters */ - init_texture_image(ctx->Texture.Proxy2D->Image[level], + init_texture_image(ctx, ctx->Texture.Proxy2D->Image[level], width, 1, 1, border, internalFormat); } } @@ -2708,10 +2896,25 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCompressedTexImage3DARB"); + switch (internalFormat) { + case GL_COMPRESSED_ALPHA_ARB: + case GL_COMPRESSED_LUMINANCE_ARB: + case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: + case GL_COMPRESSED_INTENSITY_ARB: + case GL_COMPRESSED_RGB_ARB: + case GL_COMPRESSED_RGBA_ARB: + gl_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage3DARB"); + return; + default: + /* silence compiler warning */ + ; + } + if (target == GL_TEXTURE_3D) { struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; struct gl_texture_image *texImage; + GLsizei computedImageSize; if (texture_error_check(ctx, target, level, internalFormat, GL_NONE, GL_NONE, 1, width, height, depth, border)) { @@ -2736,23 +2939,34 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level, } /* setup the teximage struct's fields */ - init_texture_image(texImage, width, height, depth, border, internalFormat); + init_texture_image(ctx, texImage, width, height, depth, + border, internalFormat); /* process the texture image */ if (data) { GLboolean retain = GL_TRUE; GLboolean success = GL_FALSE; if (ctx->Driver.CompressedTexImage3D) { - success = (*ctx->Driver.CompressedTexImage3D)( ctx, target, level, - data, texObj, texImage, &retain); + success = (*ctx->Driver.CompressedTexImage3D)(ctx, target, level, + imageSize, data, + texObj, texImage, + &retain); } if (retain || !success) { /* make internal copy of the texture image */ - GLuint imageSize = _mesa_compressed_image_size(internalFormat, - width, height, depth); - texImage->Data = MALLOC(imageSize); + computedImageSize = _mesa_compressed_image_size(ctx, + internalFormat, + 3, /* num dims */ + width, + height, + depth); + if (computedImageSize != imageSize) { + gl_error(ctx, GL_INVALID_VALUE, "glCompressedTexImage3DARB(imageSize)"); + return; + } + texImage->Data = MALLOC(computedImageSize); if (texImage->Data) { - MEMCPY(texImage->Data, data, imageSize); + MEMCPY(texImage->Data, data, computedImageSize); } } if (!retain && texImage->Data) { @@ -2764,8 +2978,9 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level, make_null_texture(texImage); if (ctx->Driver.CompressedTexImage3D) { GLboolean retain; - (*ctx->Driver.CompressedTexImage3D)( ctx, target, level, - texImage->Data, texObj, texImage, &retain); + (*ctx->Driver.CompressedTexImage3D)( ctx, target, level, 0, + texImage->Data, texObj, + texImage, &retain); } } @@ -2779,13 +2994,12 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level, GL_NONE, GL_NONE, 1, width, height, depth, border)) { /* if error, clear all proxy texture image parameters */ if (level>=0 && level<ctx->Const.MaxTextureLevels) { - MEMSET( ctx->Texture.Proxy3D->Image[level], 0, - sizeof(struct gl_texture_image) ); + clear_proxy_teximage(ctx->Texture.Proxy3D->Image[level]); } } else { /* if no error, update proxy texture image parameters */ - init_texture_image(ctx->Texture.Proxy3D->Image[level], + init_texture_image(ctx, ctx->Texture.Proxy3D->Image[level], width, 1, 1, border, internalFormat); } } @@ -2829,7 +3043,6 @@ _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, gl_problem(ctx, "glCompressedTexSubImage1DARB failed!"); return; } - } diff --git a/xc/extras/Mesa/src/vbrender.c b/xc/extras/Mesa/src/vbrender.c index cc4adb981..3d053fd4d 100644 --- a/xc/extras/Mesa/src/vbrender.c +++ b/xc/extras/Mesa/src/vbrender.c @@ -100,20 +100,14 @@ static INLINE void gl_render_clipped_line2( GLcontext *ctx, static void offset_polygon( GLcontext *ctx, GLfloat a, GLfloat b, GLfloat c ) { GLfloat ac, bc, m; - GLfloat offset; + GLfloat offset = 0.0F; - if (c<0.001F && c>-0.001F) { - /* to prevent underflow problems */ - offset = 0.0F; - } - else { + if (c*c > 1e-16) { ac = a / c; bc = b / c; if (ac<0.0F) ac = -ac; if (bc<0.0F) bc = -bc; m = MAX2( ac, bc ); - /* m = sqrt( ac*ac + bc*bc ); */ - offset = m * ctx->Polygon.OffsetFactor + ctx->Polygon.OffsetUnits; } @@ -125,10 +119,17 @@ static void offset_polygon( GLcontext *ctx, GLfloat a, GLfloat b, GLfloat c ) #define FLUSH_PRIM(prim) \ do { \ if (ctx->PB->primitive != prim) { \ - gl_reduced_prim_change( ctx, prim ); \ + gl_reduced_prim_change( ctx, prim ); \ } \ } while(0) +#define FLUSH_POLY(prim) \ +do { \ + if ((ctx->IndirectTriangles & DD_TRI_UNFILLED) == 0) { \ + FLUSH_PRIM(prim); \ + } \ +} while(0) + /* * When glPolygonMode() is used to specify that the front/back rendering @@ -156,7 +157,6 @@ static void unfilled_polygon( GLcontext *ctx, } else if (mode==GL_LINE) { GLuint i, j0, j1; - ctx->StippleCounter = 0; /* draw the edges */ for (i=0;i<n-1;i++) { @@ -319,6 +319,13 @@ static void render_triangle( GLcontext *ctx, else { (*ctx->Driver.TriangleFunc)( ctx, v0, v1, v2, pv ); } + + if (tricaps & DD_TRI_OFFSET) { + /* reset Z offsets now */ + ctx->PointZoffset = 0.0; + ctx->LineZoffset = 0.0; + ctx->PolygonZoffset = 0.0; + } } @@ -377,6 +384,13 @@ static void render_quad( GLcontext *ctx, GLuint v0, GLuint v1, else { (*ctx->Driver.QuadFunc)( ctx, v0, v1, v2, v3, pv ); } + + if (tricaps & DD_TRI_OFFSET) { + /* reset Z offsets now */ + ctx->PointZoffset = 0.0; + ctx->LineZoffset = 0.0; + ctx->PolygonZoffset = 0.0; + } } @@ -415,15 +429,16 @@ do { \ #define EDGEFLAG_POLY_TRI_PRE( i2, i1, i, pv) \ do { \ + eflag[i2] |= (eflag[i2] >> 2) & 1; \ eflag[i1] |= (eflag[i1] >> 2) & 1; \ eflag[i] |= (eflag[i] >> 2) & 2; \ } while (0) #define EDGEFLAG_POLY_TRI_POST( i2, i1, i, pv) \ do { \ - eflag[i2] = 0; \ + eflag[i2] &= ~(4|1); \ eflag[i1] &= ~(4|1); \ - eflag[i] &= ~(8|2); \ + eflag[i] &= ~(8|2); \ } while (0) @@ -503,7 +518,7 @@ do { \ (void) vlist; (void) eflag; (void) stipplecounter; #define TAG(x) x##_cull -#define INIT(x) FLUSH_PRIM(x) +#define INIT(x) if (x == GL_POLYGON) FLUSH_POLY(x); else FLUSH_PRIM(x) #define RESET_STIPPLE *stipplecounter = 0 #include "render_tmp.h" @@ -541,7 +556,7 @@ do { \ GLuint *stipplecounter = &VB->ctx->StippleCounter; \ (void) eflag; (void) stipplecounter; -#define INIT(x) FLUSH_PRIM(x); +#define INIT(x) if (x == GL_POLYGON) FLUSH_POLY(x); else FLUSH_PRIM(x) #define RESET_STIPPLE *stipplecounter = 0 #include "render_tmp.h" @@ -575,7 +590,7 @@ do { \ GLuint *stipplecounter = &VB->ctx->StippleCounter; \ (void) eflag; (void) stipplecounter; -#define INIT(x) FLUSH_PRIM(x); +#define INIT(x) if (x == GL_POLYGON) FLUSH_POLY(x); else FLUSH_PRIM(x) #define TAG(x) x##_clipped #define RESET_STIPPLE *stipplecounter = 0 @@ -633,9 +648,9 @@ setup_edgeflag( struct vertex_buffer *VB, case GL_POLYGON: if (flag[0]) flag[0] = 0x1; for (i = 1 ; i < n-1 ; i++) { - if (flag[i]) flag[i] = 0x1<<2; + if (flag[i]) flag[i] = 0x4; } - if (flag[i]) flag[i] = 0x3<<2; + if (flag[i]) flag[i] = 0x8; break; default: break; diff --git a/xc/extras/rman/contrib/bennett.txt b/xc/extras/rman/contrib/bennett.txt index 83c5464e3..b7f6e624e 100644 --- a/xc/extras/rman/contrib/bennett.txt +++ b/xc/extras/rman/contrib/bennett.txt @@ -3,7 +3,7 @@ *************** *** 1,5 **** --- 1,9 ---- - static char rcsid[] = "$Header: /home/ajax/dri-backup/xc/xc/extras/rman/contrib/bennett.txt,v 1.1.1.3 2000/09/23 20:47:59 alanh Exp $"; + static char rcsid[] = "$Header: /home/ajax/dri-backup/xc/xc/extras/rman/contrib/bennett.txt,v 1.2.10.1 2000/10/18 13:02:19 alanh Exp $"; + /* ELS: SearchDirs by "Edward L. Sutter" <els@sage.sage.att.com> */ + /* AB: HTMLHeader and HTMLFooter by Anne Bennett <anne@alcor.concordia.ca> */ diff --git a/xc/extras/rman/contrib/hman.pl b/xc/extras/rman/contrib/hman.pl index 40c46850b..3b42c1bd0 100755 --- a/xc/extras/rman/contrib/hman.pl +++ b/xc/extras/rman/contrib/hman.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl -w #!/citi/gtfd/mach/bin/perl -w ############### -# $Id: hman.pl,v 1.1.1.3 2000/09/23 20:47:59 alanh Exp $ +# $Id: hman.pl,v 1.2.10.1 2000/10/18 13:02:19 alanh Exp $ # $Source: /home/ajax/dri-backup/xc/xc/extras/rman/contrib/hman.pl,v $ ############################################ # TODO: diff --git a/xc/extras/rman/contrib/http-rman.c b/xc/extras/rman/contrib/http-rman.c index 6a88603d9..9d6f6ddd3 100644 --- a/xc/extras/rman/contrib/http-rman.c +++ b/xc/extras/rman/contrib/http-rman.c @@ -1,4 +1,4 @@ -/* $Id: http-rman.c,v 1.1.1.3 2000/09/23 20:47:59 alanh Exp $ +/* $Id: http-rman.c,v 1.2.10.1 2000/10/18 13:02:19 alanh Exp $ * * Name: * http-rman.c -- a rudimentary man-page HTTP server diff --git a/xc/extras/rman/rman.1 b/xc/extras/rman/rman.1 index a97b556f3..0a32bb949 100644 --- a/xc/extras/rman/rman.1 +++ b/xc/extras/rman/rman.1 @@ -266,4 +266,4 @@ University of California, Berkeley .br Computer Science Division .PP -Manual page last updated on $Date: 2000/09/23 20:47:45 $ +Manual page last updated on $Date: 2000/10/18 13:02:19 $ diff --git a/xc/extras/rman/rman.html b/xc/extras/rman/rman.html index 6ca56f64f..5618f1642 100644 --- a/xc/extras/rman/rman.html +++ b/xc/extras/rman/rman.html @@ -317,6 +317,6 @@ developed at the<BR> University of California, Berkeley<BR> Computer Science Division -<P>Manual page last updated on $Date: 2000/09/23 20:47:58 $ +<P>Manual page last updated on $Date: 2000/10/18 13:02:19 $ </BODY></HTML> diff --git a/xc/lib/GL/Imakefile b/xc/lib/GL/Imakefile index 240da6d39..cb4170d0e 100644 --- a/xc/lib/GL/Imakefile +++ b/xc/lib/GL/Imakefile @@ -3,6 +3,7 @@ XCOMM $XFree86: xc/lib/GL/Imakefile,v 1.31 2000/08/28 16:04:47 dawes Exp $ #include <Threads.tmpl> #define IHaveSubdirs + #define PassCDebugFlags #define DoNormalLib NormalLibGlx @@ -52,6 +53,7 @@ NormalLintTarget($(PROFSRC)) DRMPOBJS = dri/drm/profiled/?*.o DRMDONES = dri/drm/DONE + MESAOBJS = mesa/src/?*.o #ifdef i386Architecture ASM_OBJS = mesa/src/X86/common_x86asm.o \ mesa/src/X86/mmx_blend.o \ @@ -70,21 +72,27 @@ NormalLintTarget($(PROFSRC)) mesa/src/X86/3dnow_xform_raw4.o \ mesa/src/X86/vertex_3dnow.o #endif +#ifdef MesaUseKatmai + ASM_OBJS += mesa/src/X86/katmai_norm.o \ + mesa/src/X86/katmai_norm_raw.o \ + mesa/src/X86/katmai_xform_masked1.o \ + mesa/src/X86/katmai_xform_masked2.o \ + mesa/src/X86/katmai_xform_masked3.o \ + mesa/src/X86/katmai_xform_masked4.o \ + mesa/src/X86/katmai_xform_raw1.o \ + mesa/src/X86/katmai_xform_raw2.o \ + mesa/src/X86/katmai_xform_raw3.o \ + mesa/src/X86/katmai_xform_raw4.o \ + mesa/src/X86/vertex_katmai.o #endif -#ifdef i386Architecture - MESAARCHOBJS = mesa/src/X86/?*.o -MESAARCHUOBJS = mesa/src/X86/unshared/?*.o $(ASM_OBJS) -MESAARCHDOBJS = mesa/src/X86/debugger/?*.o $(ASM_OBJS) -MESAARCHPOBJS = mesa/src/X86/profiled/?*.o $(ASM_OBJS) -MESAARCHDONES = mesa/src/X86/DONE + MESAOBJS = mesa/src/?*.o mesa/src/X86/?*.o #endif - MESAOBJS = mesa/src/?*.o $(MESAARCHOBJS) - MESAUOBJS = mesa/src/unshared/?*.o $(MESAARCHUOBJS) - MESADOBJS = mesa/src/debugger/?*.o $(MESAARCHDOBJS) - MESAPOBJS = mesa/src/profiled/?*.o $(MESAARCHPOBJS) - MESADONES = mesa/src/DONE $(MESAARCHDONES) + MESAUOBJS = mesa/src/unshared/?*.o mesa/src/X86/unshared/?*.o $(ASM_OBJS) + MESADOBJS = mesa/src/debugger/?*.o mesa/src/X86/debugger/?*.o $(ASM_OBJS) + MESAPOBJS = mesa/src/profiled/?*.o mesa/src/X86/profiled/?*.o $(ASM_OBJS) + MESADONES = mesa/src/DONE mesa/src/X86/DONE DRIMESAOBJS = mesa/dri/?*.o DRIMESAUOBJS = mesa/dri/unshared/?*.o @@ -161,11 +169,11 @@ REQUIREDLIBS += -lglide3 -ldl MGAPOBJS = mesa/src/drv/mga/profiled/?*.o MGADONES = mesa/src/drv/mga/DONE - DRVOBJS = $(MGAOBJS) $(COMMONOBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS) - DRVUOBJS = $(MGAUOBJS) $(COMMONUOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS) - DRVDOBJS = $(MGADOBJS) $(COMMONDOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS) - DRVPOBJS = $(MGAPOBJS) $(COMMONPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS) - DRVDONES = $(MGADONES) $(COMMONDONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES) + DRVOBJS = $(MGAOBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS) + DRVUOBJS = $(MGAUOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS) + DRVDOBJS = $(MGADOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS) + DRVPOBJS = $(MGAPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS) + DRVDONES = $(MGADONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES) GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src mesa/src/drv/mga @@ -294,9 +302,9 @@ InstallSharedLibrary($(LIBNAME),$(SOREV),$(SHLIBDIR)) install:: MakeDir($(DESTDIR)$(SYSTEMUSRLIBDIR)) $(RM) $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so - $(LN) $(SHLIBDIR)/lib$(LIBNAME).so $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so + $(LN) $(SHLIBDIR)/lib$(LIBNAME).so $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so || true $(RM) $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so.1 - $(LN) $(SHLIBDIR)/lib$(LIBNAME).so.1 $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so.1 + $(LN) $(SHLIBDIR)/lib$(LIBNAME).so.1 $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so.1 || true #endif #endif #if DebugLibGlx diff --git a/xc/lib/GL/dri/XF86dri.c b/xc/lib/GL/dri/XF86dri.c index 1112bf9f2..44eac8b84 100644 --- a/xc/lib/GL/dri/XF86dri.c +++ b/xc/lib/GL/dri/XF86dri.c @@ -83,17 +83,27 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info) * * *****************************************************************************/ +#if 0 +#define TRACE(msg) printf("XF86DRI%s\n", msg); +#else +#define TRACE(msg) +#endif + + Bool XF86DRIQueryExtension (dpy, event_basep, error_basep) Display *dpy; int *event_basep, *error_basep; { XExtDisplayInfo *info = find_display (dpy); + TRACE("QueryExtension..."); if (XextHasExtension(info)) { *event_basep = info->codes->first_event; *error_basep = info->codes->first_error; + TRACE("QueryExtension... return True"); return True; } else { + TRACE("QueryExtension... return False"); return False; } } @@ -108,6 +118,7 @@ Bool XF86DRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion) xXF86DRIQueryVersionReply rep; xXF86DRIQueryVersionReq *req; + TRACE("QueryVersion..."); XF86DRICheckExtension (dpy, info, False); LockDisplay(dpy); @@ -117,6 +128,7 @@ Bool XF86DRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion) if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); + TRACE("QueryVersion... return False"); return False; } *majorVersion = rep.majorVersion; @@ -124,6 +136,7 @@ Bool XF86DRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion) *patchVersion = rep.patchVersion; UnlockDisplay(dpy); SyncHandle(); + TRACE("QueryVersion... return True"); return True; } @@ -136,6 +149,7 @@ Bool XF86DRIQueryDirectRenderingCapable(dpy, screen, isCapable) xXF86DRIQueryDirectRenderingCapableReply rep; xXF86DRIQueryDirectRenderingCapableReq *req; + TRACE("QueryDirectRenderingCapable..."); XF86DRICheckExtension (dpy, info, False); LockDisplay(dpy); @@ -146,11 +160,13 @@ Bool XF86DRIQueryDirectRenderingCapable(dpy, screen, isCapable) if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); + TRACE("QueryDirectRenderingCapable... return False"); return False; } *isCapable = rep.isCapable; UnlockDisplay(dpy); SyncHandle(); + TRACE("QueryDirectRenderingCapable... return True"); return True; } @@ -164,6 +180,7 @@ Bool XF86DRIOpenConnection(dpy, screen, hSAREA, busIdString) xXF86DRIOpenConnectionReply rep; xXF86DRIOpenConnectionReq *req; + TRACE("OpenConnection..."); XF86DRICheckExtension (dpy, info, False); LockDisplay(dpy); @@ -174,6 +191,7 @@ Bool XF86DRIOpenConnection(dpy, screen, hSAREA, busIdString) if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); + TRACE("OpenConnection... return False"); return False; } @@ -187,6 +205,7 @@ Bool XF86DRIOpenConnection(dpy, screen, hSAREA, busIdString) _XEatData(dpy, ((rep.busIdStringLength+3) & ~3)); UnlockDisplay(dpy); SyncHandle(); + TRACE("OpenConnection... return False"); return False; } _XReadPad(dpy, *busIdString, rep.busIdStringLength); @@ -195,6 +214,7 @@ Bool XF86DRIOpenConnection(dpy, screen, hSAREA, busIdString) } UnlockDisplay(dpy); SyncHandle(); + TRACE("OpenConnection... return True"); return True; } @@ -207,6 +227,7 @@ Bool XF86DRIAuthConnection(dpy, screen, magic) xXF86DRIAuthConnectionReq *req; xXF86DRIAuthConnectionReply rep; + TRACE("AuthConnection..."); XF86DRICheckExtension (dpy, info, False); LockDisplay(dpy); @@ -219,10 +240,12 @@ Bool XF86DRIAuthConnection(dpy, screen, magic) if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) { UnlockDisplay(dpy); SyncHandle(); + TRACE("AuthConnection... return False"); return False; } UnlockDisplay(dpy); SyncHandle(); + TRACE("AuthConnection... return True"); return True; } @@ -233,6 +256,8 @@ Bool XF86DRICloseConnection(dpy, screen) XExtDisplayInfo *info = find_display (dpy); xXF86DRICloseConnectionReq *req; + TRACE("CloseConnection..."); + XF86DRICheckExtension (dpy, info, False); LockDisplay(dpy); @@ -242,6 +267,7 @@ Bool XF86DRICloseConnection(dpy, screen) req->screen = screen; UnlockDisplay(dpy); SyncHandle(); + TRACE("CloseConnection... return True"); return True; } @@ -258,6 +284,7 @@ Bool XF86DRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, xXF86DRIGetClientDriverNameReply rep; xXF86DRIGetClientDriverNameReq *req; + TRACE("GetClientDriverName..."); XF86DRICheckExtension (dpy, info, False); LockDisplay(dpy); @@ -268,6 +295,7 @@ Bool XF86DRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); + TRACE("GetClientDriverName... return False"); return False; } @@ -278,6 +306,9 @@ Bool XF86DRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, if (rep.length) { if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) { _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3)); + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetClientDriverName... return False"); return False; } _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength); @@ -286,6 +317,7 @@ Bool XF86DRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, } UnlockDisplay(dpy); SyncHandle(); + TRACE("GetClientDriverName... return True"); return True; } @@ -300,6 +332,7 @@ Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext) xXF86DRICreateContextReply rep; xXF86DRICreateContextReq *req; + TRACE("CreateContext..."); XF86DRICheckExtension (dpy, info, False); LockDisplay(dpy); @@ -313,11 +346,13 @@ Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext) if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); + TRACE("CreateContext... return False"); return False; } *hHWContext = rep.hHWContext; UnlockDisplay(dpy); SyncHandle(); + TRACE("CreateContext... return True"); return True; } @@ -329,6 +364,7 @@ Bool XF86DRIDestroyContext(dpy, screen, context) XExtDisplayInfo *info = find_display (dpy); xXF86DRIDestroyContextReq *req; + TRACE("DestroyContext..."); XF86DRICheckExtension (dpy, info, False); LockDisplay(dpy); @@ -339,6 +375,7 @@ Bool XF86DRIDestroyContext(dpy, screen, context) req->context = context; UnlockDisplay(dpy); SyncHandle(); + TRACE("DestroyContext... return True"); return True; } @@ -352,6 +389,7 @@ Bool XF86DRICreateDrawable(dpy, screen, drawable, hHWDrawable) xXF86DRICreateDrawableReply rep; xXF86DRICreateDrawableReq *req; + TRACE("CreateDrawable..."); XF86DRICheckExtension (dpy, info, False); LockDisplay(dpy); @@ -363,11 +401,13 @@ Bool XF86DRICreateDrawable(dpy, screen, drawable, hHWDrawable) if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); + TRACE("CreateDrawable... return False"); return False; } *hHWDrawable = rep.hHWDrawable; UnlockDisplay(dpy); SyncHandle(); + TRACE("CreateDrawable... return True"); return True; } @@ -379,6 +419,7 @@ Bool XF86DRIDestroyDrawable(dpy, screen, drawable) XExtDisplayInfo *info = find_display (dpy); xXF86DRIDestroyDrawableReq *req; + TRACE("DestroyDrawable..."); XF86DRICheckExtension (dpy, info, False); LockDisplay(dpy); @@ -389,6 +430,7 @@ Bool XF86DRIDestroyDrawable(dpy, screen, drawable) req->drawable = drawable; UnlockDisplay(dpy); SyncHandle(); + TRACE("DestroyDrawable... return True"); return True; } @@ -419,6 +461,7 @@ Bool XF86DRIGetDrawableInfo(dpy, screen, drawable, xXF86DRIGetDrawableInfoReq *req; int total_rects; + TRACE("GetDrawableInfo..."); XF86DRICheckExtension (dpy, info, False); LockDisplay(dpy); @@ -432,6 +475,7 @@ Bool XF86DRIGetDrawableInfo(dpy, screen, drawable, { UnlockDisplay(dpy); SyncHandle(); + TRACE("GetDrawableInfo... return False"); return False; } *index = rep.drawableTableIndex; @@ -448,13 +492,21 @@ Bool XF86DRIGetDrawableInfo(dpy, screen, drawable, *numBackClipRects = rep.numBackClipRects; total_rects += *numBackClipRects; - if (rep.length != (SIZEOF(xXF86DRIGetDrawableInfoReply) - +#if 0 + /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks + * backwards compatibility (Because of the >> 2 shift) but the fix + * enables multi-threaded apps to work. + */ + if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) - SIZEOF(xGenericReply) + - total_rects * sizeof(XF86DRIClipRectRec))) { - _XEatData(dpy, rep.length); - return False; + total_rects * sizeof(XF86DRIClipRectRec)) + 3) & ~3) >> 2)) { + _XEatData(dpy, rep.length); + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDrawableInfo... return False"); + return False; } - +#endif if (*numClipRects) { int len = sizeof(XF86DRIClipRectRec) * (*numClipRects); @@ -478,6 +530,7 @@ Bool XF86DRIGetDrawableInfo(dpy, screen, drawable, UnlockDisplay(dpy); SyncHandle(); + TRACE("GetDrawableInfo... return True"); return True; } @@ -496,6 +549,7 @@ Bool XF86DRIGetDeviceInfo(dpy, screen, hFrameBuffer, xXF86DRIGetDeviceInfoReply rep; xXF86DRIGetDeviceInfoReq *req; + TRACE("GetDeviceInfo..."); XF86DRICheckExtension (dpy, info, False); LockDisplay(dpy); @@ -506,6 +560,7 @@ Bool XF86DRIGetDeviceInfo(dpy, screen, hFrameBuffer, if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); + TRACE("GetDeviceInfo... return False"); return False; } @@ -520,15 +575,20 @@ Bool XF86DRIGetDeviceInfo(dpy, screen, hFrameBuffer, *devPrivateSize = rep.devPrivateSize; if (rep.length) { - if (!(*pDevPrivate = (void *)Xcalloc(rep.length, 1))) { - _XEatData(dpy, ((rep.length+3) & ~3)); + if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) { + _XEatData(dpy, ((rep.devPrivateSize+3) & ~3)); + UnlockDisplay(dpy); + SyncHandle(); + TRACE("GetDeviceInfo... return False"); return False; } - _XRead(dpy, (char*)*pDevPrivate, rep.length); + _XRead(dpy, (char*)*pDevPrivate, rep.devPrivateSize); } else { *pDevPrivate = NULL; } + UnlockDisplay(dpy); SyncHandle(); + TRACE("GetDeviceInfo... return True"); return True; } diff --git a/xc/lib/GL/dri/drm/Imakefile b/xc/lib/GL/dri/drm/Imakefile index 42b5873cf..b1277e0bc 100644 --- a/xc/lib/GL/dri/drm/Imakefile +++ b/xc/lib/GL/dri/drm/Imakefile @@ -43,7 +43,8 @@ LinkSourceFile(drm.h,$(XF86OSSRC)/$(OS_SUBDIR2)/drm/kernel) LinkSourceFile(i810_drm.h,$(XF86OSSRC)/$(OS_SUBDIR2)/drm/kernel) LinkSourceFile(mga_drm.h,$(XF86OSSRC)/$(OS_SUBDIR2)/drm/kernel) LinkSourceFile(r128_drm.h,$(XF86OSSRC)/$(OS_SUBDIR2)/drm/kernel) -LinkSourceFile(sis_drm_public.h,$(XF86OSSRC)/$(OS_SUBDIR2)/drm/kernel) +LinkSourceFile(radeon_drm.h,$(XF86OSSRC)/$(OS_SUBDIR2)/drm/kernel) +LinkSourceFile(sis_drm.h,$(XF86OSSRC)/$(OS_SUBDIR2)/drm/kernel) #include <Library.tmpl> diff --git a/xc/lib/GL/glx/glxext.c b/xc/lib/GL/glx/glxext.c index 2367f49a0..262e91059 100644 --- a/xc/lib/GL/glx/glxext.c +++ b/xc/lib/GL/glx/glxext.c @@ -29,10 +29,10 @@ */ #include "packrender.h" -#include <stdio.h> #include <Xext.h> #include <extutil.h> #include <assert.h> +#include <stdio.h> #include "indirect_init.h" #include "glapi.h" #ifdef XTHREADS @@ -72,7 +72,7 @@ static __GLapi *IndirectAPI = NULL; /* - * Current context management + * Current context management and locking */ #if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS) @@ -107,6 +107,11 @@ void __glXSetCurrentContext(__GLXcontext *c) xthread_set_specific(ContextTSD, c); } + +/* Used by the __glXLock() and __glXUnlock() macros */ +xmutex_rec __glXmutex; +xmutex_rec __glXSwapBuffersMutex; + #else /* not thread safe */ @@ -451,6 +456,18 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy) XEDataObject dataObj; int major, minor; +#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS) + { + static int firstCall = 1; + if (firstCall) { + /* initialize the GLX mutexes */ + xmutex_init(&__glXmutex); + xmutex_init(&__glXSwapBuffersMutex); + firstCall = 0; + } + } +#endif + /* The one and only long long lock */ __glXLock(); @@ -510,8 +527,16 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy) ** Note: This _must_ be done before calling any other DRI routines ** (e.g., those called in AllocAndFetchScreenConfigs). */ - dpyPriv->driDisplay.private = - driCreateDisplay(dpy, &dpyPriv->driDisplay); + if (getenv("LIBGL_ALWAYS_INDIRECT")) { + /* Assinging zero here assures we'll never go direct */ + dpyPriv->driDisplay.private = 0; + dpyPriv->driDisplay.destroyDisplay = 0; + dpyPriv->driDisplay.createScreen = 0; + } + else { + dpyPriv->driDisplay.private = + driCreateDisplay(dpy, &dpyPriv->driDisplay); + } #endif if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) { @@ -811,6 +836,7 @@ Bool glXMakeCurrent(Display *dpy, GLXDrawable draw, GLXContext gc) } } else { #endif + _glapi_check_multithread(); /* Send a glXMakeCurrent request to bind the new context. */ LockDisplay(dpy); GetReq(GLXMakeCurrent,req); @@ -820,14 +846,15 @@ Bool glXMakeCurrent(Display *dpy, GLXDrawable draw, GLXContext gc) req->context = gc ? gc->xid : None; req->oldContextTag = oldGC->currentContextTag; bindReturnValue = _XReply(dpy, (xReply*) &reply, 0, False); + UnlockDisplay(dpy); #ifdef GLX_DIRECT_RENDERING } #endif + if (!bindReturnValue) { /* The make current failed. */ if (!gc->isDirect) { - UnlockDisplay(dpy); SyncHandle(); } @@ -884,6 +911,9 @@ Bool glXMakeCurrent(Display *dpy, GLXDrawable draw, GLXContext gc) ** request, and cannot adhere to the "no-op" behavior. */ } + else { + UnlockDisplay(dpy); + } oldGC->currentContextTag = reply.contextTag; } return GL_FALSE; diff --git a/xc/lib/GL/mesa/dri/dri_mesa.c b/xc/lib/GL/mesa/dri/dri_mesa.c index f72ce375a..91daf4218 100644 --- a/xc/lib/GL/mesa/dri/dri_mesa.c +++ b/xc/lib/GL/mesa/dri/dri_mesa.c @@ -132,6 +132,19 @@ static void __driMesaRemoveDrawable(__DRIdrawable *pdraw) } } +static __DRIdrawable *__driMesaFindUnboundDrawable(void) +{ + GLXDrawable draw; + __DRIdrawable *pdraw; + + while (drmHashFirst(drawHash, &draw, (void **)&pdraw)) { + __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private; + if (!pdp->refcount) + return pdraw; + } + return NULL; +} + /*****************************************************************/ static void driMesaInitAPI(__MesaAPI *MesaAPI) @@ -204,8 +217,8 @@ static Bool driMesaUnbindContext(Display *dpy, int scrn, */ /* Delete drawable if no longer referenced by any contexts */ - (*pdraw->destroyDrawable)(dpy, pdraw->private); __driMesaRemoveDrawable(pdraw); + (*pdraw->destroyDrawable)(dpy, pdraw->private); Xfree(pdraw); #endif } @@ -285,7 +298,7 @@ static Bool driMesaBindContext(Display *dpy, int scrn, DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); } - /* Bind Mesa's drawable to Mesa's context */ + /* Call device-specific MakeCurrent */ (*psp->MesaAPI.MakeCurrent)(pcp, pdp, pdp); return GL_TRUE; @@ -293,6 +306,13 @@ static Bool driMesaBindContext(Display *dpy, int scrn, /*****************************************************************/ +/* + * This function basically updates the __DRIdrawablePrivate struct's + * cliprect information by calling XF86DRIGetDrawableInfo(). + * This is usually called by a macro which compares the + * __DRIdrwablePrivate pStamp and lastStamp values. If the values + * are different that means we have to update the clipping info. + */ void driMesaUpdateDrawableInfo(Display *dpy, int scrn, __DRIdrawablePrivate *pdp) { @@ -318,7 +338,6 @@ void driMesaUpdateDrawableInfo(Display *dpy, int scrn, Xfree(pdp->pBackClipRects); } - DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); if (!XF86DRIGetDrawableInfo(dpy, scrn, pdp->draw, @@ -533,11 +552,14 @@ static void driMesaDestroyContext(Display *dpy, int scrn, void *private) reference this drawable, so we can destroy the drawable and remove it from the hash table */ pdraw = __driMesaFindDrawable(pdp->draw); - (*pdraw->destroyDrawable)(dpy, pdraw->private); __driMesaRemoveDrawable(pdraw); + (*pdraw->destroyDrawable)(dpy, pdraw->private); Xfree(pdraw); } } + while ((pdraw = __driMesaFindUnboundDrawable()) != NULL) + __driMesaRemoveDrawable(pdraw); + (void)XF86DRIDestroyContext(dpy, scrn, pcp->contextID); (*pcp->driScreenPriv->MesaAPI.DestroyContext)(pcp); gl_destroy_context(pcp->mesaContext); diff --git a/xc/lib/GL/mesa/src/drv/i810/Imakefile b/xc/lib/GL/mesa/src/drv/i810/Imakefile index 0b0bad1b3..5f5815a17 100644 --- a/xc/lib/GL/mesa/src/drv/i810/Imakefile +++ b/xc/lib/GL/mesa/src/drv/i810/Imakefile @@ -25,7 +25,6 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL MESA_INCLUDES = -I. -I.. -I../../include \ -I../../../../dri/drm - DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) @@ -229,7 +228,7 @@ MESA_INCLUDES = -I. -I.. -I../../include \ MMX_OBJS = ../../X86/mmx_blend.o XCOMM Disabling 3Dnow code for the time being. -#if 0 +#ifdef MesaUse3DNow 3DNOW_SRCS = ../../X86/3dnow.c \ ../../X86/3dnow_norm_raw.S \ ../../X86/3dnow_xform_masked1.S \ diff --git a/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c b/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c index 5934b9ebc..035e78de3 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c @@ -395,9 +395,6 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, */ ctx->TriangleCaps |= DD_CLIP_FOG_COORD; - ctx->Shared->DefaultD[2][0].DriverData = 0; - ctx->Shared->DefaultD[2][1].DriverData = 0; - if (ctx->VB) i810DDRegisterVB( ctx->VB ); diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tex.c b/xc/lib/GL/mesa/src/drv/i810/i810tex.c index 4bdeb4847..299a2ce86 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810tex.c +++ b/xc/lib/GL/mesa/src/drv/i810/i810tex.c @@ -734,7 +734,7 @@ static void i810UpdateTex0State( GLcontext *ctx ) MA_OP_ARG1 ); - if (!(ctx->Texture.Enabled & 0xf) || !tObj || !tObj->Complete) { + if (!(ctx->Texture.ReallyEnabled & 0xf) || !tObj || !tObj->Complete) { return; } @@ -977,7 +977,7 @@ static void i810UpdateTex1State( GLcontext *ctx ) MA_UPDATE_OP | MA_OP_ARG1 ); - if (!(ctx->Texture.Enabled & 0xf0) || !tObj || !tObj->Complete) { + if (!(ctx->Texture.ReallyEnabled & 0xf0) || !tObj || !tObj->Complete) { return; } diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tris.c b/xc/lib/GL/mesa/src/drv/i810/i810tris.c index 2b55a8d7b..b05affec2 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810tris.c +++ b/xc/lib/GL/mesa/src/drv/i810/i810tris.c @@ -98,7 +98,7 @@ void i810DDTrifuncInit() -#define ALL_FALLBACK (DD_MULTIDRAW | DD_SELECT | DD_FEEDBACK) +#define ALL_FALLBACK (DD_MULTIDRAW | DD_SELECT | DD_FEEDBACK | DD_STENCIL) #define POINT_FALLBACK (ALL_FALLBACK) #define LINE_FALLBACK (ALL_FALLBACK | DD_LINE_STIPPLE) #define TRI_FALLBACK (ALL_FALLBACK | DD_TRI_UNFILLED) diff --git a/xc/lib/GL/mesa/src/drv/i810/i810vb.c b/xc/lib/GL/mesa/src/drv/i810/i810vb.c index 5c6e1455e..37514dd8d 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810vb.c +++ b/xc/lib/GL/mesa/src/drv/i810/i810vb.c @@ -24,14 +24,14 @@ */ /* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810vb.c,v 1.5 2000/08/28 02:43:12 tsi Exp $ */ +#include <stdio.h> +#include <stdlib.h> #include "i810context.h" #include "i810vb.h" #include "i810log.h" - +#include "mem.h" #include "stages.h" -#include <stdio.h> -#include <stdlib.h> #define TEX0 { \ @@ -265,10 +265,10 @@ void i810ChooseRasterSetupFunc(GLcontext *ctx) imesa->vertsize = 8; imesa->Setup[I810_CTXREG_VF] = I810_VFMT_T0; - if (ctx->Texture.Enabled & 0xf) + if (ctx->Texture.ReallyEnabled & 0xf) funcindex |= I810_TEX0_BIT; - if (ctx->Texture.Enabled & 0xf0) { + if (ctx->Texture.ReallyEnabled & 0xf0) { funcindex |= I810_TEX1_BIT; imesa->vertsize = 10; imesa->Setup[I810_CTXREG_VF] = I810_VFMT_T0T1; @@ -387,8 +387,8 @@ void i810DDResizeVB( struct vertex_buffer *VB, GLuint size ) exit(1); } - free( VB->ClipMask ); - VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size); + ALIGN_FREE( VB->ClipMask ); + VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 4); if (!VB->ClipMask) { fprintf(stderr, "i810-glx: out of memory !\n"); exit(1); @@ -429,8 +429,8 @@ void i810DDRegisterVB( struct vertex_buffer *VB ) exit(1); } - free( VB->ClipMask ); - VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size); + ALIGN_FREE( VB->ClipMask ); + VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 4); if (!VB->ClipMask) { fprintf(stderr, "i810-glx: out of memory !\n"); exit(1); diff --git a/xc/lib/GL/mesa/src/drv/mga/Imakefile b/xc/lib/GL/mesa/src/drv/mga/Imakefile index 90ccceecf..1fdd283a7 100644 --- a/xc/lib/GL/mesa/src/drv/mga/Imakefile +++ b/xc/lib/GL/mesa/src/drv/mga/Imakefile @@ -34,7 +34,6 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL MESA_INCLUDES = -I. -I.. -I../../include \ -I../../../../dri/drm - DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) @@ -56,17 +55,15 @@ MESA_INCLUDES = -I. -I.. -I../../include \ ../../../../dri/drm/xf86drmSL.o - MGASRCS = mgaclear.c mgacnvtex.c mgadd.c \ - mgafastpath.c mgaeltpath.c \ - mgapipeline.c \ - mgaspan.c mgastate.c mgatex.c \ - mgatris.c mgavb.c mgaioctl.c mga_xmesa.c mgabuffers.c + MGASRCS = mgatexcnv.c mgadd.c mgafastpath.c \ + mgaeltpath.c mgapipeline.c mgaspan.c mgastate.c \ + mgatex.c mgatexmem.c mgatris.c mgavb.c mgaioctl.c \ + mga_xmesa.c mgabuffers.c - MGAOBJS = mgaclear.o mgacnvtex.o mgadd.o \ - mgafastpath.o mgaeltpath.o \ - mgapipeline.o \ - mgaspan.o mgastate.o mgatex.o \ - mgatris.o mgavb.o mgaioctl.o mga_xmesa.o mgabuffers.o + MGAOBJS = mgatexcnv.o mgadd.o mgafastpath.o \ + mgaeltpath.o mgapipeline.o mgaspan.o mgastate.o \ + mgatex.o mgatexmem.o mgatris.o mgavb.o mgaioctl.o \ + mga_xmesa.o mgabuffers.o MESASRCS = ../../aatriangle.c \ ../../accum.c \ @@ -279,7 +276,7 @@ MESA_INCLUDES = -I. -I.. -I../../include \ OBJS = $(LOOBJS) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) $(ASMOBJS) \ $(COMMONOBJS) $(MGAOBJS) $(HIOBJS) -REQUIREDLIBS += -lm +REQUIREDLIBS += -lm #if !GlxBuiltInMga REQUIREDLIBS += -L../../../.. -lGL -L../../../../../X11 -lX11 #endif diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c index edcad5800..7d8da52da 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c @@ -44,6 +44,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "matrix.h" #include "mmath.h" #include "simple_list.h" +#include "mem.h" #include "mgadd.h" #include "mgastate.h" @@ -76,7 +77,6 @@ int MGA_DEBUG = (0 static mgaContextPtr mgaCtx = 0; -mgaGlx_t mgaglx; /* These functions are accessed externally to the driver: * @@ -99,6 +99,9 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) mgaScreenPrivate *mgaScreen; MGADRIPtr serverInfo = (MGADRIPtr)sPriv->pDevPriv; + if (MGA_DEBUG&DEBUG_VERBOSE_DRI) + fprintf(stderr, "XMesaInitDriver\n"); + /* Check the DRI version */ { int major, minor, patch; @@ -123,27 +126,23 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) } /* Check that the DRM driver version is compatible */ - if (sPriv->drmMajor != 1 || + if (sPriv->drmMajor != 2 || sPriv->drmMinor != 0 || sPriv->drmPatch < 0) { char msg[1000]; - sprintf(msg, "MGA DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch); + sprintf(msg, "MGA DRI driver expected DRM driver version 2.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch); __driMesaMessage(msg); return GL_FALSE; } /* Allocate the private area */ - mgaScreen = (mgaScreenPrivate *)Xmalloc(sizeof(mgaScreenPrivate)); + mgaScreen = (mgaScreenPrivate *)MALLOC(sizeof(mgaScreenPrivate)); if (!mgaScreen) return GL_FALSE; mgaScreen->sPriv = sPriv; sPriv->private = (void *)mgaScreen; - /* - fprintf(stderr, "serverInfo->chipset: %d\n", serverInfo->chipset); - */ - if (serverInfo->chipset != MGA_CARD_TYPE_G200 && serverInfo->chipset != MGA_CARD_TYPE_G400) { XFree(mgaScreen); @@ -182,12 +181,6 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) mgaScreen->textureOffset[MGA_AGP_HEAP] = (serverInfo->agpTextureOffset | PDEA_pagpxfer_enable | 1); - /* - fprintf(stderr, "CARD texture size %x, granul %d --> %x\n", - serverInfo->textureSize, serverInfo->logTextureGranularity, - 1<<serverInfo->logTextureGranularity); - */ - mgaScreen->textureSize[MGA_CARD_HEAP] = serverInfo->textureSize; mgaScreen->textureSize[MGA_AGP_HEAP] = serverInfo->agpTextureSize; @@ -208,12 +201,6 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) */ mgaScreen->dmaOffset = serverInfo->agpBufferOffset; - /* - fprintf(stderr, "\n\n\nbackOffset: %x pitch %x\n", - mgaScreen->backOffset, - mgaScreen->backPitch); - */ - mgaScreen->bufs = drmMapBufs(sPriv->fd); if (!mgaScreen->bufs) { /*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/ @@ -222,10 +209,6 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) return GL_FALSE; } - /* Other mgaglx stuff, too?? - */ - memset(&mgaglx, 0, sizeof(mgaglx)); - mgaDDFastPathInit(); mgaDDEltPathInit(); mgaDDTrifuncInit(); @@ -240,6 +223,10 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) void XMesaResetDriver(__DRIscreenPrivate *sPriv) { mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *) sPriv->private; + + if (MGA_DEBUG&DEBUG_VERBOSE_DRI) + fprintf(stderr, "XMesaResetDriver\n"); + /*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/ Xfree(mgaScreen); sPriv->private = NULL; @@ -251,6 +238,9 @@ GLvisual *XMesaCreateVisual(Display *dpy, const XVisualInfo *visinfo, const __GLXvisualConfig *config) { + if (MGA_DEBUG&DEBUG_VERBOSE_DRI) + fprintf(stderr, "XMesaCreateVisual\n"); + /* Drivers may change the args to _mesa_create_visual() in order to * setup special visuals. */ @@ -282,9 +272,11 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private; drm_mga_sarea_t *saPriv=(drm_mga_sarea_t*)(((char*)sPriv->pSAREA)+ sizeof(XF86DRISAREARec)); - /*fprintf(stderr, "XMesaCreateContext\n");*/ - mmesa = (mgaContextPtr)Xcalloc(sizeof(mgaContext), 1); + if (MGA_DEBUG&DEBUG_VERBOSE_DRI) + fprintf(stderr, "XMesaCreateContext\n"); + + mmesa = (mgaContextPtr)CALLOC(sizeof(mgaContext)); if (!mmesa) { return GL_FALSE; } @@ -310,7 +302,6 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, make_empty_list(&mmesa->TexObjList[i]); } - /* Set the maximum texture size small enough that we can guarentee * that both texture units can bind a maximal texture and have them * on the card at once. @@ -333,11 +324,37 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, } } - if (mgaScreen->cpp == 2) - mmesa->depth_scale = 1.0/(GLdouble)0xffff; - else - mmesa->depth_scale = 1.0/(GLdouble)0xffffffff; - + mmesa->hw_stencil = mesaVis->StencilBits && mesaVis->DepthBits == 24; + +/* fprintf(stderr, */ +/* "mesaVis->DepthBits: %d " */ +/* "mmesa->glCtx->Visual->DepthBits: %d " */ +/* "mmesa->glCtx->Visual->DepthMax: %x\n", */ +/* mesaVis->DepthBits, */ +/* ctx->Visual->DepthBits, */ +/* ctx->Visual->DepthMax); */ + + switch (mesaVis->DepthBits) { + case 16: + mmesa->depth_scale = 1.0/(GLdouble)0xffff; + mmesa->depth_clear_mask = ~0; + mmesa->ClearDepth = 0xffff; + break; + case 24: + mmesa->depth_scale = 1.0/(GLdouble)0xffffff; + if (mmesa->hw_stencil) { + mmesa->depth_clear_mask = 0xffffff00; + mmesa->stencil_clear_mask = 0x000000ff; + } else + mmesa->depth_clear_mask = ~0; + mmesa->ClearDepth = 0xffffff00; + break; + case 32: + mmesa->depth_scale = 1.0/(GLdouble)0xffffffff; + mmesa->depth_clear_mask = ~0; + mmesa->ClearDepth = 0xffffffff; + break; + }; mmesa->renderindex = -1; /* impossible value */ @@ -372,9 +389,6 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, */ ctx->TriangleCaps |= DD_CLIP_FOG_COORD; - ctx->Shared->DefaultD[2][0].DriverData = 0; - ctx->Shared->DefaultD[2][1].DriverData = 0; - if (ctx->VB) mgaDDRegisterVB( ctx->VB ); @@ -395,17 +409,11 @@ void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) { mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate; - if (mmesa) { -/* mgaTextureObjectPtr next_t, t; */ - -/* foreach_s (t, next_t, &(mmesa->TexObjList)) */ -/* mgaDestroyTexObj(mmesa, t); */ - -/* foreach_s (t, next_t, &(mmesa->SwappedOut)) */ -/* mgaDestroyTexObj(mmesa, t); */ + if (MGA_DEBUG&DEBUG_VERBOSE_DRI) + fprintf(stderr, "XMesaDestroyContext\n"); + if (mmesa) { Xfree(mmesa); - driContextPriv->driverPrivate = NULL; } } @@ -416,6 +424,9 @@ GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, __DRIdrawablePrivate *driDrawPriv, GLvisual *mesaVis) { + if (MGA_DEBUG&DEBUG_VERBOSE_DRI) + fprintf(stderr, "XMesaCreateWindowBuffer\n"); + return gl_create_framebuffer(mesaVis, GL_FALSE, /* software depth buffer? */ mesaVis->StencilBits > 0, @@ -480,9 +491,11 @@ GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, gl_make_current2(mgaCtx->glCtx, driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer); - mgaCtx->driDrawable = driDrawPriv; - mgaCtx->dirty = ~0; - mgaCtx->dirty_cliprects = (MGA_FRONT|MGA_BACK); + if (mgaCtx->driDrawable != driDrawPriv) { + mgaCtx->driDrawable = driDrawPriv; + mgaCtx->dirty = ~0; + mgaCtx->dirty_cliprects = (MGA_FRONT|MGA_BACK); + } if (!mgaCtx->glCtx->Viewport.Width) gl_Viewport(mgaCtx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h); @@ -531,4 +544,5 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags ) + #endif diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h index 013c004f5..2e9877eb2 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h +++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h @@ -50,7 +50,7 @@ typedef struct { char *map; } mgaRegion, *mgaRegionPtr; -typedef struct { +typedef struct mga_screen_private_s { int chipset; int width; @@ -88,7 +88,7 @@ typedef struct { } mgaScreenPrivate; -#include "mgalib.h" +#include "mgacontext.h" extern void mgaGetLock( mgaContextPtr mmesa, GLuint flags ); extern void mgaEmitHwStateLocked( mgaContextPtr mmesa ); diff --git a/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c index da288e3c9..d37027473 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c @@ -34,7 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <stdio.h> -#include "mgalib.h" +#include "mgacontext.h" #include "mgabuffers.h" #include "mgastate.h" #include "mgaioctl.h" @@ -88,37 +88,29 @@ static void mgaUpdateRectsFromSarea( mgaContextPtr mmesa ) if (sarea->exported_buffers & MGA_BACK) { - XF86DRIClipRectPtr boxes = - (XF86DRIClipRectPtr)malloc( sarea->exported_nback * sizeof(*boxes) ); - - if (driDrawable->pBackClipRects) - free(driDrawable->pBackClipRects); driDrawable->numBackClipRects = sarea->exported_nback; - driDrawable->pBackClipRects = boxes; + driDrawable->pBackClipRects = mmesa->tmp_boxes[0]; top = sarea->exported_nback; for (i = 0 ; i < top ; i++) - boxes[i] = *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]); + driDrawable->pBackClipRects[i] = + *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]); } if (sarea->exported_buffers & MGA_FRONT) { int start = top; - XF86DRIClipRectPtr boxes = - (XF86DRIClipRectPtr)malloc( sarea->exported_nfront * sizeof(*boxes) ); - - if (driDrawable->pClipRects) - free(driDrawable->pClipRects); driDrawable->numClipRects = sarea->exported_nfront; - driDrawable->pClipRects = boxes; + driDrawable->pClipRects = mmesa->tmp_boxes[1]; top += sarea->exported_nfront; for ( ; i < top ; i++) - boxes[i-start] = *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]); - + driDrawable->pClipRects[i-start] = + *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]); + } @@ -223,7 +215,8 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers ) */ if (0) printSareaRects(mmesa); - if (sarea->exported_drawable == driDrawable->draw && + if (0 && + sarea->exported_drawable == driDrawable->draw && (sarea->exported_buffers & buffers) == buffers) { mgaUpdateRectsFromSarea( mmesa ); diff --git a/xc/lib/GL/mesa/src/drv/mga/mgadd.c b/xc/lib/GL/mesa/src/drv/mga/mgadd.c index 70e53efa8..0e89a928f 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgadd.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgadd.c @@ -35,10 +35,8 @@ #include <stdlib.h> #include "mm.h" -#include "mgalib.h" -#include "mgaclear.h" +#include "mgacontext.h" #include "mgadd.h" -#include "mgalog.h" #include "mgastate.h" #include "mgaspan.h" #include "mgatex.h" @@ -74,24 +72,28 @@ static const GLubyte *mgaDDGetString( GLcontext *ctx, GLenum name ) static GLint mgaGetParameteri(const GLcontext *ctx, GLint param) { - switch (param) { - case DD_HAVE_HARDWARE_FOG: - return 1; - default: - mgaError("mgaGetParameteri(): unknown parameter!\n"); - return 0; - } + switch (param) { + case DD_HAVE_HARDWARE_FOG: + return 1; + default: + fprintf(stderr, "mgaGetParameteri(): unknown parameter!\n"); + return 0; + } } static void mgaBufferSize(GLcontext *ctx, GLuint *width, GLuint *height) { mgaContextPtr mmesa = MGA_CONTEXT(ctx); - -/* LOCK_HARDWARE( mmesa ); */ + + /* Need to lock to make sure the driDrawable is uptodate. This + * information is used to resize Mesa's software buffers, so it has + * to be correct. + */ + LOCK_HARDWARE( mmesa ); *width = mmesa->driDrawable->w; *height = mmesa->driDrawable->h; -/* UNLOCK_HARDWARE( mmesa ); */ + UNLOCK_HARDWARE( mmesa ); } void mgaDDExtensionsInit( GLcontext *ctx ) @@ -104,8 +106,6 @@ void mgaDDExtensionsInit( GLcontext *ctx ) */ if (1 || !MGA_IS_G400(MGA_CONTEXT(ctx))) { - gl_extensions_disable( ctx, "GL_EXT_multitexture" ); - gl_extensions_disable( ctx, "GL_SGIS_multitexture" ); gl_extensions_disable( ctx, "GL_ARB_multitexture" ); } @@ -141,10 +141,6 @@ void mgaDDExtensionsInit( GLcontext *ctx ) - - - - void mgaDDInitDriverFuncs( GLcontext *ctx ) { ctx->Driver.GetBufferSize = mgaBufferSize; diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c b/xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c index b0db7dba3..3dcfa5eed 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c @@ -32,7 +32,7 @@ #include "mmath.h" #include "xform.h" -#include "mgalib.h" +#include "mgacontext.h" #include "mgapipeline.h" #include "mgatris.h" #include "mgastate.h" diff --git a/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c b/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c index ea12c20b4..ad69cf8f6 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c @@ -31,7 +31,7 @@ #include "vertices.h" #include "mmath.h" -#include "mgalib.h" +#include "mgacontext.h" #include "mgapipeline.h" #include "mgatris.h" #include "mgastate.h" @@ -487,8 +487,10 @@ void mgaDDFastPath( struct vertex_buffer *VB ) struct mga_fast_tab *tab = &mgaFastTab[mmesa->setupindex & VALID_SETUP]; GLuint do_cliptest = 1; + gl_prepare_arrays_cva( VB ); /* still need this */ +#if 1 if (gl_reduce_prim[prim] == GL_TRIANGLES && VB->Count < (MGA_DMA_BUF_SZ / 48) && (ctx->ModelProjectMatrix.flags & (MAT_FLAG_GENERAL| @@ -498,6 +500,7 @@ void mgaDDFastPath( struct vertex_buffer *VB ) mgaDDEltPath( VB ); return; } +#endif /* Reserve enough space for the pathological case. */ diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c index 059284405..8dcb8f988 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c @@ -7,11 +7,10 @@ #include "dd.h" #include "mm.h" -#include "mgalib.h" +#include "mgacontext.h" #include "mgadd.h" #include "mgastate.h" #include "mgatex.h" -#include "mgalog.h" #include "mgavb.h" #include "mgatris.h" #include "mgabuffers.h" @@ -55,6 +54,7 @@ static void mga_iload_dma_ioctl(mgaContextPtr mmesa, int mgaUpdateLock( mgaContextPtr mmesa, drmLockFlags flags ) { drm_lock_t lock; + int retcode; lock.flags = 0; @@ -67,13 +67,15 @@ int mgaUpdateLock( mgaContextPtr mmesa, drmLockFlags flags ) if (flags & DRM_LOCK_FLUSH) lock.flags |= _DRM_LOCK_FLUSH; if (flags & DRM_LOCK_FLUSH_ALL) lock.flags |= _DRM_LOCK_FLUSH_ALL; - + if (!lock.flags) return 0; - if(ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH, &lock)) { + retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH, &lock); + if(retcode != 0) { fprintf(stderr, "Lockupdate failed\n"); - return -1; + if(retcode == EACCES) exit(1); + else return -1; } if(flags & DRM_LOCK_QUIESCENT) @@ -136,10 +138,10 @@ drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa ) if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "drmDMA (get) returns size[0] 0x%x idx[0] %d\n" - "dma_buffer now: buf idx: %d size: %d used: %d\n", + "dma_buffer now: buf idx: %d size: %d used: %d addr %p\n", dma.request_sizes[0], dma.request_list[0], buf->idx, buf->total, - buf->used); + buf->used, buf->address); if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "finished getbuffer\n"); @@ -155,7 +157,6 @@ GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all, { mgaContextPtr mmesa = MGA_CONTEXT( ctx ); __DRIdrawablePrivate *dPriv = mmesa->driDrawable; - const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask); drm_mga_clear_t clear; int retcode; int i; @@ -165,30 +166,40 @@ GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all, clear.flags = 0; clear.clear_color = mmesa->ClearColor; + clear.clear_depth = 0; + clear.clear_depth_mask = 0; - if (mmesa->mgaScreen->cpp == 2) - clear.clear_depth = ctx->Depth.Clear * (GLdouble)0xffff; - else { - clear.clear_depth = ctx->Depth.Clear * (GLdouble)0xffffffff; - } FLUSH_BATCH( mmesa ); - if ((mask & DD_FRONT_LEFT_BIT) && colorMask == ~0) { + if (mask & DD_FRONT_LEFT_BIT) { clear.flags |= MGA_FRONT; + clear.clear_color_mask = mmesa->Setup[MGA_CTXREG_PLNWT]; mask &= ~DD_FRONT_LEFT_BIT; } - if ((mask & DD_BACK_LEFT_BIT) && colorMask == ~0) { + if (mask & DD_BACK_LEFT_BIT) { clear.flags |= MGA_BACK; + clear.clear_color_mask = mmesa->Setup[MGA_CTXREG_PLNWT]; mask &= ~DD_BACK_LEFT_BIT; } if ((mask & DD_DEPTH_BIT) && ctx->Depth.Mask) { clear.flags |= MGA_DEPTH; + clear.clear_depth_mask |= mmesa->depth_clear_mask; + clear.clear_depth = (mmesa->ClearDepth & + mmesa->depth_clear_mask); mask &= ~DD_DEPTH_BIT; } + if ((mask & DD_STENCIL_BIT) && mmesa->hw_stencil) { + clear.flags |= MGA_DEPTH; + clear.clear_depth_mask |= mmesa->stencil_clear_mask; + clear.clear_depth |= (ctx->Stencil.Clear & + mmesa->stencil_clear_mask); + mask &= ~DD_STENCIL_BIT; + } + if (!clear.flags) return mask; @@ -267,6 +278,8 @@ GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all, } +int nrswaps; + /* @@ -278,7 +291,6 @@ void mgaSwapBuffers( mgaContextPtr mmesa ) XF86DRIClipRectPtr pbox; int nbox; drm_mga_swap_t swap; - static int nrswaps; int retcode; int i; int tmp; @@ -312,12 +324,16 @@ void mgaSwapBuffers( mgaContextPtr mmesa ) if (0) fprintf(stderr, "DRM_IOCTL_MGA_SWAP\n"); +#if 1 if((retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_SWAP, &swap))) { printf("send swap retcode = %d\n", retcode); exit(1); } +#else + mgaUpdateLock( mmesa, DRM_LOCK_FLUSH ); +#endif - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) + if (0) fprintf(stderr, "finished swap %d\n", ++nrswaps); } @@ -525,10 +541,10 @@ void mgaFlushElts( mgaContextPtr mmesa ) } -mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ) +GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ) { int bytes = dwords * 4; - mgaUI32 *head; + GLuint *head; if (!mmesa->vertex_dma_buffer) { LOCK_HARDWARE( mmesa ); @@ -546,7 +562,7 @@ mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ) UNLOCK_HARDWARE( mmesa ); } - head = (mgaUI32 *)((char *)mmesa->vertex_dma_buffer->address + + head = (GLuint *)((char *)mmesa->vertex_dma_buffer->address + mmesa->vertex_dma_buffer->used); mmesa->vertex_dma_buffer->used += bytes; @@ -565,7 +581,10 @@ void mgaFireILoadLocked( mgaContextPtr mmesa, if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "mgaFireILoad idx %d ofs 0x%x length %d\n", mmesa->iload_buffer->idx, (int)offset, (int)length ); - + + /* HACK + */ + mgaUpdateLock( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH); mga_iload_dma_ioctl( mmesa, offset, length ); } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h index 0aafb1e37..f84ec731a 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h +++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h @@ -3,7 +3,7 @@ #ifndef MGA_IOCTL_H #define MGA_IOCTL_H -#include "mgalib.h" +#include "mgacontext.h" #include "mga_xmesa.h" GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all, @@ -14,7 +14,7 @@ void mgaSwapBuffers( mgaContextPtr mmesa ); -mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ); +GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ); void mgaGetILoadBufferLocked( mgaContextPtr mmesa ); @@ -46,6 +46,7 @@ void mgaFlushElts( mgaContextPtr mmesa ) ; /* upload texture */ +void mgaDDFlush( GLcontext *ctx ); void mgaDDFinish( GLcontext *ctx ); void mgaDDInitIoctlFuncs( GLcontext *ctx ); @@ -60,10 +61,10 @@ void mgaDDInitIoctlFuncs( GLcontext *ctx ); extern drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa ); static __inline -mgaUI32 *mgaAllocVertexDwordsInline( mgaContextPtr mmesa, int dwords ) +GLuint *mgaAllocVertexDwordsInline( mgaContextPtr mmesa, int dwords ) { int bytes = dwords * 4; - mgaUI32 *head; + GLuint *head; if (!mmesa->vertex_dma_buffer) { LOCK_HARDWARE( mmesa ); @@ -81,12 +82,11 @@ mgaUI32 *mgaAllocVertexDwordsInline( mgaContextPtr mmesa, int dwords ) UNLOCK_HARDWARE( mmesa ); } - head = (mgaUI32 *)((char *)mmesa->vertex_dma_buffer->address + + head = (GLuint *)((char *)mmesa->vertex_dma_buffer->address + mmesa->vertex_dma_buffer->used); mmesa->vertex_dma_buffer->used += bytes; return head; } - #endif diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaspan.c b/xc/lib/GL/mesa/src/drv/mga/mgaspan.c index 5400510fb..b3442d3fa 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgaspan.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgaspan.c @@ -2,8 +2,7 @@ #include "types.h" #include "mgadd.h" -#include "mgalib.h" -#include "mgalog.h" +#include "mgacontext.h" #include "mgaspan.h" #include "mgaioctl.h" @@ -18,13 +17,13 @@ GLuint height = dPriv->h; \ char *read_buf = (char *)(sPriv->pFB + \ mmesa->readOffset + \ - dPriv->x * mgaScreen->cpp + \ - dPriv->y * pitch); \ + dPriv->x * mgaScreen->cpp + \ + dPriv->y * pitch); \ char *buf = (char *)(sPriv->pFB + \ mmesa->drawOffset + \ - dPriv->x * mgaScreen->cpp + \ - dPriv->y * pitch); \ - GLushort p = MGA_CONTEXT( ctx )->MonoColor; \ + dPriv->x * mgaScreen->cpp + \ + dPriv->y * pitch); \ + GLushort p = MGA_CONTEXT( ctx )->MonoColor; \ (void) read_buf; (void) buf; (void) p @@ -40,6 +39,8 @@ dPriv->x * 2 + \ dPriv->y * pitch) +#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS + #define INIT_MONO_PIXEL(p) #define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \ @@ -150,21 +151,48 @@ do { \ +/* 32 bit depthbuffer functions. + */ +#define WRITE_DEPTH( _x, _y, d ) \ + *(GLuint *)(buf + _x*4 + _y*pitch) = d; +#define READ_DEPTH( d, _x, _y ) \ + d = *(GLuint *)(buf + _x*4 + _y*pitch); +#define TAG(x) mga##x##_32 +#include "depthtmp.h" -/* 32 bit depthbuffer functions. + +/* 24/8 bit interleaved depth/stencil functions */ -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLushort *)(buf + _x*4 + _y*pitch) = d; +#define WRITE_DEPTH( _x, _y, d ) { \ + GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \ + tmp &= 0xff; \ + tmp |= (d) & 0xffffff00; \ + *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \ +} #define READ_DEPTH( d, _x, _y ) \ - d = *(GLushort *)(buf + _x*4 + _y*pitch); + d = *(GLuint *)(buf + _x*4 + _y*pitch) >> 8; -#define TAG(x) mga##x##_32 + +#define TAG(x) mga##x##_24_8 #include "depthtmp.h" +#define WRITE_STENCIL( _x, _y, d ) { \ + GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \ + tmp &= 0xffffff00; \ + tmp |= d & 0xff; \ + *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \ +} + +#define READ_STENCIL( d, _x, _y ) \ + d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff; + +#define TAG(x) mga##x##_24_8 +#include "stenciltmp.h" + @@ -196,20 +224,32 @@ void mgaDDInitSpanFuncs( GLcontext *ctx ) ctx->Driver.WriteMonoRGBAPixels = mgaWriteMonoRGBAPixels_8888; ctx->Driver.ReadRGBASpan = mgaReadRGBASpan_8888; ctx->Driver.ReadRGBAPixels = mgaReadRGBAPixels_8888; - - ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_32; - ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_32; - ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_32; - ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_32; + + if (mmesa->hw_stencil) { + ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_32; + ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_32; + ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_32; + ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_32; + } else { + ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_24_8; + ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_24_8; + ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_24_8; + ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_24_8; + + ctx->Driver.ReadStencilSpan = mgaReadStencilSpan_24_8; + ctx->Driver.WriteStencilSpan = mgaWriteStencilSpan_24_8; + ctx->Driver.ReadStencilPixels = mgaReadStencilPixels_24_8; + ctx->Driver.WriteStencilPixels = mgaWriteStencilPixels_24_8; + } break; } - ctx->Driver.WriteCI8Span =NULL; - ctx->Driver.WriteCI32Span =NULL; - ctx->Driver.WriteMonoCISpan =NULL; - ctx->Driver.WriteCI32Pixels =NULL; - ctx->Driver.WriteMonoCIPixels =NULL; - ctx->Driver.ReadCI32Span =NULL; - ctx->Driver.ReadCI32Pixels =NULL; + ctx->Driver.WriteCI8Span = 0; + ctx->Driver.WriteCI32Span = 0; + ctx->Driver.WriteMonoCISpan = 0; + ctx->Driver.WriteCI32Pixels = 0; + ctx->Driver.WriteMonoCIPixels = 0; + ctx->Driver.ReadCI32Span = 0; + ctx->Driver.ReadCI32Pixels = 0; } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgastate.c b/xc/lib/GL/mesa/src/drv/mga/mgastate.c index 4b344b8c3..84a4b8135 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgastate.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgastate.c @@ -7,11 +7,10 @@ #include "dd.h" #include "mm.h" -#include "mgalib.h" +#include "mgacontext.h" #include "mgadd.h" #include "mgastate.h" #include "mgatex.h" -#include "mgalog.h" #include "mgavb.h" #include "mgatris.h" #include "mgaregs.h" @@ -33,6 +32,156 @@ static GLuint mgarop_NoBLK[16] = { #endif +static void mgaUpdateStencil(const GLcontext *ctx) +{ + mgaContextPtr mmesa = MGA_CONTEXT(ctx); + GLuint stencil = 0, stencilctl = 0; + + if (ctx->Stencil.Enabled) + { + stencil = ctx->Stencil.Ref | + ( ctx->Stencil.ValueMask << 8 ) | + ( ctx->Stencil.WriteMask << 16 ); + + switch (ctx->Stencil.Function) + { + case GL_NEVER: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_snever); + break; + case GL_LESS: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_slt); + break; + case GL_LEQUAL: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_slte); + break; + case GL_GREATER: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_sgt); + break; + case GL_GEQUAL: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_sgte); + break; + case GL_NOTEQUAL: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_sne); + break; + case GL_EQUAL: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_se); + break; + case GL_ALWAYS: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_salways); + default: + break; + } + + switch (ctx->Stencil.FailFunc) + { + case GL_KEEP: + MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_keep); + break; + case GL_ZERO: + MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_zero); + break; + case GL_REPLACE: + MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_replace); + break; + case GL_INCR: + MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_incrsat); + break; + case GL_DECR: + MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_decrsat); + break; + case GL_INVERT: + MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_invert); + break; + default: + break; + } + + switch (ctx->Stencil.ZFailFunc) + { + case GL_KEEP: + MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_keep); + break; + case GL_ZERO: + MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_zero); + break; + case GL_REPLACE: + MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_replace); + break; + case GL_INCR: + MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_incrsat); + break; + case GL_DECR: + MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_decrsat); + break; + case GL_INVERT: + MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_invert); + break; + default: + break; + } + + switch (ctx->Stencil.ZPassFunc) + { + case GL_KEEP: + MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_keep); + break; + case GL_ZERO: + MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_zero); + break; + case GL_REPLACE: + MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_replace); + break; + case GL_INCR: + MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_incrsat); + break; + case GL_DECR: + MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_decrsat); + break; + case GL_INVERT: + MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_invert); + break; + default: + break; + } + } + + mmesa->Setup[MGA_CTXREG_STENCIL] = stencil; + mmesa->Setup[MGA_CTXREG_STENCILCTL] = stencilctl; + mmesa->dirty |= MGA_UPLOAD_CTX; +} + +static void mgaDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref, + GLuint mask) +{ + FLUSH_BATCH( MGA_CONTEXT(ctx) ); + MGA_CONTEXT(ctx)->new_state |= MGA_NEW_STENCIL; +} + +static void mgaDDStencilMask(GLcontext *ctx, GLuint mask) +{ + FLUSH_BATCH( MGA_CONTEXT(ctx) ); + MGA_CONTEXT(ctx)->new_state |= MGA_NEW_STENCIL; +} + +static void mgaDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail, + GLenum zpass) +{ + FLUSH_BATCH( MGA_CONTEXT(ctx) ); + MGA_CONTEXT(ctx)->new_state |= MGA_NEW_STENCIL; +} + +static void mgaDDClearDepth(GLcontext *ctx, GLclampd d) +{ + mgaContextPtr mmesa = MGA_CONTEXT(ctx); + + switch (mmesa->Setup[MGA_CTXREG_MACCESS] & MA_zwidth_MASK) { + case MA_zwidth_16: mmesa->ClearDepth = d * 0x0000ffff; break; + case MA_zwidth_24: mmesa->ClearDepth = d * 0xffffff00; break; + case MA_zwidth_32: mmesa->ClearDepth = d * 0xffffffff; break; + default: return; + } +} + static void mgaUpdateZMode(const GLcontext *ctx) { mgaContextPtr mmesa = MGA_CONTEXT( ctx ); @@ -122,11 +271,8 @@ static void mgaDDLightModelfv(GLcontext *ctx, GLenum pname, static void mgaDDShadeModel(GLcontext *ctx, GLenum mode) { - if (1) { - FLUSH_BATCH( MGA_CONTEXT(ctx) ); - MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE; - mgaMsg(8, "mgaDDShadeModel: %x\n", mode); - } + FLUSH_BATCH( MGA_CONTEXT(ctx) ); + MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE; } @@ -167,9 +313,9 @@ static void mgaUpdateFogAttrib( GLcontext *ctx ) { mgaContextPtr mmesa = MGA_CONTEXT(ctx); - mgaUI32 color = MGAPACKCOLOR888((mgaUI8)(ctx->Fog.Color[0]*255.0F), - (mgaUI8)(ctx->Fog.Color[1]*255.0F), - (mgaUI8)(ctx->Fog.Color[2]*255.0F)); + GLuint color = MGAPACKCOLOR888((GLubyte)(ctx->Fog.Color[0]*255.0F), + (GLubyte)(ctx->Fog.Color[1]*255.0F), + (GLubyte)(ctx->Fog.Color[2]*255.0F)); if (color != mmesa->Setup[MGA_CTXREG_FOGCOLOR]) mmesa->Setup[MGA_CTXREG_FOGCOLOR] = color; @@ -202,7 +348,7 @@ static void mgaUpdateAlphaMode(GLcontext *ctx) int a = 0; /* determine source of alpha for blending and testing */ - if ( !ctx->Texture.Enabled ) + if ( !ctx->Texture.ReallyEnabled ) a |= AC_alphasel_diffused; else { switch (ctx->Texture.Unit[0].EnvMode) { @@ -433,7 +579,7 @@ static void mgaUpdateCull( GLcontext *ctx ) mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE); if (ctx->Polygon.FrontFace != GL_CCW) mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE); - if (mmesa->multitex) + if (mmesa->warp_pipe & MGA_TEX1_BIT) mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE); /* why??? */ } @@ -564,9 +710,6 @@ static void mgaDDPolygonStipple( GLcontext *ctx, const GLubyte *mask ) /* ============================================================= */ - - - static void mgaDDPrintDirty( const char *msg, GLuint state ) { fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s\n", @@ -582,11 +725,80 @@ static void mgaDDPrintDirty( const char *msg, GLuint state ) ); } +/* static int tex0[11] = { */ +/* 0x2050003, */ +/* 0x90, */ +/* 0x82100000, */ +/* 0x0, */ +/* 0xc6d000, */ +/* 0xc7d000, */ +/* 0xc81000, */ +/* 0xc82000, */ +/* 0xc82400, */ +/* 0x3fc7413, */ +/* 0x1fc7612 */ +/* }; */ + +/* static int tex1[11] = { */ +/* 0x2040003, */ +/* 0x90, */ +/* 0x82100000, */ +/* 0x0, */ +/* 0xc82500, */ +/* 0xc8a500, */ +/* 0xc8c500, */ +/* 0xc8cd00, */ +/* 0xc8cf00, */ +/* 0x1fc7612, */ +/* 0x1fc7612 */ +/* }; */ + +/* static int tex0_single[11] = { */ +/* 0x2040003, */ +/* 0x10, */ +/* 0x82100000, */ +/* 0x0, */ +/* 0x196d000, */ +/* 0x1975000, */ +/* 0x1977000, */ +/* 0x1977800, */ +/* 0x1977a00, */ +/* 0x1fc7612, */ +/* 0x1fc7612, */ +/* }; */ + +/* static int ctx_single[] = { */ +/* 0x727000, */ +/* 0x1, */ +/* 0xffffffff, */ +/* 0xc4436, */ +/* 0x101, */ +/* 0x7fff7f, */ +/* 0x0, */ +/* 0x0, */ +/* 0x0, */ +/* 0x0 */ +/* }; */ + +/* static int ctx_multi[] = { */ +/* 0x727000, */ +/* 0x1, */ +/* 0xffffffff, */ +/* 0xc4076, */ +/* 0x2000101, */ +/* 0x0, */ +/* 0x0, */ +/* 0xc0600000, */ +/* 0xc3600013, */ +/* 0x0 */ +/* }; */ /* Push the state into the sarea and/or texture memory. */ void mgaEmitHwStateLocked( mgaContextPtr mmesa ) { + drm_mga_sarea_t *sarea = mmesa->sarea; + if (MGA_DEBUG & DEBUG_VERBOSE_MSG) mgaDDPrintDirty( "mgaEmitHwStateLocked", mmesa->dirty ); @@ -596,28 +808,40 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa ) if ((mmesa->dirty & MGA_UPLOAD_TEX1IMAGE) && mmesa->CurrentTexObj[1]) mgaUploadTexImages(mmesa, mmesa->CurrentTexObj[1]); - if (mmesa->dirty & MGA_UPLOAD_CTX) - memcpy( mmesa->sarea->ContextState, - mmesa->Setup, - sizeof(mmesa->Setup)); + if (mmesa->dirty & MGA_UPLOAD_CTX) { + memcpy( sarea->ContextState, mmesa->Setup, sizeof(mmesa->Setup)); + } - if ((mmesa->dirty & MGA_UPLOAD_TEX0) && mmesa->CurrentTexObj[0]) - memcpy(mmesa->sarea->TexState[0], - mmesa->CurrentTexObj[0]->Setup, - sizeof(mmesa->sarea->TexState[0])); + if ((mmesa->dirty & MGA_UPLOAD_TEX0) && mmesa->CurrentTexObj[0]) { + memcpy(sarea->TexState[0], + mmesa->CurrentTexObj[0]->Setup, + sizeof(sarea->TexState[0])); + } - if ((mmesa->dirty & MGA_UPLOAD_TEX1) && mmesa->CurrentTexObj[1]) - memcpy(mmesa->sarea->TexState[1], - mmesa->CurrentTexObj[1]->Setup, - sizeof(mmesa->sarea->TexState[1])); + if ((mmesa->dirty & MGA_UPLOAD_TEX1) && mmesa->CurrentTexObj[1]) { + memcpy(sarea->TexState[1], + mmesa->CurrentTexObj[1]->Setup, + sizeof(sarea->TexState[1])); + } + + if (sarea->TexState[0][MGA_TEXREG_CTL2] != + sarea->TexState[1][MGA_TEXREG_CTL2]) { + memcpy(sarea->TexState[1], + sarea->TexState[0], + sizeof(sarea->TexState[0])); + mmesa->dirty |= MGA_UPLOAD_TEX1|MGA_UPLOAD_TEX0; + } mmesa->sarea->WarpPipe = mmesa->warp_pipe; + mmesa->sarea->vertexsize = mmesa->vertsize; +/* mmesa->sarea->vertexsize = 10; */ mmesa->sarea->dirty |= mmesa->dirty; #if 0 - mgaPrintSetupFlags("warp pipe", mmesa->sarea->WarpPipe); - fprintf(stderr, "in mgaEmitHwStateLocked: dirty now %x\n", - mmesa->sarea->dirty); + if (mmesa->dirty & MGA_UPLOAD_PIPE) + mgaPrintSetupFlags("warp pipe", mmesa->sarea->WarpPipe); +/* fprintf(stderr, "in mgaEmitHwStateLocked: dirty now %x\n", */ +/* mmesa->sarea->dirty); */ #endif mmesa->dirty &= (MGA_UPLOAD_CLIPRECTS|MGA_WAIT_AGE); @@ -686,6 +910,14 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state) mmesa->new_state |= MGA_NEW_DEPTH; #endif break; + case GL_STENCIL_TEST: + FLUSH_BATCH( mmesa ); + if (mmesa->hw_stencil) + mmesa->new_state |= MGA_NEW_STENCIL; + else if (state) + mmesa->Fallback |= MGA_FALLBACK_STENCIL; + else + mmesa->Fallback &= ~MGA_FALLBACK_STENCIL; default: break; } @@ -704,7 +936,11 @@ static void mgaWarpUpdateState( GLcontext *ctx ) int index = mmesa->setupindex; index &= ~(MGA_WIN_BIT|MGA_TEX0_BIT|MGA_RGBA_BIT); - index |= MGA_ALPHA_BIT | MGA_SPEC_BIT | MGA_FOG_BIT; + index |= (MGA_ALPHA_BIT | + MGA_SPEC_BIT | + MGA_FOG_BIT | +/* MGA_TEX1_BIT | */ + 0); if (index != mmesa->warp_pipe) { @@ -722,7 +958,7 @@ static void mgaWarpUpdateState( GLcontext *ctx ) static void mgaDDPrintState( const char *msg, GLuint state ) { - mgaMsg(1, "%s (0x%x): %s%s%s%s%s%s%s%s\n", + fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s%s\n", msg, state, (state & MGA_NEW_DEPTH) ? "depth, " : "", @@ -761,6 +997,9 @@ void mgaDDUpdateHwState( GLcontext *ctx ) if (new_state & MGA_NEW_CLIP) mgaUpdateClipping(ctx); + if (new_state & MGA_NEW_STENCIL) + mgaUpdateStencil(ctx); + if (new_state & (MGA_NEW_WARP|MGA_NEW_CULL)) mgaUpdateCull(ctx); @@ -800,7 +1039,6 @@ void mgaDDReducedPrimitiveChange( GLcontext *ctx, GLenum prim ) void mgaDDUpdateState( GLcontext *ctx ) { mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaglx.c_setupPointers++; if (ctx->NewState & INTERESTED) { mgaDDChooseRenderState(ctx); @@ -848,22 +1086,35 @@ void mgaInitState( mgaContextPtr mmesa ) mmesa->Setup[MGA_CTXREG_DSTORG] = mgaScreen->frontOffset; } - if (mgaScreen->cpp == 2) + switch (mmesa->glCtx->Visual->DepthBits) { + case 16: mmesa->Setup[MGA_CTXREG_MACCESS] = (MA_pwidth_16 | - MA_zwidth_16 | + MA_zwidth_16 | /* 1bit stencil? */ MA_memreset_disable | MA_fogen_disable | MA_tlutload_disable | MA_nodither_disable | MA_dit555_disable); - else + break; + case 24: + mmesa->Setup[MGA_CTXREG_MACCESS] = (MA_pwidth_32 | + MA_zwidth_24 | + MA_memreset_disable | + MA_fogen_disable | + MA_tlutload_disable | + MA_nodither_enable | + MA_dit555_disable); + break; + case 32: mmesa->Setup[MGA_CTXREG_MACCESS] = (MA_pwidth_32 | - MA_zwidth_32 | /* stencil? */ + MA_zwidth_32 | MA_memreset_disable | MA_fogen_disable | MA_tlutload_disable | MA_nodither_enable | MA_dit555_disable); + break; + } mmesa->Setup[MGA_CTXREG_DWGCTL] = (DC_opcod_trap | DC_atype_i | @@ -928,14 +1179,18 @@ void mgaDDInitStateFuncs( GLcontext *ctx ) ctx->Driver.SetReadBuffer = mgaDDSetReadBuffer; ctx->Driver.Color = mgaDDSetColor; ctx->Driver.ClearColor = mgaDDClearColor; + ctx->Driver.ClearDepth = mgaDDClearDepth; ctx->Driver.Dither = mgaDDDither; ctx->Driver.LogicOpcode = mgaDDLogicOp; ctx->Driver.PolygonStipple = mgaDDPolygonStipple; + ctx->Driver.StencilFunc = mgaDDStencilFunc; + ctx->Driver.StencilMask = mgaDDStencilMask; + ctx->Driver.StencilOp = mgaDDStencilOp; + ctx->Driver.Index = 0; ctx->Driver.ClearIndex = 0; ctx->Driver.IndexMask = 0; - } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatex.c b/xc/lib/GL/mesa/src/drv/mga/mgatex.c index 3286744da..964157d19 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgatex.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgatex.c @@ -1,4 +1,3 @@ -/* -*- mode: C; c-basic-offset:8 -*- */ /* * GLX Hardware Device Driver for Matrox Millenium G200 * Copyright (C) 1999 Wittawat Yamwong @@ -33,369 +32,115 @@ #include <GL/gl.h> #include "mm.h" -#include "mgalib.h" +#include "mgacontext.h" #include "mgatex.h" -#include "mgalog.h" #include "mgaregs.h" #include "mgaioctl.h" +#include "enums.h" #include "simple_list.h" +#include "mem.h" +#define TEX_0 1 +#define TEX_1 2 /* * mgaDestroyTexObj * Free all memory associated with a texture and NULL any pointers * to it. */ -static void mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t ) { - - if ( !t ) return; +void +mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t ) +{ + if ( !t ) return; - /* free the texture memory */ - if (t->MemBlock) { - mmFreeMem( t->MemBlock ); - t->MemBlock = 0; - - if (t->age > mmesa->dirtyAge) - mmesa->dirtyAge = t->age; - } + /* free the texture memory */ + if (t->MemBlock) { + mmFreeMem( t->MemBlock ); + t->MemBlock = 0; + + if (t->age > mmesa->dirtyAge) + mmesa->dirtyAge = t->age; + } - /* free mesa's link */ - if (t->tObj) - t->tObj->DriverData = NULL; + /* free mesa's link */ + if (t->tObj) + t->tObj->DriverData = NULL; - /* see if it was the driver's current object */ - if (t->bound) - mmesa->CurrentTexObj[t->bound - 1] = 0; + /* see if it was the driver's current object */ + if (t->bound & TEX_0) mmesa->CurrentTexObj[0] = 0; + if (t->bound & TEX_1) mmesa->CurrentTexObj[1] = 0; - remove_from_list(t); - free( t ); -} - -static void mgaSwapOutTexObj(mgaContextPtr mmesa, mgaTextureObjectPtr t) -{ - if (t->MemBlock) { - mmFreeMem(t->MemBlock); - t->MemBlock = 0; - - if (t->age > mmesa->dirtyAge) - mmesa->dirtyAge = t->age; - } - - t->dirty_images = ~0; - move_to_tail(&(mmesa->SwappedOut), t); + remove_from_list(t); + FREE( t ); } -static void mgaPrintLocalLRU( mgaContextPtr mmesa, int heap ) -{ - mgaTextureObjectPtr t; - int sz = 1 << (mmesa->mgaScreen->logTextureGranularity[heap]); - - fprintf(stderr, "\nLocal LRU, heap %d:\n", heap); - - foreach( t, &(mmesa->TexObjList[heap]) ) { - if (!t->tObj) - fprintf(stderr, "Placeholder %d at %x sz %x\n", - t->MemBlock->ofs / sz, - t->MemBlock->ofs, - t->MemBlock->size); - else - fprintf(stderr, "Texture (bound %d) at %x sz %x\n", - t->bound, - t->MemBlock->ofs, - t->MemBlock->size); - - } - - fprintf(stderr, "\n\n"); -} - -static void mgaPrintGlobalLRU( mgaContextPtr mmesa, int heap ) +/* + * mgaSetTexWrappings + */ +static void mgaSetTexWrapping( mgaTextureObjectPtr t, + GLenum sWrap, + GLenum tWrap ) { - int i, j; - drm_mga_tex_region_t *list = mmesa->sarea->texList[heap]; + GLuint val = 0; - fprintf(stderr, "\nGlobal LRU, heap %d list %p:\n", heap, list); - - for (i = 0, j = MGA_NR_TEX_REGIONS ; i < MGA_NR_TEX_REGIONS ; i++) { - fprintf(stderr, "list[%d] age %d next %d prev %d\n", - j, list[j].age, list[j].next, list[j].prev); - j = list[j].next; - if (j == MGA_NR_TEX_REGIONS) break; - } - - if (j != MGA_NR_TEX_REGIONS) { - fprintf(stderr, "Loop detected in global LRU\n\n\n"); - for (i = 0 ; i < MGA_NR_TEX_REGIONS ; i++) { - fprintf(stderr, "list[%d] age %d next %d prev %d\n", - i, list[i].age, list[i].next, list[i].prev); - } - } + if (sWrap != GL_REPEAT) + val |= TMC_clampu_enable; - fprintf(stderr, "\n\n"); -} - - -static void mgaResetGlobalLRU( mgaContextPtr mmesa, GLuint heap ) -{ - drm_mga_tex_region_t *list = mmesa->sarea->texList[heap]; - int sz = 1 << mmesa->mgaScreen->logTextureGranularity[heap]; - int i; - - mmesa->texAge[heap] = ++mmesa->sarea->texAge[heap]; - - if (0) fprintf(stderr, "mgaResetGlobalLRU %d\n", (int)heap); - - /* (Re)initialize the global circular LRU list. The last element - * in the array (MGA_NR_TEX_REGIONS) is the sentinal. Keeping it - * at the end of the array allows it to be addressed rationally - * when looking up objects at a particular location in texture - * memory. - */ - for (i = 0 ; (i+1) * sz <= mmesa->mgaScreen->textureSize[heap] ; i++) { - list[i].prev = i-1; - list[i].next = i+1; - list[i].age = mmesa->sarea->texAge[heap]; - } - - i--; - list[0].prev = MGA_NR_TEX_REGIONS; - list[i].prev = i-1; - list[i].next = MGA_NR_TEX_REGIONS; - list[MGA_NR_TEX_REGIONS].prev = i; - list[MGA_NR_TEX_REGIONS].next = 0; + if (tWrap != GL_REPEAT) + val |= TMC_clampv_enable; + t->Setup[MGA_TEXREG_CTL] &= ~(TMC_clampu_enable|TMC_clampv_enable); + t->Setup[MGA_TEXREG_CTL] |= val; } -static void mgaUpdateTexLRU( mgaContextPtr mmesa, mgaTextureObjectPtr t ) -{ - int i; - int heap = t->heap; - int logsz = mmesa->mgaScreen->logTextureGranularity[heap]; - int start = t->MemBlock->ofs >> logsz; - int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz; - drm_mga_tex_region_t *list = mmesa->sarea->texList[heap]; - - mmesa->texAge[heap] = ++mmesa->sarea->texAge[heap]; - - if (!t->MemBlock) { - fprintf(stderr, "no memblock\n\n"); - return; - } - - /* Update our local LRU - */ - move_to_head( &(mmesa->TexObjList[heap]), t ); - - - if (0) - fprintf(stderr, "mgaUpdateTexLRU heap %d list %p\n", heap, list); - - - /* Update the global LRU - */ - for (i = start ; i <= end ; i++) { - - list[i].in_use = 1; - list[i].age = mmesa->texAge[heap]; - - /* remove_from_list(i) - */ - list[(unsigned)list[i].next].prev = list[i].prev; - list[(unsigned)list[i].prev].next = list[i].next; - - /* insert_at_head(list, i) - */ - list[i].prev = MGA_NR_TEX_REGIONS; - list[i].next = list[MGA_NR_TEX_REGIONS].next; - list[(unsigned)list[MGA_NR_TEX_REGIONS].next].prev = i; - list[MGA_NR_TEX_REGIONS].next = i; - } - - if (0) { - mgaPrintGlobalLRU(mmesa, t->heap); - mgaPrintLocalLRU(mmesa, t->heap); - } -} - -/* Called for every shared texture region which has increased in age - * since we last held the lock. - * - * Figures out which of our textures have been ejected by other clients, - * and pushes a placeholder texture onto the LRU list to represent - * the other client's textures. +/* + * mgaSetTexFilter */ -static void mgaTexturesGone( mgaContextPtr mmesa, - GLuint heap, - GLuint offset, - GLuint size, - GLuint in_use ) +static void mgaSetTexFilter(mgaTextureObjectPtr t, GLenum minf, GLenum magf) { - mgaTextureObjectPtr t, tmp; - - - - foreach_s ( t, tmp, &(mmesa->TexObjList[heap]) ) { - - if (t->MemBlock->ofs >= offset + size || - t->MemBlock->ofs + t->MemBlock->size <= offset) - continue; - - - - - /* It overlaps - kick it off. Need to hold onto the currently bound - * objects, however. - */ - if (t->bound) - mgaSwapOutTexObj( mmesa, t ); - else - mgaDestroyTexObj( mmesa, t ); + GLuint val = 0; + + switch (minf) { + case GL_NEAREST: val = TF_minfilter_nrst; break; + case GL_LINEAR: val = TF_minfilter_bilin; break; + case GL_NEAREST_MIPMAP_NEAREST: val = TF_minfilter_mm1s; break; + case GL_LINEAR_MIPMAP_NEAREST: val = TF_minfilter_mm4s; break; + case GL_NEAREST_MIPMAP_LINEAR: val = TF_minfilter_mm2s; break; + case GL_LINEAR_MIPMAP_LINEAR: val = TF_minfilter_mm8s; break; + default: val = TF_minfilter_nrst; break; } - - if (in_use) { - t = (mgaTextureObjectPtr) calloc(1,sizeof(*t)); - if (!t) return; - - t->heap = heap; - t->MemBlock = mmAllocMem( mmesa->texHeap[heap], size, 0, offset); - if (!t->MemBlock) { - fprintf(stderr, "Couldn't alloc placeholder sz %x ofs %x\n", - (int)size, (int)offset); - mmDumpMemInfo( mmesa->texHeap[heap]); - return; - } - insert_at_head( &(mmesa->TexObjList[heap]), t ); + switch (magf) { + case GL_NEAREST: val |= TF_magfilter_nrst; break; + case GL_LINEAR: val |= TF_magfilter_bilin; break; + default: val |= TF_magfilter_nrst; break; } -} - - -void mgaAgeTextures( mgaContextPtr mmesa, int heap ) -{ - drm_mga_sarea_t *sarea = mmesa->sarea; - int sz = 1 << (mmesa->mgaScreen->logTextureGranularity[heap]); - int idx, nr = 0; - - /* Have to go right round from the back to ensure stuff ends up - * LRU in our local list... Fix with a cursor pointer. - */ - for (idx = sarea->texList[heap][MGA_NR_TEX_REGIONS].prev ; - idx != MGA_NR_TEX_REGIONS && nr < MGA_NR_TEX_REGIONS ; - idx = sarea->texList[heap][idx].prev, nr++) - { - if (sarea->texList[heap][idx].age > mmesa->texAge[heap]) { - mgaTexturesGone(mmesa, heap, idx * sz, sz, 1); - } - } - - if (nr == MGA_NR_TEX_REGIONS) { - mgaTexturesGone(mmesa, heap, 0, - mmesa->mgaScreen->textureSize[heap], 0); - mgaResetGlobalLRU( mmesa, heap ); - } - - - if (0) { - mgaPrintGlobalLRU( mmesa, heap ); - mgaPrintLocalLRU( mmesa, heap ); - } - - mmesa->texAge[heap] = sarea->texAge[heap]; - mmesa->dirty |= MGA_UPLOAD_TEX0IMAGE | MGA_UPLOAD_TEX1IMAGE; -} - - -/* - * mgaSetTexWrappings - */ -static void mgaSetTexWrapping( mgaTextureObjectPtr t, - GLenum sWrap, GLenum tWrap ) { - if (sWrap == GL_REPEAT) { - t->Setup[MGA_TEXREG_CTL] &= ~TMC_clampu_enable; - } else { - t->Setup[MGA_TEXREG_CTL] |= TMC_clampu_enable; - } - if (tWrap == GL_REPEAT) { - t->Setup[MGA_TEXREG_CTL] &= ~TMC_clampv_enable; - } else { - t->Setup[MGA_TEXREG_CTL] |= TMC_clampv_enable; - } -} - -/* - * mgaSetTexFilter - */ -static void mgaSetTexFilter(mgaTextureObjectPtr t, GLenum minf, GLenum magf) { - switch (minf) { - case GL_NEAREST: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_minfilter_MASK, TF_minfilter_nrst); - break; - case GL_LINEAR: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_minfilter_MASK, TF_minfilter_bilin); - break; - case GL_NEAREST_MIPMAP_NEAREST: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_minfilter_MASK, TF_minfilter_mm1s); - break; - case GL_LINEAR_MIPMAP_NEAREST: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_minfilter_MASK, TF_minfilter_mm4s); - break; - case GL_NEAREST_MIPMAP_LINEAR: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_minfilter_MASK, TF_minfilter_mm2s); - break; - case GL_LINEAR_MIPMAP_LINEAR: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_minfilter_MASK, TF_minfilter_mm8s); - break; - default: - mgaError("mgaSetTexFilter(): not supported min. filter %d\n", - (int)minf); - break; - } - - switch (magf) { - case GL_NEAREST: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_magfilter_MASK,TF_magfilter_nrst); - break; - case GL_LINEAR: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_magfilter_MASK,TF_magfilter_bilin); - break; - default: - mgaError("mgaSetTexFilter(): not supported mag. filter %d\n", - (int)magf); - break; - } - /* See OpenGL 1.2 specification */ - if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST || - minf == GL_NEAREST_MIPMAP_LINEAR)) { - /* c = 0.5 */ - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],TF_fthres_MASK, - 0x20 << TF_fthres_SHIFT); - } else { - /* c = 0 */ - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],TF_fthres_MASK, - 0x10 << TF_fthres_SHIFT); - } + /* See OpenGL 1.2 specification */ + if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST || + minf == GL_NEAREST_MIPMAP_LINEAR)) { + val |= (0x20 << TF_fthres_SHIFT); /* c = 0.5 */ + } else { + val |= (0x10 << TF_fthres_SHIFT); /* c = 0 */ + } + + t->Setup[MGA_TEXREG_FILTER] &= (TF_minfilter_MASK | + TF_magfilter_MASK | + TF_fthres_MASK); + t->Setup[MGA_TEXREG_FILTER] |= val; } /* * mgaSetTexBorderColor */ -static void mgaSetTexBorderColor(mgaTextureObjectPtr t, GLubyte color[4]) { - t->Setup[MGA_TEXREG_BORDERCOL] = - MGAPACKCOLOR8888(color[0],color[1],color[2],color[3]); - +static void mgaSetTexBorderColor(mgaTextureObjectPtr t, GLubyte color[4]) +{ + t->Setup[MGA_TEXREG_BORDERCOL] = MGAPACKCOLOR8888(color[0],color[1], + color[2],color[3]); } @@ -404,152 +149,6 @@ static void mgaSetTexBorderColor(mgaTextureObjectPtr t, GLubyte color[4]) { -/* - * mgaUploadSubImageLocked - * - * Perform an iload based update of a resident buffer. This is used for - * both initial loading of the entire image, and texSubImage updates. - * - * Performed with the hardware lock held. - */ -static void mgaUploadSubImageLocked( mgaContextPtr mmesa, - mgaTextureObjectPtr t, - int level, - int x, int y, int width, int height ) { - int x2; - int dwords; - int offset; - struct gl_texture_image *image; - int texelBytes, texelsPerDword, texelMaccess, length; - - if ( level < 0 || level >= MGA_TEX_MAXLEVELS ) { - mgaMsg( 1, "mgaUploadSubImage: bad level: %i\n", level ); - return; - } - - image = t->tObj->Image[level]; - if ( !image ) { - mgaError( "mgaUploadSubImage: NULL image\n" ); - return; - } - - /* find the proper destination offset for this level */ - offset = (t->MemBlock->ofs + - t->offsets[level]); - - texelBytes = t->texelBytes; - switch( texelBytes ) { - case 1: - texelsPerDword = 4; - texelMaccess = 0; - break; - case 2: - texelsPerDword = 2; - texelMaccess = 1; - break; - case 4: - texelsPerDword = 1; - texelMaccess = 2; - break; - default: - return; - } - - - /* We can't do a subimage update if pitch is < 32 texels due - * to hardware XY addressing limits, so we will need to - * linearly upload all modified rows. - */ - if ( image->Width < 32 ) { - x = 0; - width = image->Width * height; - height = 1; - - /* Assume that 1x1 textures aren't going to cause a - * bus error if we read up to four texels from that - * location: - */ - if ( width < texelsPerDword ) { - width = texelsPerDword; - } - } else { - /* pad the size out to dwords. The image is a pointer - to the entire image, so we can safely reference - outside the x,y,width,height bounds if we need to */ - x2 = x + width; - x2 = (x2 + (texelsPerDword-1)) & ~(texelsPerDword-1); - x = (x + (texelsPerDword-1)) & ~(texelsPerDword-1); - width = x2 - x; - } - - /* we may not be able to upload the entire texture in one - batch due to register limits or dma buffer limits. - Recursively split it up. */ - while ( 1 ) { - dwords = height * width / texelsPerDword; - if ( dwords * 4 <= MGA_DMA_BUF_SZ ) { - break; - } - mgaMsg(10, "mgaUploadSubImage: recursively subdividing\n" ); - - mgaUploadSubImageLocked( mmesa, t, level, x, y, - width, height >> 1 ); - y += ( height >> 1 ); - height -= ( height >> 1 ); - } - - mgaMsg(10, "mgaUploadSubImage: %i,%i of %i,%i at %i,%i\n", - width, height, image->Width, image->Height, x, y ); - - /* bump the performance counter */ - mgaglx.c_textureSwaps += ( dwords << 2 ); - - length = dwords * 4; - - /* Fill in the secondary buffer with properly converted texels - * from the mesa buffer. */ - if(t->heap == MGA_CARD_HEAP) { - mgaGetILoadBufferLocked( mmesa ); - mgaConvertTexture( (mgaUI32 *)mmesa->iload_buffer->address, - texelBytes, image, x, y, width, height ); - if(length < 64) length = 64; - mgaMsg(10, "TexelBytes : %d, offset: %d, length : %d\n", - texelBytes, - mmesa->mgaScreen->textureOffset[t->heap] + - offset + - y * width * 4/texelsPerDword, - length); - - mgaFireILoadLocked( mmesa, - mmesa->mgaScreen->textureOffset[t->heap] + - offset + - y * width * 4/texelsPerDword, - length); - } else { - /* This works, is slower for uploads to card space and needs - * additional synchronization with the dma stream. - */ - mgaConvertTexture( (mgaUI32 *) - (mmesa->mgaScreen->texVirtual[t->heap] + - offset + - y * width * 4/texelsPerDword), - texelBytes, image, x, y, width, height ); - } -} - - -static void mgaUploadTexLevel( mgaContextPtr mmesa, - mgaTextureObjectPtr t, - int l ) -{ - mgaUploadSubImageLocked( mmesa, - t, - l, - 0, 0, - t->tObj->Image[l]->Width, - t->tObj->Image[l]->Height); -} - /* @@ -558,502 +157,337 @@ static void mgaUploadTexLevel( mgaContextPtr mmesa, * This will happen before drawing with a new texture, or drawing with a * texture after it was swapped out or teximaged again. */ -static void mgaCreateTexObj(mgaContextPtr mmesa, struct gl_texture_object *tObj) +static void mgaCreateTexObj(mgaContextPtr mmesa, + struct gl_texture_object *tObj) { - mgaTextureObjectPtr t; - int i, ofs, size; - struct gl_texture_image *image; - int LastLevel; - int s, s2; - int textureFormat; - - mgaMsg( 10,"mgaCreateTexObj( %p )\n", tObj ); - - t = malloc( sizeof( *t ) ); - if ( !t ) { - mgaError( "mgaCreateTexObj: Failed to malloc mgaTextureObject\n" ); - return; - } - memset( t, 0, sizeof( *t ) ); - - image = tObj->Image[ 0 ]; - if ( !image ) { - return; - } - - if ( 0 ) { - /* G400 texture format options */ - - } else { - /* G200 texture format options */ - - switch( image->Format ) { - case GL_RGB: - case GL_LUMINANCE: - if ( image->IntFormat != GL_RGB5 && - ( image->IntFormat == GL_RGB8 || - mgaglx.default32BitTextures ) ) { - t->texelBytes = 4; - textureFormat = TMC_tformat_tw32; - } else { - t->texelBytes = 2; - textureFormat = TMC_tformat_tw16; - } - break; - case GL_ALPHA: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RGBA: - if ( image->IntFormat != GL_RGBA4 && - ( image->IntFormat == GL_RGBA8 || - mgaglx.default32BitTextures ) ) { - t->texelBytes = 4; - textureFormat = TMC_tformat_tw32; - } else { - t->texelBytes = 2; - textureFormat = TMC_tformat_tw12; - } - break; - case GL_COLOR_INDEX: - textureFormat = TMC_tformat_tw8; - t->texelBytes = 1; - break; - default: - mgaError( "mgaCreateTexObj: bad image->Format\n" ); - free( t ); - return; - } - } - - /* we are going to upload all levels that are present, even if - later levels wouldn't be used by the current filtering mode. This - allows the filtering mode to change without forcing another upload - of the images */ - LastLevel = MGA_TEX_MAXLEVELS-1; - - ofs = 0; - for ( i = 0 ; i <= LastLevel ; i++ ) { - int levelWidth, levelHeight; - - t->offsets[i] = ofs; - image = tObj->Image[ i ]; - if ( !image ) { - LastLevel = i - 1; - mgaMsg( 10, " missing images after LastLevel: %i\n", - LastLevel ); - break; - } - /* the G400 doesn't work with textures less than 8 - units in size */ - levelWidth = image->Width; - levelHeight = image->Height; - if ( levelWidth < 8 ) { - levelWidth = 8; - } - if ( levelHeight < 8 ) { - levelHeight = 8; - } - size = levelWidth * levelHeight * t->texelBytes; - size = ( size + 31 ) & ~31; /* 32 byte aligned */ - ofs += size; - t->dirty_images |= (1<<i); - } - t->totalSize = ofs; - t->lastLevel = LastLevel; + const struct gl_texture_image *image = tObj->Image[ 0 ]; + mgaTextureObjectPtr t; + int i, ofs; + int LastLevel; + int s, s2; + int textureFormat; - /* fill in our mga texture object */ - t->tObj = tObj; - t->ctx = mmesa; - t->age = 0; - t->bound = 0; + if (!image) return; - - insert_at_tail(&(mmesa->SwappedOut), t); - - t->MemBlock = 0; - /* base image */ - image = tObj->Image[ 0 ]; + tObj->DriverData = t = CALLOC( sizeof( *t ) ); + if (!t) { + fprintf(stderr, "mgaCreateTexObj: Failed to malloc mgaTextureObject\n" ); + return; + } - /* setup hardware register values */ - t->Setup[MGA_TEXREG_CTL] = (TMC_takey_1 | - TMC_tamask_0 | - textureFormat ); + switch( image->Format ) { + case GL_RGB: + case GL_LUMINANCE: + if ( image->IntFormat != GL_RGB5 && ( image->IntFormat == GL_RGB8 || + mmesa->default32BitTextures ) ) { + t->texelBytes = 4; + textureFormat = TMC_tformat_tw32; + } else { + t->texelBytes = 2; + textureFormat = TMC_tformat_tw16; + } + break; + case GL_ALPHA: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_RGBA: + if ( image->IntFormat != GL_RGBA4 && ( image->IntFormat == GL_RGBA8 || + mmesa->default32BitTextures ) ) { + t->texelBytes = 4; + textureFormat = TMC_tformat_tw32; + } else { + t->texelBytes = 2; + textureFormat = TMC_tformat_tw12; + } + break; + case GL_COLOR_INDEX: + textureFormat = TMC_tformat_tw8; + t->texelBytes = 1; + break; + default: + fprintf(stderr, "mgaCreateTexObj: bad image->Format %x/%s\n", + image->Format, + gl_lookup_enum_by_nr(image->Format)); + FREE( t ); + tObj->DriverData = 0; + return; + } + + /* We are going to upload all levels that are present, even if + * later levels wouldn't be used by the current filtering mode. This + * allows the filtering mode to change without forcing another upload + * of the images. + */ + LastLevel = MGA_TEX_MAXLEVELS-1; - if (image->WidthLog2 >= 3) { - t->Setup[MGA_TEXREG_CTL] |= ((image->WidthLog2 - 3) << - TMC_tpitch_SHIFT); - } else { - t->Setup[MGA_TEXREG_CTL] |= (TMC_tpitchlin_enable | - (image->Width << - TMC_tpitchext_SHIFT)); - } + ofs = 0; + for ( i = 0 ; i <= LastLevel ; i++ ) { + if ( !tObj->Image[i] ) { + LastLevel = i - 1; + break; + } + t->offsets[i] = ofs; + t->dirty_images |= (1<<i); - t->Setup[MGA_TEXREG_CTL2] = TMC_ckstransdis_enable; + ofs += ((MAX2( tObj->Image[i]->Width, 8 ) * + MAX2( tObj->Image[i]->Height, 8 ) * + t->texelBytes) + 31) & ~31; + } - if ( mmesa->glCtx->Light.Model.ColorControl == - GL_SEPARATE_SPECULAR_COLOR ) - { - t->Setup[MGA_TEXREG_CTL2] |= TMC_specen_enable; - } - - t->Setup[MGA_TEXREG_FILTER] = (TF_minfilter_nrst | - TF_magfilter_nrst | - TF_filteralpha_enable | - (0x10 << TF_fthres_SHIFT) | - (LastLevel << TF_mapnb_SHIFT)); - - /* warp texture registers */ - if (MGA_IS_G200(mmesa)) { - ofs = 28; - } else { - ofs = 11; - } - - s = image->Width; - s2 = image->WidthLog2; - t->Setup[MGA_TEXREG_WIDTH] = - MGA_FIELD(TW_twmask, s - 1) | - MGA_FIELD(TW_rfw, (10 - s2 - 8) & 63 ) | - MGA_FIELD(TW_tw, (s2 + ofs ) | 0x40 ); + t->totalSize = ofs; + t->lastLevel = LastLevel; + t->tObj = tObj; + t->ctx = mmesa; + t->age = 0; + t->bound = 0; + t->MemBlock = 0; + insert_at_tail(&(mmesa->SwappedOut), t); - s = image->Height; - s2 = image->HeightLog2; - t->Setup[MGA_TEXREG_HEIGHT] = - MGA_FIELD(TH_thmask, s - 1) | - MGA_FIELD(TH_rfh, (10 - s2 - 8) & 63 ) | - MGA_FIELD(TH_th, (s2 + ofs ) | 0x40 ); - - - /* set all the register values for filtering, border, etc */ - mgaSetTexWrapping( t, tObj->WrapS, tObj->WrapT ); - mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter ); - mgaSetTexBorderColor( t, tObj->BorderColor ); - - tObj->DriverData = t; -} - -static void mgaMigrateTexture( mgaContextPtr mmesa, mgaTextureObjectPtr t ) -{ - /* NOT DONE */ -} - -static int mgaChooseTexHeap( mgaContextPtr mmesa, mgaTextureObjectPtr t ) -{ - return 0; -} + /* setup hardware register values */ + t->Setup[MGA_TEXREG_CTL] = (TMC_takey_1 | + TMC_tamask_0 | + textureFormat ); + if (image->WidthLog2 >= 3) + t->Setup[MGA_TEXREG_CTL] |= ((image->WidthLog2 - 3) << TMC_tpitch_SHIFT); + else + t->Setup[MGA_TEXREG_CTL] |= (TMC_tpitchlin_enable | + (image->Width << TMC_tpitchext_SHIFT)); -int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t ) -{ - int heap; - int i; - int ofs; - mgaglx.c_textureSwaps++; - - heap = t->heap = mgaChooseTexHeap( mmesa, t ); - - /* Do we need to eject LRU texture objects? - */ - if (!t->MemBlock) { - while (1) - { - mgaTextureObjectPtr tmp = mmesa->TexObjList[heap].prev; - - t->MemBlock = mmAllocMem( mmesa->texHeap[heap], - t->totalSize, - 6, 0 ); - if (t->MemBlock) - break; - - if (mmesa->TexObjList[heap].prev->bound) { - fprintf(stderr, - "Hit bound texture in upload\n"); - return -1; - } - - if (mmesa->TexObjList[heap].prev == - &(mmesa->TexObjList[heap])) - { - fprintf(stderr, "Failed to upload texture, " - "sz %d\n", t->totalSize); - mmDumpMemInfo( mmesa->texHeap[heap] ); - return -1; - } - - mgaDestroyTexObj( mmesa, tmp ); - } - - ofs = t->MemBlock->ofs - + mmesa->mgaScreen->textureOffset[heap] - ; - t->Setup[MGA_TEXREG_ORG] = ofs; - t->Setup[MGA_TEXREG_ORG1] = ofs + t->offsets[1]; - t->Setup[MGA_TEXREG_ORG2] = ofs + t->offsets[2]; - t->Setup[MGA_TEXREG_ORG3] = ofs + t->offsets[3]; - t->Setup[MGA_TEXREG_ORG4] = ofs + t->offsets[4]; + t->Setup[MGA_TEXREG_CTL2] = TMC_ckstransdis_enable; - mmesa->dirty |= MGA_UPLOAD_CTX; - } - - /* Let the world know we've used this memory recently. - */ - mgaUpdateTexLRU( mmesa, t ); + if ( mmesa->glCtx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ) + t->Setup[MGA_TEXREG_CTL2] |= TMC_specen_enable; - if (MGA_DEBUG&DEBUG_VERBOSE_LRU) - fprintf(stderr, "dispatch age: %d age freed memory: %d\n", - GET_DISPATCH_AGE(mmesa), mmesa->dirtyAge); - - if (mmesa->dirtyAge >= GET_DISPATCH_AGE(mmesa)) - mgaWaitAgeLocked( mmesa, mmesa->dirtyAge ); - - if (t->dirty_images) { - if (MGA_DEBUG&DEBUG_VERBOSE_LRU) - fprintf(stderr, "*"); + t->Setup[MGA_TEXREG_FILTER] = (TF_minfilter_nrst | + TF_magfilter_nrst | + TF_filteralpha_enable | + (0x10 << TF_fthres_SHIFT) | + (LastLevel << TF_mapnb_SHIFT)); + + /* warp texture registers */ + ofs = MGA_IS_G200(mmesa) ? 28 : 11; + s = image->Width; + s2 = image->WidthLog2; + t->Setup[MGA_TEXREG_WIDTH] = (MGA_FIELD(TW_twmask, s - 1) | + MGA_FIELD(TW_rfw, (10 - s2 - 8) & 63 ) | + MGA_FIELD(TW_tw, (s2 + ofs ) | 0x40 )); - for (i = 0 ; i <= t->lastLevel ; i++) - if (t->dirty_images & (1<<i)) - mgaUploadTexLevel( mmesa, t, i ); - } + + s = image->Height; + s2 = image->HeightLog2; + t->Setup[MGA_TEXREG_HEIGHT] = (MGA_FIELD(TH_thmask, s - 1) | + MGA_FIELD(TH_rfh, (10 - s2 - 8) & 63 ) | + MGA_FIELD(TH_th, (s2 + ofs ) | 0x40 )); - t->dirty_images = 0; - return 0; + /* set all the register values for filtering, border, etc */ + mgaSetTexWrapping( t, tObj->WrapS, tObj->WrapT ); + mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter ); + mgaSetTexBorderColor( t, tObj->BorderColor ); } -/* -============================================================================ - -PUBLIC MGA FUNCTIONS - -============================================================================ -*/ static void mgaUpdateTextureEnvG200( GLcontext *ctx ) { - struct gl_texture_object *tObj = ctx->Texture.Unit[0].Current; - mgaTextureObjectPtr t; - - if (!tObj || !tObj->DriverData) - return; - - t = (mgaTextureObjectPtr)tObj->DriverData; - - switch (ctx->Texture.Unit[0].EnvMode) { - case GL_REPLACE: - t->Setup[MGA_TEXREG_CTL] &= ~TMC_tmodulate_enable; - t->Setup[MGA_TEXREG_CTL2] &= ~TMC_decaldis_enable; - break; - case GL_MODULATE: - t->Setup[MGA_TEXREG_CTL] |= TMC_tmodulate_enable; - t->Setup[MGA_TEXREG_CTL2] &= ~TMC_decaldis_enable; - break; - case GL_DECAL: - t->Setup[MGA_TEXREG_CTL] &= ~TMC_tmodulate_enable; - t->Setup[MGA_TEXREG_CTL2] &= ~TMC_decaldis_enable; - break; - case GL_BLEND: - t->ctx->Fallback |= MGA_FALLBACK_TEXTURE; - break; - default: - break; - } + struct gl_texture_object *tObj = ctx->Texture.Unit[0].Current; + mgaTextureObjectPtr t; + + if (!tObj || !tObj->DriverData) + return; + + t = (mgaTextureObjectPtr)tObj->DriverData; + + switch (ctx->Texture.Unit[0].EnvMode) { + case GL_REPLACE: + t->Setup[MGA_TEXREG_CTL] &= ~TMC_tmodulate_enable; + break; + case GL_MODULATE: + t->Setup[MGA_TEXREG_CTL] |= TMC_tmodulate_enable; + break; + case GL_DECAL: + t->Setup[MGA_TEXREG_CTL] &= ~TMC_tmodulate_enable; + break; + case GL_BLEND: + t->ctx->Fallback |= MGA_FALLBACK_TEXTURE; + break; + default: + break; + } } -static void mgaUpdateTextureStage( GLcontext *ctx, int unit ) +static void mgaUpdateTextureEnvG400( GLcontext *ctx, int unit ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - GLuint *reg = &mmesa->Setup[MGA_CTXREG_TDUAL0 + unit]; - GLuint source = mmesa->tmu_source[unit]; - struct gl_texture_object *tObj = ctx->Texture.Unit[source].Current; - - *reg = 0; - if (unit == 1) - *reg = mmesa->Setup[MGA_CTXREG_TDUAL0]; - - if ( tObj != ctx->Texture.Unit[source].CurrentD[2] ) - return; + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + GLuint *reg = &mmesa->Setup[MGA_CTXREG_TDUAL0 + unit]; + GLuint source = mmesa->tmu_source[unit]; + struct gl_texture_object *tObj = ctx->Texture.Unit[source].Current; + + if ( tObj != ctx->Texture.Unit[source].CurrentD[2] || + !tObj || + !tObj->Complete || + ((ctx->Enabled>>(source*4))&TEXTURE0_ANY) != TEXTURE0_2D ) + return; - if ( ((ctx->Enabled>>(source*4))&TEXTURE0_ANY) != TEXTURE0_2D ) - return; - - if (!tObj || !tObj->Complete) - return; - - switch (ctx->Texture.Unit[source].EnvMode) { - case GL_REPLACE: - *reg = (TD0_color_sel_arg1 | - TD0_alpha_sel_arg1 ); - break; - - case GL_MODULATE: - if (unit == 0) - *reg = ( TD0_color_arg2_diffuse | - TD0_color_sel_mul | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_mul); - else - *reg = ( TD0_color_arg2_prevstage | - TD0_color_alpha_prevstage | - TD0_color_sel_mul | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_mul); - break; - case GL_DECAL: - if (unit == 0) - *reg = (TD0_color_arg2_diffuse | - TD0_color_alpha_currtex | - TD0_color_alpha2inv_enable | - TD0_color_arg2mul_alpha2 | - TD0_color_arg1mul_alpha1 | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_arg2 ); - else - *reg = (TD0_color_arg2_prevstage | - TD0_color_alpha_currtex | - TD0_color_alpha2inv_enable | - TD0_color_arg2mul_alpha2 | - TD0_color_arg1mul_alpha1 | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2 ); - - break; - - case GL_ADD: - if (unit == 0) - *reg = ( TD0_color_arg2_diffuse | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_add); - else - *reg = ( TD0_color_arg2_prevstage | - TD0_color_alpha_prevstage | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_add); - break; - - case GL_BLEND: - if (0) - fprintf(stderr, "GL_BLEND unit %d flags %x\n", unit, - mmesa->blend_flags); - - if (mmesa->blend_flags) - mmesa->Fallback |= MGA_FALLBACK_TEXTURE; - return; - - /* Do singletexture GL_BLEND with 'all ones' env-color - * by using both texture units. Multitexture gl_blend - * is a fallback. - */ - if (unit == 0) { - /* Part 1: R1 = Rf ( 1 - Rt ) - * A1 = Af At - */ - *reg = ( TD0_color_arg2_diffuse | - TD0_color_arg1_inv_enable | - TD0_color_sel_mul | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_arg1); - } else { - /* Part 2: R2 = R1 + Rt - * A2 = A1 - */ - *reg = ( TD0_color_arg2_prevstage | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2); - } - - break; - default: - break; - } -} + switch (ctx->Texture.Unit[source].EnvMode) { + case GL_REPLACE: + *reg = (TD0_color_sel_arg1 | + TD0_alpha_sel_arg1 ); + break; + + case GL_MODULATE: + if (unit == 0) + *reg = ( TD0_color_arg2_diffuse | + TD0_color_sel_mul | + TD0_alpha_arg2_diffuse | + TD0_alpha_sel_mul); + else + *reg = ( TD0_color_arg2_prevstage | + TD0_color_alpha_prevstage | + TD0_color_sel_mul | + TD0_alpha_arg2_prevstage | + TD0_alpha_sel_mul); + break; + case GL_DECAL: + if (tObj->Image[0]->Format == GL_RGB) + *reg = (TD0_color_sel_arg1 | + TD0_alpha_sel_arg1 ); + else if (unit == 0) + *reg = (TD0_color_arg2_diffuse | + TD0_color_alpha_currtex | + TD0_color_alpha2inv_enable | + TD0_color_arg2mul_alpha2 | + TD0_color_arg1mul_alpha1 | + TD0_color_add_add | + TD0_color_sel_add | + TD0_alpha_arg2_diffuse | + TD0_alpha_sel_arg2 ); + else + *reg = (TD0_color_arg2_prevstage | + TD0_color_alpha_currtex | + TD0_color_alpha2inv_enable | + TD0_color_arg2mul_alpha2 | + TD0_color_arg1mul_alpha1 | + TD0_color_add_add | + TD0_color_sel_add | + TD0_alpha_arg2_prevstage | + TD0_alpha_sel_arg2 ); + + break; + + case GL_ADD: + if (unit == 0) + *reg = ( TD0_color_arg2_diffuse | + TD0_color_add_add | + TD0_color_sel_add | + TD0_alpha_arg2_diffuse | + TD0_alpha_sel_add); + else + *reg = ( TD0_color_arg2_prevstage | + TD0_color_alpha_prevstage | + TD0_color_add_add | + TD0_color_sel_add | + TD0_alpha_arg2_prevstage | + TD0_alpha_sel_add); + break; + + case GL_BLEND: + if (mmesa->blend_flags) + mmesa->Fallback |= MGA_FALLBACK_TEXTURE; + + /* Do singletexture GL_BLEND with 'all ones' env-color + * by using both texture units. Multitexture gl_blend + * is a fallback. + */ + if (unit == 0) { + /* Part 1: R1 = Rf ( 1 - Rt ) + * A1 = Af At + */ + *reg = ( TD0_color_arg2_diffuse | + TD0_color_arg1_inv_enable | + TD0_color_sel_mul | + TD0_alpha_arg2_diffuse | + TD0_alpha_sel_arg1); + } else { + /* Part 2: R2 = R1 + Rt + * A2 = A1 + */ + *reg = ( TD0_color_arg2_prevstage | + TD0_color_add_add | + TD0_color_sel_add | + TD0_alpha_arg2_prevstage | + TD0_alpha_sel_arg2); + } + break; + default: + break; + } +} -static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) { - mgaTextureObjectPtr t; - struct gl_texture_object *tObj; - GLuint enabled; - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - GLuint source = mmesa->tmu_source[unit]; - - mgaMsg(15,"mgaUpdateTextureState %d\n", unit); - - /* disable texturing until it is known to be good */ - mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_opcod_MASK; - mmesa->Setup[MGA_CTXREG_DWGCTL] |= DC_opcod_trap; - - enabled = (ctx->Texture.Enabled>>(source*4))&TEXTURE0_ANY; - if (enabled != TEXTURE0_2D) { - if (enabled) - mmesa->Fallback |= MGA_FALLBACK_TEXTURE; - return; - } - tObj = ctx->Texture.Unit[source].Current; +static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) +{ + mgaTextureObjectPtr t; + struct gl_texture_object *tObj; + GLuint enabled; + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + GLuint source = mmesa->tmu_source[unit]; - if ( !tObj || tObj != ctx->Texture.Unit[source].CurrentD[2] ) - return; -/* fprintf(stderr, "unit %d: %d\n", unit, tObj->Name); */ - - /* if the texture object doesn't exist at all (never used or - swapped out), create it now, uploading all texture images */ + enabled = (ctx->Texture.ReallyEnabled>>(source*4))&TEXTURE0_ANY; + tObj = ctx->Texture.Unit[source].Current; - if ( !tObj->DriverData ) { - /* clear the current pointer so that texture object can be - swapped out if necessary to make room */ - mgaCreateTexObj( mmesa, tObj ); + if (enabled != TEXTURE0_2D) { + if (enabled) + mmesa->Fallback |= MGA_FALLBACK_TEXTURE; + return; + } - if ( !tObj->DriverData ) { - mgaMsg( 5, "mgaUpdateTextureState: create failed\n" ); - mmesa->Fallback |= MGA_FALLBACK_TEXTURE; - return; /* can't create a texture object */ - } - } + if ( !tObj || tObj != ctx->Texture.Unit[source].CurrentD[2] ) { + mmesa->Fallback |= MGA_FALLBACK_TEXTURE; + return; + } - /* we definately have a valid texture now */ - mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_opcod_MASK; - mmesa->Setup[MGA_CTXREG_DWGCTL] |= DC_opcod_texture_trap; +/* if (!tObj) tObj = ctx->Texture.Unit[0].Current; */ +/* if (!tObj) return; */ - t = (mgaTextureObjectPtr)tObj->DriverData; + if ( !tObj->DriverData ) { + mgaCreateTexObj( mmesa, tObj ); + if ( !tObj->DriverData ) { + mmesa->Fallback |= MGA_FALLBACK_TEXTURE; + return; + } + } - if (t->dirty_images) - mmesa->dirty |= (MGA_UPLOAD_TEX0IMAGE << unit); + t = (mgaTextureObjectPtr)tObj->DriverData; - mmesa->CurrentTexObj[unit] = t; - t->bound = unit+1; + if (t->dirty_images) + mmesa->dirty |= (MGA_UPLOAD_TEX0IMAGE << unit); - if (t->MemBlock) - mgaUpdateTexLRU( mmesa, t ); + mmesa->CurrentTexObj[unit] = t; + t->bound |= unit+1; +/* if (t->MemBlock) */ +/* mgaUpdateTexLRU( mmesa, t ); */ - t->Setup[MGA_TEXREG_CTL2] &= ~TMC_dualtex_enable; - if (ctx->Texture.Enabled == (TEXTURE0_2D|TEXTURE1_2D)) - t->Setup[MGA_TEXREG_CTL2] |= TMC_dualtex_enable; + t->Setup[MGA_TEXREG_CTL2] &= ~TMC_dualtex_enable; + if (mmesa->multitex) + t->Setup[MGA_TEXREG_CTL2] |= TMC_dualtex_enable; - t->Setup[MGA_TEXREG_CTL2] &= ~TMC_specen_enable; - if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) - t->Setup[MGA_TEXREG_CTL2] |= TMC_specen_enable; - + t->Setup[MGA_TEXREG_CTL2] &= ~TMC_specen_enable; + if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) + t->Setup[MGA_TEXREG_CTL2] |= TMC_specen_enable; } @@ -1065,278 +499,259 @@ static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) { */ void mgaUpdateTextureState( GLcontext *ctx ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mmesa->Fallback &= ~MGA_FALLBACK_TEXTURE; - - if (mmesa->CurrentTexObj[0]) mmesa->CurrentTexObj[0]->bound = 0; - if (mmesa->CurrentTexObj[1]) mmesa->CurrentTexObj[1]->bound = 0; - mmesa->CurrentTexObj[0] = 0; - mmesa->CurrentTexObj[1] = 0; + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + mmesa->Fallback &= ~MGA_FALLBACK_TEXTURE; - if (MGA_IS_G400(mmesa)) { - mgaUpdateTextureObject( ctx, 0 ); - mgaUpdateTextureStage( ctx, 0 ); + if (mmesa->CurrentTexObj[0]) { + mmesa->CurrentTexObj[0]->bound = 0; + mmesa->CurrentTexObj[0] = 0; + } - mmesa->Setup[MGA_CTXREG_TDUAL1] = - mmesa->Setup[MGA_CTXREG_TDUAL0]; + if (mmesa->CurrentTexObj[1]) { + mmesa->CurrentTexObj[1]->bound = 0; + mmesa->CurrentTexObj[1] = 0; + } - if (mmesa->multitex) { - mgaUpdateTextureObject( ctx, 1 ); - mgaUpdateTextureStage( ctx, 1 ); - } - - mmesa->dirty |= MGA_UPLOAD_TEX0 | MGA_UPLOAD_TEX1; - } else { - mgaUpdateTextureObject( ctx, 0 ); - mgaUpdateTextureEnvG200( ctx ); - } - - /* schedule the register writes */ - mmesa->dirty |= MGA_UPLOAD_CTX | MGA_UPLOAD_TEX0; -} + if (MGA_IS_G400(mmesa)) { + mgaUpdateTextureObject( ctx, 0 ); + mgaUpdateTextureEnvG400( ctx, 0 ); + + mmesa->Setup[MGA_CTXREG_TDUAL1] = mmesa->Setup[MGA_CTXREG_TDUAL0]; + + if (mmesa->multitex || 1) { + mgaUpdateTextureObject( ctx, 1 ); + mgaUpdateTextureEnvG400( ctx, 1 ); + } +/* else */ +/* mmesa->Setup[MGA_CTXREG_TDUAL1] = ( TD0_color_arg2_prevstage | */ +/* TD0_color_sel_arg2 | */ +/* TD0_alpha_arg2_prevstage | */ +/* TD0_alpha_sel_arg2); */ + + + mmesa->dirty |= MGA_UPLOAD_TEX1; + } else { + mgaUpdateTextureObject( ctx, 0 ); + mgaUpdateTextureEnvG200( ctx ); + } + mmesa->dirty |= MGA_UPLOAD_CTX | MGA_UPLOAD_TEX0; + mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_opcod_MASK; + mmesa->Setup[MGA_CTXREG_DWGCTL] |= (ctx->Texture.ReallyEnabled + ? DC_opcod_texture_trap + : DC_opcod_trap); +} -/* -============================================================================ -Driver functions called directly from mesa -============================================================================ -*/ -/* - * mgaTexEnv - */ -void mgaTexEnv( GLcontext *ctx, GLenum target, - GLenum pname, const GLfloat *param ) +static void mgaDDTexEnv( GLcontext *ctx, GLenum target, + GLenum pname, const GLfloat *param ) { - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - mgaMsg( 10, "mgaTexEnv( %i )\n", pname ); - - - if (pname == GL_TEXTURE_ENV_MODE) { - /* force the texture state to be updated */ - FLUSH_BATCH( MGA_CONTEXT(ctx) ); - MGA_CONTEXT(ctx)->new_state |= (MGA_NEW_TEXTURE | - MGA_NEW_ALPHA); - } - else if (pname == GL_TEXTURE_ENV_COLOR) - { - struct gl_texture_unit *texUnit = - &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - GLfloat *fc = texUnit->EnvColor; - GLubyte c[4]; - GLuint col; - - - c[0] = fc[0]; - c[1] = fc[1]; - c[2] = fc[2]; - c[3] = fc[3]; + mgaContextPtr mmesa = MGA_CONTEXT(ctx); - col = mgaPackColor( mmesa->mgaScreen->cpp, - c[0], c[1], c[2], c[3] ); - mmesa->envcolor = (c[3]<<24) | (c[0]<<16) | (c[1]<<8) | (c[2]); + if (pname == GL_TEXTURE_ENV_MODE) { + /* force the texture state to be updated */ + FLUSH_BATCH( MGA_CONTEXT(ctx) ); + MGA_CONTEXT(ctx)->new_state |= (MGA_NEW_TEXTURE | + MGA_NEW_ALPHA); + } + else if (pname == GL_TEXTURE_ENV_COLOR) + { + struct gl_texture_unit *texUnit = + &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + GLfloat *fc = texUnit->EnvColor; + GLubyte c[4]; + GLuint col; + + COPY_4V(c, fc); + col = mgaPackColor( mmesa->mgaScreen->cpp, c[0], c[1], c[2], c[3] ); + mmesa->envcolor = (c[3]<<24) | (c[0]<<16) | (c[1]<<8) | (c[2]); - if (mmesa->Setup[MGA_CTXREG_FCOL] != col) { - FLUSH_BATCH(mmesa); - mmesa->Setup[MGA_CTXREG_FCOL] = col; - mmesa->dirty |= MGA_UPLOAD_CTX; - - mmesa->blend_flags &= ~MGA_BLEND_ENV_COLOR; - - /* Actually just require all four components to be - * equal. This permits a single-pass GL_BLEND. - * - * More complex multitexture/multipass fallbacks - * for blend can be done later. - */ - if (mmesa->envcolor != 0x0 && - mmesa->envcolor != 0xffffffff) - mmesa->blend_flags |= MGA_BLEND_ENV_COLOR; - } - } - + if (mmesa->Setup[MGA_CTXREG_FCOL] != col) { + FLUSH_BATCH(mmesa); + mmesa->Setup[MGA_CTXREG_FCOL] = col; + mmesa->dirty |= MGA_UPLOAD_CTX; + + mmesa->blend_flags &= ~MGA_BLEND_ENV_COLOR; + + /* Actually just require all four components to be + * equal. This permits a single-pass GL_BLEND. + * + * More complex multitexture/multipass fallbacks + * for blend can be done later. + */ + if (mmesa->envcolor != 0x0 && mmesa->envcolor != 0xffffffff) + mmesa->blend_flags |= MGA_BLEND_ENV_COLOR; + } + } } -/* - * mgaTexImage - */ -void mgaTexImage( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj, GLint level, - GLint internalFormat, - const struct gl_texture_image *image ) + +static void mgaDDTexImage( GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj, GLint level, + GLint internalFormat, + const struct gl_texture_image *image ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaTextureObjectPtr t; + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + mgaTextureObjectPtr t; - mgaMsg( 10,"mgaTexImage( %p, level %i )\n", tObj, level ); - - /* just free the mga texture if it exists, it will be recreated at - mgaUpdateTextureState time. */ - t = (mgaTextureObjectPtr) tObj->DriverData; - if ( t ) { - if (t->bound) FLUSH_BATCH(mmesa); - /* if this is the current object, it will force an update */ - mgaDestroyTexObj( mmesa, t ); - mmesa->new_state |= MGA_NEW_TEXTURE; - } + /* just free the mga texture if it exists, it will be recreated at + mgaUpdateTextureState time. */ + t = (mgaTextureObjectPtr) tObj->DriverData; + if ( t ) { + if (t->bound) FLUSH_BATCH(mmesa); + /* if this is the current object, it will force an update */ + mgaDestroyTexObj( mmesa, t ); + mmesa->new_state |= MGA_NEW_TEXTURE; + } + + if (0) + fprintf(stderr, "mgaDDTexImage tObj %p, level %d, image %p\n", + tObj, level, image); + } -/* - * mgaTexSubImage - */ -void mgaTexSubImage( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLint internalFormat, - const struct gl_texture_image *image ) +static void mgaDDTexSubImage( GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLint internalFormat, + const struct gl_texture_image *image ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaTextureObjectPtr t; - - mgaMsg(10,"mgaTexSubImage() Size: %d,%d of %d,%d; Level %d\n", - width, height, image->Width,image->Height, level); + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + mgaTextureObjectPtr t; - t = (mgaTextureObjectPtr) tObj->DriverData; + t = (mgaTextureObjectPtr) tObj->DriverData; - /* just free the mga texture if it exists, it will be recreated at - mgaUpdateTextureState time. */ - t = (mgaTextureObjectPtr) tObj->DriverData; - if ( t ) { - if (t->bound) FLUSH_BATCH(mmesa); - /* if this is the current object, it will force an update */ - mgaDestroyTexObj( mmesa, t ); - mmesa->new_state |= MGA_NEW_TEXTURE; - } + /* just free the mga texture if it exists, it will be recreated at + mgaUpdateTextureState time. */ + t = (mgaTextureObjectPtr) tObj->DriverData; + if ( t ) { + if (t->bound) FLUSH_BATCH(mmesa); + /* if this is the current object, it will force an update */ + mgaDestroyTexObj( mmesa, t ); + mmesa->new_state |= MGA_NEW_TEXTURE; + } #if 0 - /* the texture currently exists, so directly update it */ - mgaUploadSubImage( t, level, xoffset, yoffset, width, height ); + /* the texture currently exists, so directly update it */ + mgaUploadSubImage( t, level, xoffset, yoffset, width, height ); #endif } + + /* * mgaTexParameter * This just changes variables and flags for a state update, which * will happen at the next mgaUpdateTextureState */ -void mgaTexParameter( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj, - GLenum pname, const GLfloat *params ) +static void +mgaDDTexParameter( GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj, + GLenum pname, const GLfloat *params ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaTextureObjectPtr t; - - mgaMsg( 10, "mgaTexParameter( %p, %i )\n", tObj, pname ); - - t = (mgaTextureObjectPtr) tObj->DriverData; - - /* if we don't have a hardware texture, it will be automatically - created with current state before it is used, so we don't have - to do anything now */ - if ( !t || target != GL_TEXTURE_2D ) { - return; - } - - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - if (t->bound) FLUSH_BATCH(mmesa); - mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter ); - break; - - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - if (t->bound) FLUSH_BATCH(mmesa); - mgaSetTexWrapping(t,tObj->WrapS,tObj->WrapT); - break; + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + mgaTextureObjectPtr t; + + t = (mgaTextureObjectPtr) tObj->DriverData; + + /* if we don't have a hardware texture, it will be automatically + created with current state before it is used, so we don't have + to do anything now */ + if ( !t || !t->bound || target != GL_TEXTURE_2D ) { + return; + } + + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + FLUSH_BATCH(mmesa); + mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter ); + break; + + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + FLUSH_BATCH(mmesa); + mgaSetTexWrapping(t,tObj->WrapS,tObj->WrapT); + break; - case GL_TEXTURE_BORDER_COLOR: - if (t->bound) FLUSH_BATCH(mmesa); - mgaSetTexBorderColor(t,tObj->BorderColor); - break; + case GL_TEXTURE_BORDER_COLOR: + FLUSH_BATCH(mmesa); + mgaSetTexBorderColor(t,tObj->BorderColor); + break; - default: - return; - } + default: + return; + } - mmesa->new_state |= MGA_NEW_TEXTURE; + mmesa->new_state |= MGA_NEW_TEXTURE; } -/* - * mgaBindTexture - */ -void mgaBindTexture( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaMsg( 10, "mgaBindTexture( %p )\n", tObj ); +static void +mgaDDBindTexture( GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj ) +{ + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + int unit = ctx->Texture.CurrentUnit; - FLUSH_BATCH(mmesa); + FLUSH_BATCH(mmesa); - if (mmesa->CurrentTexObj[ctx->Texture.CurrentUnit]) { - mmesa->CurrentTexObj[ctx->Texture.CurrentUnit]->bound = 0; - mmesa->CurrentTexObj[ctx->Texture.CurrentUnit] = 0; - } + if (mmesa->CurrentTexObj[unit]) { + mmesa->CurrentTexObj[unit]->bound &= ~(unit+1); + mmesa->CurrentTexObj[unit] = 0; + } - /* force the texture state to be updated - */ - MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE; + /* force the texture state to be updated + */ + MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE; } -/* - * mgaDeleteTexture - */ -void mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) + +static void +mgaDDDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaTextureObjectPtr t = (mgaTextureObjectPtr)tObj->DriverData; + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + mgaTextureObjectPtr t = (mgaTextureObjectPtr)tObj->DriverData; + + if ( t ) { + if (t->bound) { + FLUSH_BATCH(mmesa); + if (t->bound & TEX_0) mmesa->CurrentTexObj[0] = 0; + if (t->bound & TEX_1) mmesa->CurrentTexObj[1] = 0; + mmesa->new_state |= MGA_NEW_TEXTURE; + } - mgaMsg( 10, "mgaDeleteTexture( %p )\n", tObj ); - - if ( t ) { - if (t->bound) { - FLUSH_BATCH(mmesa); - mmesa->CurrentTexObj[t->bound-1] = 0; - mmesa->new_state |= MGA_NEW_TEXTURE; - } - - mgaDestroyTexObj( mmesa, t ); - mmesa->new_state |= MGA_NEW_TEXTURE; - } + mgaDestroyTexObj( mmesa, t ); + mmesa->new_state |= MGA_NEW_TEXTURE; + } } -/* Have to grab the lock to find out if anyone has kicked out our - * textures. - */ -GLboolean mgaIsTextureResident( GLcontext *ctx, struct gl_texture_object *t ) +static GLboolean +mgaDDIsTextureResident( GLcontext *ctx, struct gl_texture_object *t ) { - mgaTextureObjectPtr mt; - -/* LOCK_HARDWARE; */ - mt = (mgaTextureObjectPtr)t->DriverData; -/* UNLOCK_HARDWARE; */ - - return mt && mt->MemBlock; + mgaTextureObjectPtr mt = (mgaTextureObjectPtr)t->DriverData; + return mt && mt->MemBlock; } -void mgaDDInitTextureFuncs( GLcontext *ctx ) + +void +mgaDDInitTextureFuncs( GLcontext *ctx ) { - ctx->Driver.TexEnv = mgaTexEnv; - ctx->Driver.TexImage = mgaTexImage; - ctx->Driver.TexSubImage = mgaTexSubImage; - ctx->Driver.BindTexture = mgaBindTexture; - ctx->Driver.DeleteTexture = mgaDeleteTexture; - ctx->Driver.TexParameter = mgaTexParameter; + ctx->Driver.TexEnv = mgaDDTexEnv; + ctx->Driver.TexImage = mgaDDTexImage; + ctx->Driver.TexSubImage = mgaDDTexSubImage; + ctx->Driver.BindTexture = mgaDDBindTexture; + ctx->Driver.DeleteTexture = mgaDDDeleteTexture; + ctx->Driver.TexParameter = mgaDDTexParameter; ctx->Driver.UpdateTexturePalette = 0; - ctx->Driver.IsTextureResident = mgaIsTextureResident; + ctx->Driver.IsTextureResident = mgaDDIsTextureResident; } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatris.c b/xc/lib/GL/mesa/src/drv/mga/mgatris.c index bf38066ee..d63796946 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgatris.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgatris.c @@ -33,22 +33,27 @@ #include "pipeline.h" #include "mm.h" -#include "mgalib.h" +#include "mgacontext.h" #include "mgatris.h" #include "mgavb.h" -#include "mgalog.h" static void mga_null_quad( GLcontext *ctx, GLuint v0, - GLuint v1, GLuint v2, GLuint v3, GLuint pv ) { + GLuint v1, GLuint v2, GLuint v3, GLuint pv ) +{ } + static void mga_null_triangle( GLcontext *ctx, GLuint v0, - GLuint v1, GLuint v2, GLuint pv ) { + GLuint v1, GLuint v2, GLuint pv ) +{ } -static void mga_null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) { + +static void mga_null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) +{ } -static void mga_null_points( GLcontext *ctx, GLuint first, GLuint last ) { +static void mga_null_points( GLcontext *ctx, GLuint first, GLuint last ) +{ } @@ -66,17 +71,6 @@ static quad_func quad_tab[0x10]; static line_func line_tab[0x10]; static points_func points_tab[0x10]; -static void mgaPrintRenderState( const char *msg, GLuint state ) -{ - fprintf(stderr, "%s: (%x) %s%s%s%s%s\n", - msg, state, - (state & MGA_FLAT_BIT) ? "flat, " : "", - (state & MGA_OFFSET_BIT) ? "offset, " : "", - (state & MGA_TWOSIDE_BIT) ? "twoside, " : "", - (state & MGA_NODRAW_BIT) ? "no-draw, " : "", - (state & MGA_FALLBACK_BIT) ? "fallback" : ""); -} - #define IND (0) #define TAG(x) x #include "mgatritmp.h" @@ -148,8 +142,8 @@ void mgaDDTrifuncInit() void mgaDDChooseRenderState(GLcontext *ctx) { mgaContextPtr mmesa = MGA_CONTEXT(ctx); - GLuint flags = ctx->TriangleCaps; - CARD32 index = 0; + GLuint flags = ctx->TriangleCaps; + GLuint index = 0; if (mmesa->Fallback) { mmesa->renderindex = MGA_FALLBACK_BIT; @@ -203,8 +197,3 @@ void mgaDDChooseRenderState(GLcontext *ctx) } } } - - - - - diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatris.h b/xc/lib/GL/mesa/src/drv/mga/mgatris.h index 038d11689..6fcf73d58 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgatris.h +++ b/xc/lib/GL/mesa/src/drv/mga/mgatris.h @@ -41,47 +41,123 @@ extern void mgaDDTrifuncInit( void ); #define MGA_NODRAW_BIT 0x8 #define MGA_FALLBACK_BIT 0x10 - - +extern int nrswaps; + + +#define VERTSIZE vertsize + +/* static float _v0[] = { */ +/* 242.202515, */ +/* 250.469604, */ +/* 0.961081, */ +/* 0.013503, */ +/* 0, */ +/* 0.000000, */ +/* 2.600000, */ +/* 0.000000, */ +/* 1.000000, */ +/* 0.600000 */ +/* }; */ + +/* static float _v1[] = { */ +/* 246.448914, */ +/* 54.697876, */ +/* 0.953817, */ +/* 0.014156, */ +/* 0, */ +/* 0.000000, */ +/* 2.600000, */ +/* 2.000000, */ +/* 1.000000, */ +/* 1.600000 */ +/* }; */ + +/* static float _v2[] = { */ +/* 55.999474, */ +/* 85.196106, */ +/* 0.942609, */ +/* 0.015165, */ +/* 0, */ +/* 0.000000, */ +/* 0.600000, */ +/* 2.000000, */ +/* 0.000000, */ +/* 1.600000, */ +/* }; */ static __inline void mga_draw_triangle( mgaContextPtr mmesa, mgaVertex *v0, mgaVertex *v1, mgaVertex *v2 ) { - mgaUI32 vertsize = mmesa->vertsize; - mgaUI32 *wv = mgaAllocVertexDwordsInline( mmesa, 3 * vertsize ); + GLuint vertsize = mmesa->vertsize; + GLuint *wv = mgaAllocVertexDwordsInline( mmesa, 3 * VERTSIZE ); int j; + (void) vertsize; + +/* for (j = 0 ; j < vertsize ; j++) */ +/* fprintf(stderr, "v0 %d: %f 0x%x\n", j, v0->f[j], v0->ui[j]); */ + +/* for (j = 0 ; j < vertsize ; j++) */ +/* fprintf(stderr, "v1 %d: %f 0x%x\n", j, v1->f[j], v1->ui[j]); */ + +/* for (j = 0 ; j < vertsize ; j++) */ +/* fprintf(stderr, "v2 %d: %f 0x%x\n", j, v2->f[j], v2->ui[j]); */ + +/* v0 = (mgaVertex *)_v0; */ +/* v1 = (mgaVertex *)_v1; */ +/* v2 = (mgaVertex *)_v2; */ + + +/* if (v0->v.x < 0 || v0->v.x > 1920 || */ +/* v0->v.y < 0 || v0->v.y > 1440 || */ +/* v0->v.z < 0 || v0->v.z > 1) */ +/* fprintf(stderr, "v0 %f %f %f %f\n", v0->v.x, v0->v.y, v0->v.z, v0->v.rhw); */ + + +/* if (v1->v.x < 0 || v1->v.x > 1920 || */ +/* v1->v.y < 0 || v1->v.y > 1440 || */ +/* v1->v.z < 0 || v1->v.z > 1) */ +/* fprintf(stderr, "v1 %f %f %f %f\n", v1->v.x, v1->v.y, v1->v.z, v1->v.rhw); */ + +/* if (v2->v.x < 0 || v2->v.x > 1920 || */ +/* v2->v.y < 0 || v2->v.y > 1440 || */ +/* v2->v.z < 0 || v2->v.z > 1) */ +/* fprintf(stderr, "v2 %f %f %f %f\n", v2->v.x, v2->v.y, v2->v.z, v2->v.rhw); */ + + #if defined (USE_X86_ASM) - /* GTH: We can safely assume the vertex stride is some number of - * dwords, and thus a "rep movsd" is okay. The vb pointer is - * automagically updated with this instruction, so we don't have - * to manually take care of incrementing it. - */ - __asm__ __volatile__( "rep ; movsl" - : "=%c" (j) - : "0" (vertsize), "D" ((long)wv), "S" ((long)v0) - : "memory" ); - __asm__ __volatile__( "rep ; movsl" - : "=%c" (j) - : "0" (vertsize), "S" ((long)v1) - : "memory" ); - __asm__ __volatile__( "rep ; movsl" - : "=%c" (j) - : "0" (vertsize), "S" ((long)v2) - : "memory" ); + /* GTH: We can safely assume the vertex stride is some number of + * dwords, and thus a "rep movsd" is okay. The vb pointer is + * automagically updated with this instruction, so we don't have + * to manually take care of incrementing it. + */ + __asm__ __volatile__( "rep ; movsl" + : "=%c" (j) + : "0" (VERTSIZE), "D" ((long)wv), "S" ((long)v0) + : "memory" ); + __asm__ __volatile__( "rep ; movsl" + : "=%c" (j) + : "0" (VERTSIZE), "S" ((long)v1) + : "memory" ); + __asm__ __volatile__( "rep ; movsl" + : "=%c" (j) + : "0" (VERTSIZE), "S" ((long)v2) + : "memory" ); #else - for (j = 0 ; j < vertsize ; j++) - wv[j] = v0->ui[j]; + { + for (j = 0 ; j < vertsize ; j++) + wv[j] = v0->ui[j]; - wv += vertsize; - for (j = 0 ; j < vertsize ; j++) - wv[j] = v1->ui[j]; + wv += VERTSIZE; + for (j = 0 ; j < vertsize ; j++) + wv[j] = v1->ui[j]; - wv += vertsize; - for (j = 0 ; j < vertsize ; j++) - wv[j] = v2->ui[j]; + wv += VERTSIZE; + for (j = 0 ; j < vertsize ; j++) + wv[j] = v2->ui[j]; + } #endif } @@ -89,39 +165,39 @@ static __inline void mga_draw_triangle( mgaContextPtr mmesa, static __inline void mga_draw_point( mgaContextPtr mmesa, mgaVertex *tmp, float sz ) { - mgaUI32 vertsize = mmesa->vertsize; - mgaUI32 *wv = mgaAllocVertexDwords( mmesa, 6*vertsize); + GLuint vertsize = mmesa->vertsize; + GLuint *wv = mgaAllocVertexDwords( mmesa, 6*VERTSIZE); int j; *(float *)&wv[0] = tmp->v.x - sz; *(float *)&wv[1] = tmp->v.y - sz; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp->v.x + sz; *(float *)&wv[1] = tmp->v.y - sz; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp->v.x + sz; *(float *)&wv[1] = tmp->v.y + sz; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp->v.x + sz; *(float *)&wv[1] = tmp->v.y + sz; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp->v.x - sz; *(float *)&wv[1] = tmp->v.y + sz; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp->v.x - sz; *(float *)&wv[1] = tmp->v.y - sz; @@ -135,8 +211,8 @@ static __inline void mga_draw_line( mgaContextPtr mmesa, const mgaVertex *tmp1, float width ) { - mgaUI32 vertsize = mmesa->vertsize; - mgaUI32 *wv = mgaAllocVertexDwords( mmesa, 6 * vertsize ); + GLuint vertsize = mmesa->vertsize; + GLuint *wv = mgaAllocVertexDwords( mmesa, 6 * VERTSIZE ); float dx, dy, ix, iy; int j; @@ -156,37 +232,37 @@ static __inline void mga_draw_line( mgaContextPtr mmesa, *(float *)&wv[1] = tmp0->v.y - iy; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp0->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp1->v.x + ix; *(float *)&wv[1] = tmp1->v.y + iy; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp1->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp0->v.x + ix; *(float *)&wv[1] = tmp0->v.y + iy; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp0->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp0->v.x - ix; *(float *)&wv[1] = tmp0->v.y - iy; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp0->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp1->v.x - ix; *(float *)&wv[1] = tmp1->v.y - iy; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp1->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp1->v.x + ix; *(float *)&wv[1] = tmp1->v.y + iy; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp1->ui[j]; - wv += vertsize; + wv += VERTSIZE; } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgavb.c b/xc/lib/GL/mesa/src/drv/mga/mgavb.c index cc9066fda..dec13514a 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgavb.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgavb.c @@ -25,9 +25,10 @@ */ /* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgavb.c,v 1.5 2000/08/28 02:43:13 tsi Exp $ */ -#include "mgalib.h" +#include "mgacontext.h" #include "mgavb.h" -#include "mgalog.h" +#include "mga_xmesa.h" + #include "stages.h" #include "mem.h" @@ -83,12 +84,13 @@ } -#define COORD \ - GLfloat *win = VB->Win.data[i]; \ +#define COORD \ + GLfloat *win = VB->Win.data[i]; \ v->v.rhw = win[3]; \ v->v.z = depth_scale * win[2]; \ - v->v.x = win[0] + xoffset; \ - v->v.y = - win[1] + yoffset; + v->v.x = win[0] + xoffset; \ + v->v.y = - win[1] + yoffset; + #define NOP @@ -181,7 +183,7 @@ SETUPFUNC(rs_gfst0t1, NOP,COL,TEX0,TEX1,TEX0_4,SPC,FOG) static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end) { - mgaError("mgaRasterSetup(): invalid combination\n"); + fprintf(stderr, "mgaRasterSetup(): invalid combination\n"); } typedef void (*setupFunc)(struct vertex_buffer *,GLuint,GLuint); @@ -256,6 +258,7 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx) { mgaContextPtr mmesa = MGA_CONTEXT( ctx ); int funcindex = (MGA_WIN_BIT | MGA_RGBA_BIT); + int multi = mmesa->multitex; mmesa->vertsize = 8; mmesa->tmu_source[0] = 0; @@ -265,7 +268,7 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx) mmesa->multitex = 0; mmesa->blend_flags &= ~MGA_BLEND_MULTITEX; - if (ctx->Texture.Enabled & 0xf) { + if (ctx->Texture.ReallyEnabled & 0xf) { /* This doesn't work for non-RGBA textures if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE) funcindex &= ~MGA_RGBA_BIT; @@ -282,8 +285,8 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx) funcindex |= MGA_TEX0_BIT; } - if (ctx->Texture.Enabled & 0xf0) { - if (ctx->Texture.Enabled & 0xf) { + if (ctx->Texture.ReallyEnabled & 0xf0) { + if (ctx->Texture.ReallyEnabled & 0xf) { mmesa->multitex = 1; mmesa->vertsize = 10; mmesa->blend_flags |= MGA_BLEND_MULTITEX; @@ -312,6 +315,19 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx) } } +/* if (mmesa->multitex == 0) { */ +/* mmesa->tmu_source[1] = mmesa->tmu_source[0]; */ +/* mmesa->tex_dest[1] = mmesa->tex_dest[0]; */ +/* mmesa->vertsize = 10; */ +/* mmesa->multitex = 1; */ +/* funcindex |= MGA_TEX0_BIT|MGA_TEX1_BIT; */ +/* } */ + +/* mmesa->vertsize = 10; */ + if (multi != mmesa->multitex) + mmesa->new_state |= MGA_NEW_WARP; + + /* Not really a good place to do this - need to make the mga state * management code more event-driven so this can be calculated for * free. @@ -423,11 +439,6 @@ static void FatalError( char *s ) } -#ifndef ALIGN_MALLOC -#define ALIGN_MALLOC(x,y) malloc(y) -#define ALIGN_FREE free -#endif - void mgaDDResizeVB( struct vertex_buffer *VB, GLuint size ) { mgaVertexBufferPtr mvb = MGA_DRIVER_DATA(VB); @@ -435,8 +446,8 @@ void mgaDDResizeVB( struct vertex_buffer *VB, GLuint size ) while (mvb->size < size) mvb->size *= 2; - free( mvb->vert_store ); - mvb->vert_store = malloc( sizeof(mgaVertex) * mvb->size + 31); + FREE( mvb->vert_store ); + mvb->vert_store = MALLOC( sizeof(mgaVertex) * mvb->size + 31); if (!mvb->vert_store) FatalError("mga-glx: out of memory !\n"); @@ -448,15 +459,15 @@ void mgaDDResizeVB( struct vertex_buffer *VB, GLuint size ) FatalError("mga-glx: out of memory !\n"); ALIGN_FREE( VB->ClipMask ); - VB->ClipMask = (GLubyte *)ALIGN_MALLOC(4, sizeof(GLubyte) * mvb->size); + VB->ClipMask = (GLubyte *)ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 32); if (!VB->ClipMask) FatalError("mga-glx: out of memory !\n"); if (VB->Type == VB_IMMEDIATE) { - free( mvb->primitive ); - free( mvb->next_primitive ); - mvb->primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size ); - mvb->next_primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size ); + FREE( mvb->primitive ); + FREE( mvb->next_primitive ); + mvb->primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size ); + mvb->next_primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size ); if (!mvb->primitive || !mvb->next_primitive) FatalError("mga-glx: out of memory!"); } @@ -467,14 +478,14 @@ void mgaDDRegisterVB( struct vertex_buffer *VB ) { mgaVertexBufferPtr mvb; - mvb = (mgaVertexBufferPtr)calloc( 1, sizeof(*mvb) ); + mvb = (mgaVertexBufferPtr)MALLOC( sizeof(*mvb) ); /* This looks like it allocates a lot of memory, but it basically * just sets an upper limit on how much can be used - nothing like * this amount will ever be turned into 'real' memory. */ mvb->size = VB->Size * 5; - mvb->vert_store = malloc( sizeof(mgaVertex) * mvb->size + 31); + mvb->vert_store = MALLOC( sizeof(mgaVertex) * mvb->size + 31); if (!mvb->vert_store) FatalError("mga-glx: out of memory !\n"); @@ -485,12 +496,12 @@ void mgaDDRegisterVB( struct vertex_buffer *VB ) FatalError("mga-glx: out of memory !\n"); ALIGN_FREE( VB->ClipMask ); - VB->ClipMask = (GLubyte *)ALIGN_MALLOC(4, sizeof(GLubyte) * mvb->size); + VB->ClipMask = (GLubyte *)ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 32); if (!VB->ClipMask) FatalError("mga-glx: out of memory !\n"); - mvb->primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size ); - mvb->next_primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size ); + mvb->primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size ); + mvb->next_primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size ); if (!mvb->primitive || !mvb->next_primitive) FatalError("mga-glx: out of memory!"); @@ -503,11 +514,11 @@ void mgaDDUnregisterVB( struct vertex_buffer *VB ) mgaVertexBufferPtr mvb = MGA_DRIVER_DATA(VB); if (mvb) { - if (mvb->vert_store) free(mvb->vert_store); - if (mvb->primitive) free(mvb->primitive); - if (mvb->next_primitive) free(mvb->next_primitive); + if (mvb->vert_store) FREE(mvb->vert_store); + if (mvb->primitive) FREE(mvb->primitive); + if (mvb->next_primitive) FREE(mvb->next_primitive); gl_vector1ui_free( &mvb->clipped_elements ); - free(mvb); + FREE(mvb); VB->driver_data = 0; } } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgavb.h b/xc/lib/GL/mesa/src/drv/mga/mgavb.h index cc902ae0f..c79fd5b6e 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgavb.h +++ b/xc/lib/GL/mesa/src/drv/mga/mgavb.h @@ -30,7 +30,6 @@ #include "types.h" #include "vb.h" -#include "mgacommon.h" /* common datatypes for the mga warp engines */ @@ -67,7 +66,7 @@ typedef struct mga_warp_vertex_t { union mga_vertex_t { mga_warp_vertex v; float f[16]; - mgaUI32 ui[16]; + GLuint ui[16]; }; typedef union mga_vertex_t mgaVertex; @@ -82,9 +81,9 @@ struct mga_vertex_buffer_t { void *vert_store; GLuint size; - mgaUI32 *vert_buf; - mgaUI32 *elt_buf; - mgaUI32 vert_phys_start; + GLuint *vert_buf; + GLuint *elt_buf; + GLuint vert_phys_start; }; typedef struct mga_vertex_buffer_t *mgaVertexBufferPtr; diff --git a/xc/lib/GL/mesa/src/drv/r128/Imakefile b/xc/lib/GL/mesa/src/drv/r128/Imakefile index 049428b46..3b6e0a2b5 100644 --- a/xc/lib/GL/mesa/src/drv/r128/Imakefile +++ b/xc/lib/GL/mesa/src/drv/r128/Imakefile @@ -262,8 +262,7 @@ MESA_INCLUDES = -I. -I.. -I../../include \ MMX_OBJS = ../../X86/mmx_blend.o -XCOMM Disabling 3Dnow code for the time being. -#if 0 +#ifdef MesaUse3DNow 3DNOW_SRCS = ../../X86/3dnow.c \ ../../X86/3dnow_norm_raw.S \ ../../X86/3dnow_xform_masked1.S \ diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_vb.c b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c index bb846701c..326b0b6e6 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_vb.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c @@ -40,7 +40,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_cce.h" #include "r128_state.h" #include "r128_vb.h" - +#include "mem.h" #include "stages.h" #define TEX0 \ @@ -423,8 +423,8 @@ void r128DDResizeVB(struct vertex_buffer *VB, GLuint size) exit(1); } - free(VB->ClipMask); - VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * r128vb->size); + ALIGN_FREE(VB->ClipMask); + VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * r128vb->size, 4); if (!VB->ClipMask) { fprintf(stderr, "Cannot allocate clipmask! Exiting...\n"); exit(1); @@ -454,8 +454,8 @@ void r128DDRegisterVB(struct vertex_buffer *VB) exit(1); } - free(VB->ClipMask); - VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * r128vb->size); + ALIGN_FREE(VB->ClipMask); + VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * r128vb->size, 4); if (!VB->ClipMask) { fprintf(stderr, "Cannot allocate clipmask! Exiting...\n"); exit(1); diff --git a/xc/lib/GL/mesa/src/drv/sis/Imakefile b/xc/lib/GL/mesa/src/drv/sis/Imakefile index cdcfcaf78..56f93a157 100644 --- a/xc/lib/GL/mesa/src/drv/sis/Imakefile +++ b/xc/lib/GL/mesa/src/drv/sis/Imakefile @@ -257,7 +257,7 @@ LinkSourceFile(xdriP.h, ../../X) MMX_OBJS = ../../X86/mmx_blend.o -#if MesaUse3DNow +#ifdef MesaUse3DNow 3DNOW_SRCS = ../../X86/3dnow.c \ ../../X86/3dnow_norm_raw.S \ ../../X86/3dnow_xform_masked1.S \ diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c b/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c index 935a220e6..e9ce26d30 100644 --- a/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c +++ b/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c @@ -40,7 +40,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # include "xf86fbman.h" #else # include "drm.h" -# include "sis_drm_public.h" +# include "sis_drm.h" # include <sys/ioctl.h> #endif diff --git a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile index 05ad70e5b..43d62f0c4 100644 --- a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile +++ b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile @@ -13,7 +13,7 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL #endif #if BuildXF86DRI - DRI_DEFINES = GlxDefines -DFX -DFX_GLIDE3 -DGLIDE3 -DDRIVERTS + DRI_DEFINES = GlxDefines -DFX_GLIDE3 -DDRIVERTS DRI_INCLUDES = -I../../../../dri -I../../../../glx \ -I../../../dri \ -I$(TOP)/include -I$(TOP)/include/GL \ @@ -25,32 +25,6 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL MESA_INCLUDES = -I. -I.. -I../../include \ -I../../../../dri/drm -LinkSourceFile(fxclip.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxcliptmp.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxcva.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxcva.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxcvatmp.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxdd.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxddspan.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxddtex.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxdrv.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxfastpath.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxfasttmp.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxglidew.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxglidew.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxpipeline.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxrender.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxsanity.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxsdettmp.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxsetup.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxstripdet.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxtexman.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxtrifuncs.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxtritmp.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxvsetup.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxvsetup.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxvs_tmp.h, $(MESASRCDIR)/src/FX) - DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) \ -I$(GLIDE3INCDIR) @@ -71,6 +45,14 @@ LinkSourceFile(fxvs_tmp.h, $(MESASRCDIR)/src/FX) ../../../../dri/drm/xf86drmRandom.o \ ../../../../dri/drm/xf86drmSL.o +#ifdef GlxSoProf + HIOBJS = ../../../../highpc.o + LOOBJS = ../../../../lowpc.o +#else + HIOBJS = + LOOBJS = +#endif + TDFXSRCS = tdfx_xmesa.c tdfx_init.c tdfx_inithw.c \ fxclip.c fxcva.c fxdd.c fxddspan.c fxddtex.c fxfastpath.c \ fxglidew.c fxpipeline.c fxrender.c fxsanity.c fxsetup.c \ @@ -246,7 +228,7 @@ LinkSourceFile(fxvs_tmp.h, $(MESASRCDIR)/src/FX) MMX_OBJS = ../../X86/mmx_blend.o -#if MesaUse3DNow +#ifdef MesaUse3DNow 3DNOW_SRCS = ../../X86/3dnow.c \ ../../X86/3dnow_norm_raw.S \ ../../X86/3dnow_xform_masked1.S \ @@ -272,15 +254,41 @@ LinkSourceFile(fxvs_tmp.h, $(MESASRCDIR)/src/FX) ../../X86/vertex_3dnow.o #endif +#ifdef MesaUseKatmai + KATMAI_SRCS = ../../X86/katmai.c \ + ../../X86/katmai_norm_raw.S \ + ../../X86/katmai_xform_masked1.S \ + ../../X86/katmai_xform_masked2.S \ + ../../X86/katmai_xform_masked3.S \ + ../../X86/katmai_xform_masked4.S \ + ../../X86/katmai_xform_raw1.S \ + ../../X86/katmai_xform_raw2.S \ + ../../X86/katmai_xform_raw3.S \ + ../../X86/katmai_xform_raw4.S \ + ../../X86/vertex_katmai.S + + KATMAI_OBJS = ../../X86/katmai.o \ + ../../X86/katmai_norm_raw.o \ + ../../X86/katmai_xform_masked1.o \ + ../../X86/katmai_xform_masked2.o \ + ../../X86/katmai_xform_masked3.o \ + ../../X86/katmai_xform_masked4.o \ + ../../X86/katmai_xform_raw1.o \ + ../../X86/katmai_xform_raw2.o \ + ../../X86/katmai_xform_raw3.o \ + ../../X86/katmai_xform_raw4.o \ + ../../X86/vertex_katmai.o #endif - ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) - ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) +#endif - SRCS = $(DRISRCS) $(DRMSRCS) $(TDFXSRCS) $(MESASRCS) $(ASMSRCS) - OBJS = $(DRIOBJS) $(DRMOBJS) $(TDFXOBJS) $(MESAOBJS) $(ASMOBJS) + ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) $(KATMAI_SRCS) + ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS) -REQUIREDLIBS = -l$(GLIDE3LIBNAME) MathLibrary + SRCS = $(LOSRCS) $(DRISRCS) $(DRMSRCS) $(TDFXSRCS) $(MESASRCS) $(ASMSRCS) $(HISRCS) + OBJS = $(LOOBJS) $(DRIOBJS) $(DRMOBJS) $(TDFXOBJS) $(MESAOBJS) $(ASMOBJS) $(HIOBJS) + +REQUIREDLIBS = -lglide3x -lm #if !GlxBuiltInTdfx REQUIREDLIBS += -L../../../.. -lGL #endif @@ -306,6 +314,12 @@ ALL_OBJS = $(OBJS) ALL_DEPS = DONE SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS)) InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri) + +#ifdef GlxSoProf +SOPROF_LIBNAME = _tdfx_dri_p +NormalDepLibraryTarget($(SOPROF_LIBNAME),$(ALL_DEPS),$(ALL_OBJS)) +InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri) +#endif #endif DependTarget() diff --git a/xc/programs/Xserver/GL/dri/dri.c b/xc/programs/Xserver/GL/dri/dri.c index 2d1ee7bc9..aa5d75529 100644 --- a/xc/programs/Xserver/GL/dri/dri.c +++ b/xc/programs/Xserver/GL/dri/dri.c @@ -113,6 +113,8 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) if (fd < 0) { /* failed to open DRM */ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] drmOpen failed\n"); return FALSE; } @@ -123,7 +125,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIInfo->drmDriverName); } - pDRIPriv = (DRIScreenPrivPtr) xalloc(sizeof(DRIScreenPrivRec)); + pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec)); if (!pDRIPriv) { pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; return FALSE; @@ -139,6 +141,9 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIPriv->directRenderingSupport = FALSE; pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; drmClose(pDRIPriv->drmFD); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] drmSetBusid failed (%d, %s)\n", + pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString); return FALSE; } @@ -158,6 +163,8 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIPriv->directRenderingSupport = FALSE; pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; drmClose(pDRIPriv->drmFD); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] drmAddMap failed\n"); return FALSE; } DRIDrvMsg(pScreen->myNum, X_INFO, @@ -172,6 +179,8 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIPriv->directRenderingSupport = FALSE; pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; drmClose(pDRIPriv->drmFD); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] drmMap failed\n"); return FALSE; } DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA 0x%08lx to %p\n", @@ -188,6 +197,8 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize); drmClose(pDRIPriv->drmFD); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] drmAddMap failed\n"); return FALSE; } DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = 0x%08lx\n", @@ -267,7 +278,7 @@ DRIFinishScreenInit(ScreenPtr pScreen) /* allocate memory for hidden context store */ pDRIPriv->hiddenContextStore - = (void *)xalloc(pDRIInfo->contextSize); + = (void *)xcalloc(1, pDRIInfo->contextSize); if (!pDRIPriv->hiddenContextStore) { DRIDrvMsg(pScreen->myNum, X_ERROR, "failed to allocate hidden context\n"); @@ -277,7 +288,7 @@ DRIFinishScreenInit(ScreenPtr pScreen) /* allocate memory for partial 3D context store */ pDRIPriv->partial3DContextStore - = (void *)xalloc(pDRIInfo->contextSize); + = (void *)xcalloc(1, pDRIInfo->contextSize); if (!pDRIPriv->partial3DContextStore) { DRIDrvMsg(pScreen->myNum, X_ERROR, "[DRI] failed to allocate partial 3D context\n"); @@ -547,7 +558,7 @@ DRICreateContextPrivFromHandle(ScreenPtr pScreen, contextPrivSize = sizeof(DRIContextPrivRec) + pDRIPriv->pDriverInfo->contextSize; - if (!(pDRIContextPriv = xalloc(contextPrivSize))) { + if (!(pDRIContextPriv = xcalloc(1, contextPrivSize))) { return NULL; } pDRIContextPriv->pContextStore = (void *)(pDRIContextPriv + 1); @@ -1044,7 +1055,7 @@ DRIGetDeviceInfo(ScreenPtr pScreen, DRIInfoPtr DRICreateInfoRec(void) { - DRIInfoPtr inforec = (DRIInfoPtr)xalloc(sizeof(DRIInfoRec)); + DRIInfoPtr inforec = (DRIInfoPtr)xcalloc(1, sizeof(DRIInfoRec)); if (!inforec) return NULL; /* Initialize defaults */ @@ -1430,7 +1441,11 @@ static void DRISpinLockTimeout(drmLock *lock, int val, unsigned long timeout /* in mS */) { int count = 10000; +#ifndef __alpha__ char ret; +#else + int ret; +#endif long s_secs, s_usecs; long f_secs, f_usecs; long msecs; diff --git a/xc/programs/Xserver/hw/kdrive/trident/trident.c b/xc/programs/Xserver/hw/kdrive/trident/trident.c index 0447861b1..57076c487 100644 --- a/xc/programs/Xserver/hw/kdrive/trident/trident.c +++ b/xc/programs/Xserver/hw/kdrive/trident/trident.c @@ -1,5 +1,5 @@ /* - * $Id: trident.c,v 1.1.1.6 2000/09/23 21:12:18 alanh Exp $ + * $Id: trident.c,v 1.1.1.4.24.1 2000/10/18 13:03:03 alanh Exp $ * * Copyright © 1999 Keith Packard * diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h b/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h index ec6541041..9882cd133 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h +++ b/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.67 2000/08/11 21:12:48 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.72 2000/09/13 15:47:31 martin Exp $ */ /* * PCI Probe * @@ -86,7 +86,6 @@ #define PCI_VENDOR_PICOP 0x1066 #define PCI_VENDOR_MYLEX 0x1069 #define PCI_VENDOR_APPLE 0x106B -/* Yahama is a guess based on chipset */ #define PCI_VENDOR_YAMAHA 0x1073 #define PCI_VENDOR_NEXGEN 0x1074 #define PCI_VENDOR_QLOGIC 0x1077 @@ -98,6 +97,7 @@ #define PCI_VENDOR_SUN 0x108E #define PCI_VENDOR_DIAMOND 0x1092 #define PCI_VENDOR_CMD 0x1095 +#define PCI_VENDOR_APPIAN 0x1097 #define PCI_VENDOR_VISION 0x1098 #define PCI_VENDOR_BROOKTREE 0x109E #define PCI_VENDOR_SIERRA 0x10A8 @@ -478,7 +478,7 @@ #define PCI_CHIP_QUADRO2MXR 0x0113 #define PCI_CHIP_GEFORCE2GTS 0x0150 #define PCI_CHIP_GEFORCE2GTS_1 0x0151 -#define PCI_CHIP_GEFORCE2GTS_2 0x0152 +#define PCI_CHIP_GEFORCE2ULTRA 0x0152 #define PCI_CHIP_QUADRO2PRO 0x0153 /* NVIDIA & SGS */ @@ -556,6 +556,7 @@ #define PCI_CHIP_NM2097 0x0083 #define PCI_CHIP_NM2160 0x0004 #define PCI_CHIP_NM2200 0x0005 +#define PCI_CHIP_NM2230 0x0025 #define PCI_CHIP_NM2360 0x0006 #define PCI_CHIP_NM2380 0x0016 @@ -636,6 +637,7 @@ static SymTabRec xf86PCIVendorNameInfoData[] = { {PCI_VENDOR_SUN, "Sun"}, {PCI_VENDOR_DIAMOND, "Diamond"}, {PCI_VENDOR_CMD, "CMD"}, + {PCI_VENDOR_APPIAN, "Appian Graphics"}, {PCI_VENDOR_VISION, "Vision"}, {PCI_VENDOR_BROOKTREE, "BrookTree"}, {PCI_VENDOR_SIERRA, "Sierra"}, @@ -982,6 +984,7 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = { {PCI_CHIP_TI_PERMEDIA2, "Permedia 2",0}, {PCI_CHIP_PCI_1130, "PCI 1130",0}, {PCI_CHIP_PCI_1131, "PCI 1131",0}, + {0x8019, "TSB12LV23 IEEE1394/FireWire",0}, {0x0000, NULL,0}}}, #ifdef VENDOR_INCLUDE_NONVIDEO {PCI_VENDOR_SONY, { @@ -1036,6 +1039,9 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = { {0x0001, "Bandit",0 }, {0x0002, "Grand Central",0 }, {0x000E, "Hydra",0 }, + {0x0019, "Keylargo USB",0 }, + {0x0020, "Uni-North AGP",0 }, + {0x0022, "Keylargo I/O",0 }, {0x0000, NULL,0}}}, #ifdef INCLUDE_EMPTY_LISTS {PCI_VENDOR_NEXGEN, { @@ -1088,6 +1094,11 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = { {0x0646, "646",0 }, {0x0670, "670",0 }, {0x0000, NULL,0}}}, +#endif + {PCI_VENDOR_APPIAN, { + {0x3D32, "Jeronimo 2000 AGP",0 }, + {0x0000, NULL,0}}}, +#ifdef VENDOR_INCLUDE_NONVIDEO {PCI_VENDOR_VISION, { {0x0001, "QD 8500",0 }, {0x0002, "QD 8580",0 }, @@ -1156,6 +1167,7 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = { {PCI_CHIP_NM2093, "NM2093",0}, {PCI_CHIP_NM2160, "NM2160",0}, {PCI_CHIP_NM2200, "NM2200",0}, + {PCI_CHIP_NM2230, "NM2230 MagicMedia 256AV+",0}, {PCI_CHIP_NM2360, "NM2360",0}, {PCI_CHIP_NM2380, "NM2380",0}, #ifdef VENDOR_INCLUDE_NONVIDEO @@ -1189,7 +1201,7 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = { {PCI_CHIP_QUADRO2MXR, "GeForce2 MXR",0}, {PCI_CHIP_GEFORCE2GTS, "GeForce2 GTS",0}, {PCI_CHIP_GEFORCE2GTS_1,"GeForce2 GTS (rev 1)",0}, - {PCI_CHIP_GEFORCE2GTS_2,"GeForce2 GTS (rev 2)",0}, + {PCI_CHIP_GEFORCE2ULTRA,"GeForce2 ultra",0}, {PCI_CHIP_QUADRO2PRO, "Quadro 2 Pro",0}, {0x0000, NULL,0}}}, #ifdef VENDOR_INCLUDE_NONVIDEO diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml index c8e34f6d3..8d4acb0d6 100644 --- a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml +++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml @@ -12,7 +12,7 @@ <author> <htmlurl url="http://www.valinux.com/" name="VA Linux Systems, Inc."> Professional Services - Graphics. - <date>22 August 2000 + <date>10 October 2000 <ident> $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.7 2000/08/28 18:24:15 dawes Exp $ @@ -573,7 +573,7 @@ <p> The Voodoo3 DRI driver requires a special versions of the 3dfx Glide library. - It can be downloaded from the DRI web site. + It can be downloaded from the DRI website. <p> <sect2>Configuration <p> @@ -605,7 +605,7 @@ should be installed in /lib/modules/KERNEL-VERSION/misc/. It will be automatically loaded by the Xserver if needed. <p> - The DRI 3D driver for the Voodoo3 should be in + The DRI 3D driver for the Voodoo3 hould be in <tt>/usr/X11R6/lib/modules/dri/tdfx_dri.so</tt>. This will be automatically loaded by libGL.so. <p> @@ -614,6 +614,14 @@ <p> <itemize> <item> + If you try to run an OpenGL application and see an error message + similar to + <verb> + gd error (glide): gd error (glide): grSstSelect: non-existent SSTgd error (glide): grSstSelect: non-existent SSTS + </verb> + it means that you have the wrong version of the Glide library + for your hardware. + <item> 3D acceleration for Voodoo3 is only supported in the 16 bit/pixel screen mode. Use <tt/xdpyinfo/ to verify that all your visuals are depth 16. @@ -642,7 +650,42 @@ Applications which use that mode, such as the Performer Town demo, may become sluggish when falling back to software rendering to render in that mode. + <item> + The Voodoo3/Banshee driver reverts to software rendering under + the following conditions: + <itemize> + <item> + Setting <tt/GL_LIGHT_MODEL_COLOR_CONTROL/ to + <tt/GL_SEPARATE_SPECULAR_COLOR/. + <item> + Enabling line stippline or polygon stippling. + <item> + Enabling point smoothing or polygon smoothing. + <item> + Enabling line smoothing when line width is not 1.0. + That is, antialiased lines are done in hardware only when + the line width is 1.0. + <item> + Using 1-D or 3-D texture maps. + <item> + Using the GL_BLEND texture environment. + <item> + Using stencil operations. + <item> + Using the accumulation buffer. + <item> + Using <tt/glBlendEquation(GL_LOGIC_OP)/. + <item> + Using <tt/glDrawBuffer(GL_FRONT_AND_BACK)/. + <item> + Using <tt/glPolygonMode(face, GL_POINT)/ or + <tt/glPolygonMode(face, GL_LINE)/. + <item> + Using point size attenuation + (i.e. <tt/GL_DISTANCE_ATTENUATION_EXT/). + </itemize> </itemize> + <sect2>Known Problems <p> <itemize> @@ -654,7 +697,7 @@ clipping planes. The office.unc Performer model also suffers from this problem. <item> - The lowest mipmap level is sometimes mis-colored in trilinear- + The lowest mipmap level is sometimes miscolored in trilinear- sampled polygons. </itemize> @@ -666,7 +709,7 @@ The Voodoo5 DRI driver requires a special versions of the 3dfx Glide library, different than that used for Voodoo3 hardware. - It can be downloaded from the DRI web site. + It can be downloaded from the DRI website. <p> <sect2>Configuration <p> @@ -703,7 +746,7 @@ should be installed in /lib/modules/KERNEL-VERSION/misc/. It will be automatically loaded by the Xserver if needed. <p> - The DRI 3D driver for the Voodoo5 should be in + The DRI 3D driver for the Voodoo5 hould be in <tt>/usr/X11R6/lib/modules/dri/tdfx_dri.so</tt>. This will be automatically loaded by libGL.so. <p> @@ -725,7 +768,7 @@ Glide on older 3dfx hardware. <item> Different versions of Glide are needed for Voodoo3 and Voodoo5. - See the DRI web site's resources page to download the right + See the DRI website's resources page to download the right version of Glide. </itemize> @@ -740,6 +783,17 @@ The value of this variable indicates the maximum number of swap buffer commands can be buffered. Zero allows maximum frame rate. + <item> + Rendering with 16-bit per texel textures is faster than using + 32-bit per texel textures. The <tt/internalFormat/ parameter + to <tt/glTexImage2D/ can be used to control texel size. + <item> + The Voodoo5 driver reverts to software rendering under the + same conditions Voodoo3 with two exceptions. + First, stencil operations are implemented in hardware when the + screen is configured for 32 bits/pixel. + Second, the <tt/GL_BLEND/ texture env mode is fully supported in + hardware. </itemize> <sect2>Known Problems <p> @@ -749,7 +803,11 @@ be used via the tdfx DRI driver. <item> 24bpp screen modes are supported by the hardware but not by - the current driver. + the current driver. 32bpp is fully supported. + <item> + As of October, 2000 the second VSA-100 chip on the Voodoo5 is + not yet operational. Therefore, the board isn't being used to + its full capacity. </itemize> diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml index 15f2663ef..03b396ad2 100644 --- a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml +++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml @@ -459,7 +459,7 @@ To update your X locale information do the following: <verb> cd ~/DRI-CVS/build/xc/nls - xmkmf -a + ../config/util/xmkmf -a make make install </verb> diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c index d2997aacd..2e97a3c26 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c @@ -135,7 +135,7 @@ I810InitVisualConfigs(ScreenPtr pScreen) depth = 1; for (accum = 0; accum <= 1; accum++) { for (stencil = 0; stencil <= 1; stencil++) { - for (db = 0; db <= 1; db++) { + for (db = 1; db >= 0; db--) { pConfigs[i].vid = -1; pConfigs[i].class = -1; pConfigs[i].rgba = TRUE; @@ -171,7 +171,7 @@ I810InitVisualConfigs(ScreenPtr pScreen) pConfigs[i].stencilSize = 0; pConfigs[i].auxBuffers = 0; pConfigs[i].level = 0; - if (stencil) + if (stencil || accum) pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; else pConfigs[i].visualRating = GLX_NONE_EXT; @@ -850,9 +850,6 @@ I810DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) I810SetupForSolidFill(pScrn, 0, GXcopy, -1); while (nbox--) { - I810SelectBuffer(pScrn, I810_FRONT); - I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1, - pbox->x2-pbox->x1, pbox->y2-pbox->y1); I810SelectBuffer(pScrn, I810_BACK); I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1, pbox->x2-pbox->x1, pbox->y2-pbox->y1); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c index caab501c8..2e55a7849 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c @@ -1900,12 +1900,15 @@ I810CloseScreen(int scrnIndex, ScreenPtr pScreen) I810Ptr pI810 = I810PTR(pScrn); XAAInfoRecPtr infoPtr = pI810->AccelInfoRec; - + if (pScrn->vtSema == TRUE) { + I810Restore(pScrn); + vgaHWLock(hwp); + } #ifdef XF86DRI - if (pI810->directRenderingEnabled) { - I810DRICloseScreen(pScreen); - pI810->directRenderingEnabled=FALSE; - } + if (pI810->directRenderingEnabled) { + I810DRICloseScreen(pScreen); + pI810->directRenderingEnabled=FALSE; + } #endif if(pScrn->vtSema == TRUE) { diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c index 505f9d092..42893411d 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c @@ -50,7 +50,6 @@ int I810AllocLow( I810MemRange *result, I810MemRange *pool, int size ) return 1; } - int I810AllocHigh( I810MemRange *result, I810MemRange *pool, int size ) { if (size > pool->Size) return 0; @@ -62,7 +61,6 @@ int I810AllocHigh( I810MemRange *result, I810MemRange *pool, int size ) return 1; } - int I810AllocateGARTMemory( ScrnInfoPtr pScrn ) { unsigned long size = pScrn->videoRam * 1024; @@ -94,6 +92,7 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn ) if (!xf86BindGARTMemory(pScrn->scrnIndex, key, 0)) return FALSE; + pI810->SysMem.Start = 0; pI810->SysMem.Size = size; pI810->SysMem.End = size; @@ -135,6 +134,8 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn ) size); pI810->DcacheKey = -1; } + + /* Mouse cursor -- The i810 (crazy) needs a physical address in * system memory from which to upload the cursor. We get this from diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile index 4bb3168ad..abfc49e87 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile @@ -6,6 +6,11 @@ XCOMM #define IHaveModules #include <Server.tmpl> +#if BuildMatroxHal +#define IHaveSubdirs +SUBDIRS=hallib +#endif + #if BuildXF86DRI DRISRCS = mga_dri.c mga_warp.c mga_wrap.c DRIOBJS = mga_dri.o mga_warp.o mga_wrap.o @@ -14,17 +19,31 @@ DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri \ DRIDEFINES = $(GLX_DEFINES) #endif +#if UseMatroxHal +MGAHALSRCS = clientlx.c +MGAHALDEFINES = -DUSEMGAHAL +#if !BuildMatroxHal +MGAHALOBJS = clientlx.o HALlib/mgaHALlib.a +MGAHALINCLUDES = -IHALlib +#else +MGAHALOBJS = clientlx.o hallib/libmga_hal.a +MGAHALINCLUDES = -Ihallib +hallib/libmga_hal.a: $(SUBDIRS) +#endif +#endif + SRCS = mga_driver.c mga_hwcurs.c /* mga_cmap.c */ mga_dac3026.c mga_dacG.c \ mga_storm8.c mga_storm16.c mga_storm24.c mga_storm32.c mga_arc.c \ - mga_dga.c mga_shadow.c mga_video.c $(DRISRCS) + mga_dga.c mga_shadow.c mga_video.c $(MGAHALSRCS) $(DRISRCS) OBJS = mga_driver.o mga_hwcurs.o /* mga_cmap.o */ mga_dac3026.o mga_dacG.o \ mga_storm8.o mga_storm16.o mga_storm24.o mga_storm32.o mga_arc.o \ - mga_dga.o mga_shadow.o mga_video.o $(DRIOBJS) + mga_dga.o mga_shadow.o mga_video.o $(MGAHALOBJS) $(DRIOBJS) #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include #else -INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/fb \ +INCLUDES = -I. $(MGAHALINCLUDES) -I$(XF86COMSRC) -I$(XF86OSSRC) \ + -I$(SERVERSRC)/fb \ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi -I$(XF86SRC)/int10 \ -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa -I$(XF86SRC)/rac \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/fbdevhw \ @@ -36,7 +55,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/fb \ -I$(XF86OSSRC)/vbe $(DRIINCLUDES) #endif -DEFINES = $(DRIDEFINES) +DEFINES = $(MGAHALDEFINES) $(DRIDEFINES) #if MakeHasPosixVariableSubstitutions SubdirLibraryRule($(OBJS)) @@ -78,3 +97,9 @@ InstallDriverSDKNonExecFile(mga_video.c,$(DRIVERSDKDIR)/drivers/mga) InstallDriverSDKObjectModule(mga,$(DRIVERSDKMODULEDIR),drivers) +#if BuildMatroxHal +MakeSubdirs($(SUBDIRS)) +ForceSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) +#endif + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h index e246ba594..26da1dead 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h @@ -32,6 +32,11 @@ #include "mga_dri.h" #endif +#ifdef USEMGAHAL +#include "client.h" +#endif +#include "mga_bios.h" + #if !defined(EXTRADEBUG) #define INREG8(addr) MMIO_IN8(pMga->IOBase, addr) #define INREG16(addr) MMIO_IN16(pMga->IOBase, addr) @@ -58,6 +63,8 @@ void dbg_outreg32(ScrnInfoPtr,int,int); #define MGA_VERSION 4000 #define MGA_NAME "MGA" +#define MGA_C_NAME MGA +#define MGA_MODULE_DATA mgaModuleData #define MGA_DRIVER_NAME "mga" #define MGA_MAJOR_VERSION 1 #define MGA_MINOR_VERSION 0 @@ -137,6 +144,31 @@ typedef struct mgaSave { #endif typedef struct { + int lastInstance; +#ifdef USEMGAHAL + LPCLIENTDATA pClientStruct; + LPBOARDHANDLE pBoard; + LPMGAHWINFO pMgaHwInfo; +#endif + int refCount; + CARD32 masterFbAddress; + long masterFbMapSize; + CARD32 slaveFbAddress; + long slaveFbMapSize; + int mastervideoRam; + int slavevideoRam; + Bool directRenderingEnabled; + ScrnInfoPtr pScrn_1; + ScrnInfoPtr pScrn_2; +} MGAEntRec, *MGAEntPtr; + +typedef struct { +#ifdef USEMGAHAL + LPCLIENTDATA pClientStruct; + LPBOARDHANDLE pBoard; + LPMGAMODEINFO pMgaModeInfo; + LPMGAHWINFO pMgaHwInfo; +#endif EntityInfoPtr pEnt; MGABiosInfo Bios; MGABios2Info Bios2; @@ -238,6 +270,7 @@ typedef struct { int expandHeight; int expandY; #ifdef XF86DRI + int agp_mode; Bool have_quiescense; Bool directRenderingEnabled; DRIInfoPtr pDRIInfo; @@ -247,8 +280,20 @@ typedef struct { MGAConfigPrivPtr pVisualConfigsPriv; MGARegRec DRContextRegs; MGADRIServerPrivatePtr DRIServerInfo; + void (*GetQuiescence)(ScrnInfoPtr pScrn); #endif XF86VideoAdaptorPtr adaptor; + Bool SecondCrtc; + GDevPtr device; + /* The hardware's real SrcOrg */ + int realSrcOrg; + MGAEntPtr entityPrivate; + void (*SetupForSolidFill)(ScrnInfoPtr pScrn, int color, + int rop, unsigned int planemask); + void (*SubsequentSolidFillRect)(ScrnInfoPtr pScrn, + int x, int y, int w, int h); + void (*RestoreAccelState)(ScrnInfoPtr pScrn); + int allowedWidth; void (*VideoTimerCallback)(ScrnInfoPtr, Time); void (*PaletteLoadCallback)(ScrnInfoPtr); MGAPaletteInfo palinfo[256]; /* G400 hardware bug workaround */ @@ -303,6 +348,11 @@ Bool Mga16AccelInit(ScreenPtr pScreen); Bool Mga24AccelInit(ScreenPtr pScreen); Bool Mga32AccelInit(ScreenPtr pScreen); +void Mga8InitSolidFillRectFuncs(MGAPtr pMga); +void Mga16InitSolidFillRectFuncs(MGAPtr pMga); +void Mga24InitSolidFillRectFuncs(MGAPtr pMga); +void Mga32InitSolidFillRectFuncs(MGAPtr pMga); + void MGAPolyArcThinSolid(DrawablePtr, GCPtr, int, xArc*); Bool MGADGAInit(ScreenPtr pScreen); @@ -319,6 +369,8 @@ Bool MgaCleanupDma(ScrnInfoPtr pScrn); Bool MgaInitDma(ScrnInfoPtr pScrn, int prim_size); #ifdef XF86DRI Bool MgaLockUpdate(ScrnInfoPtr pScrn, drmLockFlags flags); +void mgaGetQuiescence(ScrnInfoPtr pScrn); +void mgaGetQuiescence_shared(ScrnInfoPtr pScrn); #endif void MGARefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void MGARefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c index 3c2fe556f..091dd3edb 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c @@ -24,7 +24,6 @@ #include "mga_bios.h" #include "mga_reg.h" -#include "mga_macros.h" #include "mga.h" #include "xf86DDC.h" @@ -83,6 +82,12 @@ static Bool MGAGInit(ScrnInfoPtr, DisplayModePtr); static void MGAGLoadPalette(ScrnInfoPtr, int, int*, LOCO*, VisualPtr); static Bool MGAG_i2cInit(ScrnInfoPtr pScrn); + +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +/* We don't need anymore: MGAGCalcClock and MGAGSetPCLK function */ +#ifndef USEMGAHAL /* * MGAGCalcClock - Calculate the PLL settings (m, n, p, s). * @@ -245,6 +250,10 @@ MGAGSetPCLK( ScrnInfoPtr pScrn, long f_out ) pReg->DacRegs[ MGA1064_PIX_PLLC_N ] = n & 0x7F; pReg->DacRegs[ MGA1064_PIX_PLLC_P ] = (p & 0x07) | ((s & 0x03) << 3); } +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif /* * MGAGInit @@ -283,6 +292,10 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) BppShift = pMga->BppShifts[(pLayout->bitsPerPixel >> 3) - 1]; +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL /* Allocate the DacRegs space if not done already */ if (pReg->DacRegs == NULL) { pReg->DacRegs = xnfcalloc(DACREGSIZE, 1); @@ -423,6 +436,10 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) default: FatalError("MGA: unsupported depth\n"); } +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif /* * This will initialize all of the generic VGA registers. @@ -503,23 +520,49 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) pVga->CRTC[21] = vd & 0xFF; pVga->CRTC[22] = (vt + 1) & 0xFF; - if (mode->Flags & V_DBLSCAN) - pVga->CRTC[9] |= 0x80; - +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL pReg->DacRegs[ MGA1064_CURSOR_BASE_ADR_LOW ] = pMga->FbCursorOffset >> 10; pReg->DacRegs[ MGA1064_CURSOR_BASE_ADR_HI ] = pMga->FbCursorOffset >> 18; +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif if (pMga->SyncOnGreen) { +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL pReg->DacRegs[ MGA1064_GEN_CTL ] &= ~0x20; +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif pReg->ExtVga[3] |= 0x40; } /* select external clock */ pVga->MiscOutReg |= 0x0C; - + +#ifndef USEMGAHAL + if (mode->Flags & V_DBLSCAN) + pVga->CRTC[9] |= 0x80; +#endif + +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL MGAGSetPCLK( pScrn, mode->Clock ); +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif /* This disables the VGA memory aperture */ pVga->MiscOutReg &= ~0x02; @@ -630,7 +673,10 @@ MGAGRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, CARD32 optionMask; MGAPtr pMga = MGAPTR(pScrn); - CHECK_DMA_QUIESCENT( pMga, pScrn ); +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL /* * Code is needed to get things back to bank zero. */ @@ -665,6 +711,10 @@ MGAGRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, pciSetBitsLong(pMga->PciTag, PCI_MGA_OPTION3, OPTION3_MASK, mgaReg->Option3); +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif /* restore CRTCEXT regs */ for (i = 0; i < 6; i++) OUTREG16(0x1FDE, (mgaReg->ExtVga[i] << 8) | i); @@ -712,12 +762,20 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, int i; MGAPtr pMga = MGAPTR(pScrn); - CHECK_DMA_QUIESCENT( pMga, pScrn ); + if(pMga->SecondCrtc == TRUE) return; +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL /* Allocate the DacRegs space if not done already */ if (mgaReg->DacRegs == NULL) { mgaReg->DacRegs = xnfcalloc(DACREGSIZE, 1); } +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif /* * Code is needed to get back to bank zero. @@ -731,6 +789,10 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, vgaHWSave(pScrn, vgaReg, VGA_SR_MODE | (saveFonts ? VGA_SR_FONTS : 0)); MGAGSavePalette(pScrn, vgaReg->DAC); +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL /* * The port I/O code necessary to read in the extended registers. */ @@ -742,6 +804,10 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, mgaReg->Option2 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION2); if (pMga->Chipset == PCI_CHIP_MGAG400) mgaReg->Option3 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION3); +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif for (i = 0; i < 6; i++) { @@ -833,8 +899,12 @@ MGAGSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) static Bool MGAGUseHWCursor(ScreenPtr pScrn, CursorPtr pCurs) { + MGAPtr pMga = MGAPTR(xf86Screens[pScrn->myNum]); + /* This needs to detect if its on the second dac */ if( XF86SCRNINFO(pScrn)->currentMode->Flags & V_DBLSCAN ) return FALSE; + if( pMga->SecondCrtc == TRUE ) + return FALSE; return TRUE; } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c index db75b5985..41b82801c 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.7 2000/08/25 13:42:37 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.5 2000/06/23 23:43:44 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -38,6 +38,11 @@ static void MGADRISwapContext(ScreenPtr pScreen, DRISyncType syncType, void *readContextStore, DRIContextType writeContextType, void *writeContextStore); +static void MGADRISwapContext_shared(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType readContextType, + void *readContextStore, + DRIContextType writeContextType, + void *writeContextStore); extern void Mga8DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index); extern void Mga8DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 index); @@ -145,7 +150,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen) case 24: break; case 16: - numConfigs = 4; + numConfigs = 8; if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), numConfigs))) { @@ -168,7 +173,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen) i = 0; depth = 1; for (accum = 0; accum <= 1; accum++) { - for (stencil = 0; stencil <= 0; stencil++) { /* no stencil for now */ + for (stencil = 0; stencil <= 1; stencil++) { /* no stencil for now */ for (db=1; db>=0; db--) { pConfigs[i].vid = -1; pConfigs[i].class = -1; @@ -229,7 +234,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen) break; case 32: - numConfigs = 4; + numConfigs = 8; if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), numConfigs))) { @@ -252,7 +257,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen) i = 0; depth = 1; for (accum = 0; accum <= 1; accum++) { - for (stencil = 0; stencil <= 0; stencil++) { /* no stencil for now */ + for (stencil = 0; stencil <= 1; stencil++) { for (db=1; db>=0; db--) { pConfigs[i].vid = -1; pConfigs[i].class = -1; @@ -282,7 +287,10 @@ MGAInitVisualConfigs(ScreenPtr pScreen) pConfigs[i].stereo = FALSE; pConfigs[i].bufferSize = 32; if (depth) - pConfigs[i].depthSize = 32; + if (stencil) + pConfigs[i].depthSize = 24; + else + pConfigs[i].depthSize = 32; else pConfigs[i].depthSize = 0; if (stencil) @@ -291,7 +299,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen) pConfigs[i].stencilSize = 0; pConfigs[i].auxBuffers = 0; pConfigs[i].level = 0; - if (stencil || accum) + if (accum) pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; else pConfigs[i].visualRating = GLX_NONE_EXT; @@ -329,6 +337,39 @@ static unsigned int mylog2(unsigned int n) return log2; } +static unsigned long MGAParseAgpMode(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MGAPtr pMga = MGAPTR(pScrn); + unsigned long mode_mask; + + switch(pMga->agp_mode) { + case 4: + mode_mask = ~0x00000003; + break; + case 2: + if (pMga->Chipset == PCI_CHIP_MGAG200) { + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Enabling AGP 2x pll encoding\n"); + OUTREG(MGAREG_AGP_PLL, AGP_PLL_agp2xpllen_enable); + } + mode_mask = ~0x00000005; + break; + default: + /* Default to 1X agp mode */ + case 1: + if (pMga->Chipset == PCI_CHIP_MGAG200) { + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Disabling AGP 2x pll encoding\n"); + OUTREG(MGAREG_AGP_PLL, AGP_PLL_agp2xpllen_disable); + } + pMga->agp_mode = 1; + mode_mask = ~0x00000006; + break; + } + + return mode_mask; +} Bool MGADRIScreenInit(ScreenPtr pScreen) { @@ -341,6 +382,7 @@ Bool MGADRIScreenInit(ScreenPtr pScreen) int prim_size; int init_offset; int i; + unsigned long mode_mask; /* Check that the GLX, DRI, and DRM modules have been loaded by testing * for canonical symbols in each module. */ @@ -442,7 +484,10 @@ Bool MGADRIScreenInit(ScreenPtr pScreen) pDRIInfo->CreateContext = MGACreateContext; pDRIInfo->DestroyContext = MGADestroyContext; - pDRIInfo->SwapContext = MGADRISwapContext; + if (xf86IsEntityShared(pScrn->entityList[0])) + pDRIInfo->SwapContext = MGADRISwapContext_shared; + else + pDRIInfo->SwapContext = MGADRISwapContext; switch( pScrn->bitsPerPixel ) { case 8: @@ -476,16 +521,17 @@ Bool MGADRIScreenInit(ScreenPtr pScreen) { drmVersionPtr version = drmGetVersion(pMGA->drmSubFD); if (version) { - if (version->version_major != 1 || + if (version->version_major != 2 || version->version_minor != 0 || version->version_patchlevel < 0) { /* incompatible drm version */ xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] MGADRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n", + "[drm] MGADRIScreenInit failed (DRM version = %d.%d.%d, expected 2.0.x). Disabling DRI.\n", version->version_major, version->version_minor, version->version_patchlevel); - MGADRICloseScreen(pScreen); +/* MGADRICloseScreen(pScreen); */ + drmFreeVersion(version); return FALSE; } @@ -524,16 +570,17 @@ Bool MGADRIScreenInit(ScreenPtr pScreen) DRICloseScreen(pScreen); return FALSE; } - + + mode_mask = MGAParseAgpMode(pScreen); + pMGADRIServer->agpMode = drmAgpGetMode(pMGA->drmSubFD); - /* Default to 1X agp mode */ - pMGADRIServer->agpMode &= ~0x00000002; + pMGADRIServer->agpMode &= mode_mask; if (drmAgpEnable(pMGA->drmSubFD, pMGADRIServer->agpMode) < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpEnable failed\n"); DRICloseScreen(pScreen); return FALSE; } - ErrorF("[drm] drmAgpEnabled succeeded\n"); + ErrorF("[drm] drmAgpEnabled succeeded for AGP mode %dx\n", pMGA->agp_mode); prim_size = 65536; init_offset = ((prim_size + pMGADRIServer->warp_ucode_size + @@ -724,22 +771,16 @@ MGADRICloseScreen(ScreenPtr pScreen) MGAPtr pMGA = MGAPTR(pScrn); MGADRIServerPrivatePtr pMGADRIServer = pMGA->DRIServerInfo; - MgaCleanupDma(pScrn); - +/* The DRI will automagically clean these up when driFD is closed */ if(pMGADRIServer->agp_map) { - ErrorF("Unmapped agp region\n"); drmUnmap(pMGADRIServer->agp_map, pMGADRIServer->agpSizep); pMGADRIServer->agp_map = 0; } if(pMGADRIServer->agpHandle) { - ErrorF("Freeing agp memory\n"); - drmAgpFree(pMGA->drmSubFD, pMGADRIServer->agpHandle); pMGADRIServer->agpHandle = 0; pMGADRIServer->agpSizep = 0; } if(pMGADRIServer->agpAcquired == TRUE) { - ErrorF("releasing agp module\n"); - drmAgpRelease(pMGA->drmSubFD); pMGADRIServer->agpAcquired = FALSE; } @@ -797,7 +838,8 @@ MGADRIFinishScreenInit(ScreenPtr pScreen) } -void mgaGetQuiescence( ScrnInfoPtr pScrn ) +void +mgaGetQuiescence( ScrnInfoPtr pScrn ) { MGAPtr pMga = MGAPTR(pScrn); @@ -812,13 +854,13 @@ void mgaGetQuiescence( ScrnInfoPtr pScrn ) OUTREG(MGAREG_MACCESS, pMga->MAccess); OUTREG(MGAREG_PITCH, pLayout->displayWidth); pMga->PlaneMask = ~0; + OUTREG(MGAREG_PLNWT, pMga->PlaneMask); pMga->BgColor = 0; pMga->FgColor = 0; - OUTREG(MGAREG_PLNWT, ~0); - OUTREG(MGAREG_BCOL, 0); - OUTREG(MGAREG_FCOL, 0); + OUTREG(MGAREG_BCOL, pMga->BgColor); + OUTREG(MGAREG_FCOL, pMga->FgColor); + OUTREG(MGAREG_SRCORG, pMga->realSrcOrg); pMga->SrcOrg = 0; - OUTREG(MGAREG_SRCORG, 0); OUTREG(MGAREG_DSTORG, pMga->DstOrg); OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT); OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); /* (maxX << 16) | minX */ @@ -829,8 +871,27 @@ void mgaGetQuiescence( ScrnInfoPtr pScrn ) } +void +mgaGetQuiescence_shared( ScrnInfoPtr pScrn ) +{ + MGAPtr pMga = MGAPTR(pScrn); + MGAEntPtr pMgaEnt = pMga->entityPrivate; + MGAPtr pMga2 = MGAPTR(pMgaEnt->pScrn_2); -void MGASwapContext(ScreenPtr pScreen) + pMga = MGAPTR(pMgaEnt->pScrn_1); + pMga->have_quiescense = 1; + pMga2->have_quiescense = 1; + + if (pMgaEnt->directRenderingEnabled) { + MgaLockUpdate(pMgaEnt->pScrn_1, (DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH)); + pMga->RestoreAccelState(pScrn); + xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex); + } +} + + +void +MGASwapContext(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMga = MGAPTR(pScrn); @@ -842,6 +903,20 @@ void MGASwapContext(ScreenPtr pScreen) pMga->AccelInfoRec->NeedToSync = TRUE; } +void +MGASwapContext_shared(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MGAPtr pMga = MGAPTR(pScrn); + MGAEntPtr pMgaEnt = pMga->entityPrivate; + MGAPtr pMga2 = MGAPTR(pMgaEnt->pScrn_2); + + pMga = MGAPTR(pMgaEnt->pScrn_1); + pMga->have_quiescense = 0; + pMga->AccelInfoRec->NeedToSync = TRUE; + pMga2->have_quiescense = 0; + pMga2->AccelInfoRec->NeedToSync = TRUE; +} /* This is really only called from validate/postvalidate as we @@ -874,6 +949,18 @@ MGADRISwapContext(ScreenPtr pScreen, DRISyncType syncType, } } +static void +MGADRISwapContext_shared(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType oldContextType, void *oldContext, + DRIContextType newContextType, void *newContext) +{ + if (syncType == DRI_3D_SYNC && + oldContextType == DRI_2D_CONTEXT && + newContextType == DRI_2D_CONTEXT) + { + MGASwapContext_shared(pScreen); + } +} void MGASelectBuffer(ScrnInfoPtr pScrn, int which) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c index ea5d061e1..845e3f85a 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c @@ -43,7 +43,7 @@ * Fixed 32bpp hires 8MB horizontal line glitch at middle right */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.167 2000/09/20 00:09:22 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.165 2000/07/11 01:46:36 tsi Exp $ */ /* * This is a first cut at a non-accelerated version to work with the @@ -79,11 +79,10 @@ #include "xf86RAC.h" #include "vbe.h" -#include "cfb8_32.h" #include "fb.h" +#include "cfb8_32.h" #include "dixstruct.h" -#include "mga_bios.h" #include "mga_reg.h" #include "mga.h" #include "mga_macros.h" @@ -118,6 +117,7 @@ static Bool MGAEnterVTFBDev(int scrnIndex, int flags); static void MGALeaveVT(int scrnIndex, int flags); static Bool MGACloseScreen(int scrnIndex, ScreenPtr pScreen); static Bool MGASaveScreen(ScreenPtr pScreen, int mode); +static Bool MGASaveScreenCrtc2(ScreenPtr pScreen, int mode); /* This shouldn't be needed since RAC will disable all I/O for MGA cards. */ #ifdef DISABLE_VGA_IO @@ -141,8 +141,10 @@ static Bool MGAUnmapMem(ScrnInfoPtr pScrn); static void MGASave(ScrnInfoPtr pScrn); static void MGARestore(ScrnInfoPtr pScrn); static Bool MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +void MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags); static void MGABlockHandler(int, pointer, pointer, pointer); +static int MGAEntityIndex = -1; /* * This contains the functions needed by the server after loading the @@ -152,7 +154,7 @@ static void MGABlockHandler(int, pointer, pointer, pointer); * this DriverRec be an upper-case version of the driver name. */ -DriverRec MGA = { +DriverRec MGA_C_NAME = { MGA_VERSION, MGA_DRIVER_NAME, #if 0 @@ -207,7 +209,10 @@ typedef enum { OPTION_VIDEO_KEY, OPTION_ROTATE, OPTION_TEXTURED_VIDEO, - OPTION_XAALINES + OPTION_XAALINES, + OPTION_CRTC2HALF, + OPTION_AGP_MODE_2X, + OPTION_AGP_MODE_4X } MGAOpts; static OptionInfoRec MGAOptions[] = { @@ -228,6 +233,9 @@ static OptionInfoRec MGAOptions[] = { { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, { OPTION_TEXTURED_VIDEO, "TexturedVideo",OPTV_BOOLEAN, {0}, FALSE }, { OPTION_XAALINES, "XAALines", OPTV_INTEGER, {0}, FALSE }, + { OPTION_CRTC2HALF, "Crtc2Half", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_AGP_MODE_2X, "AGPMode2x", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_AGP_MODE_4X, "AGPMode4x", OPTV_BOOLEAN, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; @@ -395,7 +403,7 @@ static MODULESETUPPROTO(mgaSetup); static XF86ModuleVersionInfo mgaVersRec = { - "mga", + MGA_DRIVER_NAME, MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, @@ -407,7 +415,7 @@ static XF86ModuleVersionInfo mgaVersRec = {0,0,0,0} }; -XF86ModuleData mgaModuleData = { &mgaVersRec, mgaSetup, NULL }; +XF86ModuleData MGA_MODULE_DATA = { &mgaVersRec, mgaSetup, NULL }; static pointer mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin) @@ -418,7 +426,7 @@ mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin) if (!setupDone) { setupDone = TRUE; - xf86AddDriver(&MGA, module, 0); + xf86AddDriver(&MGA_C_NAME, module, 0); /* * Modules that this driver always requires may be loaded here @@ -429,10 +437,11 @@ mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin) * Tell the loader about symbols from other modules that this module * might refer to. */ - LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, + LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, xf8_32bppSymbols, ramdacSymbols, ddcSymbols, i2cSymbols, shadowSymbols, - fbdevHWSymbols, vbeSymbols, fbSymbols, + fbdevHWSymbols, vbeSymbols, + fbSymbols, #ifdef XF86DRI drmSymbols, driSymbols, #endif @@ -575,6 +584,7 @@ MGAProbe(DriverPtr drv, int flags) foundScreen = TRUE; else for (i = 0; i < numUsed; i++) { ScrnInfoPtr pScrn; + EntityInfoPtr pEnt; #ifdef DISABLE_VGA_IO MgaSavePtr smga; #endif @@ -610,6 +620,37 @@ MGAProbe(DriverPtr drv, int flags) pScrn->ValidMode = MGAValidMode; foundScreen = TRUE; } + + /* + * For cards that can do dual head per entity, mark the entity + * as sharable. + */ + pEnt = xf86GetEntityInfo(usedChips[i]); + if (pEnt->chipset == PCI_CHIP_MGAG400) { + MGAEntPtr pMgaEnt = NULL; + DevUnion *pPriv; + + xf86SetEntitySharable(usedChips[i]); + /* Allocate an entity private if necessary */ + if (MGAEntityIndex < 0) + MGAEntityIndex = xf86AllocateEntityPrivateIndex(); + pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex); + if (!pPriv->ptr) { + pPriv->ptr = xnfcalloc(sizeof(MGAEntRec), 1); + pMgaEnt = pPriv->ptr; + pMgaEnt->lastInstance = -1; + } else { + pMgaEnt = pPriv->ptr; + } + /* + * Set the entity instance for this instance of the driver. For + * dual head per card, instance 0 is the "master" instance, driving + * the primary head, and instance 1 is the "slave". + */ + pMgaEnt->lastInstance++; + xf86SetEntityInstanceForScreen(pScrn, pScrn->entityList[0], + pMgaEnt->lastInstance); + } } if (usedChips) xfree(usedChips); @@ -783,6 +824,7 @@ MGASoftReset(ScrnInfoPtr pScrn) { MGAPtr pMga = MGAPTR(pScrn); + ErrorF("SoftReset called!!!\n"); pMga->FbMapSize = 8192 * 1024; MGAMapMem(pScrn); @@ -1071,8 +1113,16 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) double real; int bytesPerPixel; ClockRangePtr clockRanges; + const char *reqSym = NULL; const char *s; int flags24; + MGAEntPtr pMgaEnt = NULL; +#ifdef USEMGAHAL + MGAMODEINFO mgaModeInfo = {0}; + ULONG ulBOARDHANDLESize; + UCHAR ucMgaBase2; + ULONG ulOrgFBuffer; +#endif /* * Note: This function is only called once at server startup, and @@ -1097,12 +1147,26 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) } pMga = MGAPTR(pScrn); - + /* Set here until dri is enabled */ +#ifdef XF86DRI + pMga->have_quiescense = 1; +#endif /* Get the entity, and make sure it is PCI. */ pMga->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if (pMga->pEnt->location.type != BUS_PCI) return FALSE; + /* Allocate an entity private if necessary */ + if (xf86IsEntityShared(pScrn->entityList[0])) { + pMgaEnt = xf86GetEntityPrivate(pScrn->entityList[0], + MGAEntityIndex)->ptr; + pMga->entityPrivate = pMgaEnt; + } + + /* Set pMga->device to the relevant Device section */ + pMga->device = xf86GetDevFromEntity(pScrn->entityList[0], + pScrn->entityInstanceList[0]); + if (flags & PROBE_DETECT) { MGAProbeDDC(pScrn, pMga->pEnt->index); return TRUE; @@ -1173,6 +1237,55 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) /* Set pScrn->monitor */ pScrn->monitor = pScrn->confScreen->monitor; +#if 1 + /* + * XXX This assumes that the lower number screen is always the "master" + * head, and that the "master" is the first CRTC. This can result in + * unexpected behaviour when the config file marks the primary CRTC + * as the second screen. + */ + if(xf86IsEntityShared(pScrn->entityList[0]) && + xf86IsPrimInitDone(pScrn->entityList[0])) { + /* This is the second crtc */ + pMga->SecondCrtc = TRUE; + pMga->HWCursor = FALSE; + pScrn->AdjustFrame = MGAAdjustFrameCrtc2; + pMgaEnt->pScrn_2 = pScrn; +#ifdef XF86DRI + pMga->GetQuiescence = mgaGetQuiescence_shared; +#endif + } else { + pMga->SecondCrtc = FALSE; + pMga->HWCursor = TRUE; + if (xf86IsEntityShared(pScrn->entityList[0])) { + pMgaEnt->pScrn_1 = pScrn; +#ifdef XF86DRI + pMga->GetQuiescence = mgaGetQuiescence_shared; +#endif + } else { +#ifdef XF86DRI + pMga->GetQuiescence = mgaGetQuiescence; +#endif + } + } +#else + /* + * This is an alternative version that determines which is the secondary + * CRTC from the screen field in pMga->device. It doesn't currently + * work becasue there are things that assume the primary CRTC is + * initialised first. + */ + if (pMga->device->screen == 1) { + /* This is the second CRTC */ + pMga->SecondCrtc = TRUE; + pMga->HWCursor = FALSE; + pScrn->AdjustFrame = MGAAdjustFrameCrtc2; + } else { + pMga->SecondCrtc = FALSE; + pMga->HWCursor = TRUE; + } +#endif + /* * The first thing we should figure out is the depth, bpp, etc. * Our default depth is 8, so pass it to the helper function. @@ -1183,10 +1296,13 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) flags24 = Support24bppFb | Support32bppFb | SupportConvert32to24; s = xf86TokenToOptName(MGAOptions, OPTION_OVERLAY); if (!(xf86FindOption(pScrn->confScreen->options, s) || - xf86FindOption(pMga->pEnt->device->options, s))) { + xf86FindOption(pMga->device->options, s))) { flags24 |= PreferConvert32to24; } + if (pMga->SecondCrtc) + flags24 = Support32bppFb; + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, flags24)) { return FALSE; } else { @@ -1243,12 +1359,12 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) * Set the Chipset and ChipRev, allowing config file entries to * override. */ - if (pMga->pEnt->device->chipset && *pMga->pEnt->device->chipset) { - pScrn->chipset = pMga->pEnt->device->chipset; + if (pMga->device->chipset && *pMga->device->chipset) { + pScrn->chipset = pMga->device->chipset; pMga->Chipset = xf86StringToToken(MGAChipsets, pScrn->chipset); from = X_CONFIG; - } else if (pMga->pEnt->device->chipID >= 0) { - pMga->Chipset = pMga->pEnt->device->chipID; + } else if (pMga->device->chipID >= 0) { + pMga->Chipset = pMga->device->chipID; pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset); from = X_CONFIG; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", @@ -1258,8 +1374,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) pMga->Chipset = pMga->PciInfo->chipType; pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset); } - if (pMga->pEnt->device->chipRev >= 0) { - pMga->ChipRev = pMga->pEnt->device->chipRev; + if (pMga->device->chipRev >= 0) { + pMga->ChipRev = pMga->device->chipRev; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", pMga->ChipRev); } else { @@ -1305,8 +1421,31 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) pMga->numXAALines); } +#ifdef XF86DRI + { + Bool temp; + + from = X_DEFAULT; + + pMga->agp_mode = 1; + if (xf86GetOptValBool(MGAOptions, OPTION_AGP_MODE_2X, + &temp)) { + pMga->agp_mode = 2; + from = X_CONFIG; + } + + if (xf86GetOptValBool(MGAOptions, OPTION_AGP_MODE_4X, + &temp)) { + pMga->agp_mode = 4; + from = X_CONFIG; + } + xf86DrvMsg(pScrn->scrnIndex, from, "Using AGP Mode %dx\n", + pMga->agp_mode); + } +#endif + from = X_DEFAULT; - pMga->HWCursor = TRUE; + /* * The preferred method is to use the "hw cursor" option as a tri-state * option, with the default set above. @@ -1346,7 +1485,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) } if ((s = xf86GetOptValString(MGAOptions, OPTION_OVERLAY))) { if (!*s || !xf86NameCmp(s, "8,24") || !xf86NameCmp(s, "24,8")) { - if(pScrn->bitsPerPixel == 32) { + if(pScrn->bitsPerPixel == 32 && pMga->SecondCrtc == FALSE) { pMga->Overlay8Plus24 = TRUE; if(!xf86GetOptValInteger( MGAOptions, OPTION_COLOR_KEY,&(pMga->colorKey))) @@ -1357,13 +1496,15 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) "PseudoColor overlay enabled\n"); } else { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Option \"Overlay\" is only supported in 32 bits per pixel\n"); + "Option \"Overlay\" is only supported in 32 bits per pixel on" + "the first CRTC\n"); } } else { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "\"%s\" is not a valid value for Option \"Overlay\"\n", s); } } + if(xf86GetOptValInteger(MGAOptions, OPTION_VIDEO_KEY, &(pMga->videoKey))) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video key set to 0x%x\n", pMga->videoKey); @@ -1467,16 +1608,16 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) * For the 2064 and older rev 1064, base0 is the MMIO and base0 is * the framebuffer is base1. Let the config file override these. */ - if (pMga->pEnt->device->MemBase != 0) { + if (pMga->device->MemBase != 0) { /* Require that the config file value matches one of the PCI values. */ - if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->pEnt->device->MemBase)) { + if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->device->MemBase)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "MemBase 0x%08lX doesn't match any PCI base register.\n", - pMga->pEnt->device->MemBase); + pMga->device->MemBase); MGAFreeRec(pScrn); return FALSE; } - pMga->FbAddress = pMga->pEnt->device->MemBase; + pMga->FbAddress = pMga->device->MemBase; from = X_CONFIG; } else { /* details: mgabase2 sdk pp 4-12 */ @@ -1493,19 +1634,20 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) return FALSE; } } + xf86DrvMsg(pScrn->scrnIndex, from, "Linear framebuffer at 0x%lX\n", (unsigned long)pMga->FbAddress); - if (pMga->pEnt->device->IOBase != 0) { + if (pMga->device->IOBase != 0) { /* Require that the config file value matches one of the PCI values. */ - if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->pEnt->device->IOBase)) { + if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->device->IOBase)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "IOBase 0x%08lX doesn't match any PCI base register.\n", - pMga->pEnt->device->IOBase); + pMga->device->IOBase); MGAFreeRec(pScrn); return FALSE; } - pMga->IOAddress = pMga->pEnt->device->IOBase; + pMga->IOAddress = pMga->device->IOBase; from = X_CONFIG; } else { /* details: mgabase1 sdk pp 4-11 */ @@ -1542,9 +1684,9 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) */ pMga->BiosFrom = X_NONE; - if (pMga->pEnt->device->BiosBase != 0) { + if (pMga->device->BiosBase != 0) { /* XXX This isn't used */ - pMga->BiosAddress = pMga->pEnt->device->BiosBase; + pMga->BiosAddress = pMga->device->BiosBase; pMga->BiosFrom = X_CONFIG; } else { /* details: rombase sdk pp 4-15 */ @@ -1591,20 +1733,73 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) * file, we respect that setting. */ from = X_PROBED; - if (pMga->pEnt->device->videoRam != 0) { - pScrn->videoRam = pMga->pEnt->device->videoRam; + if (pMga->device->videoRam != 0) { + pScrn->videoRam = pMga->device->videoRam; from = X_CONFIG; } else if (pMga->FBDev) { pScrn->videoRam = fbdevHWGetVidmem(pScrn)/1024; } else { pScrn->videoRam = MGACountRam(pScrn); } + + if(xf86IsEntityShared(pScrn->entityList[0])) { + /* This takes gives either half or 8 meg to the second head + * whichever is less. */ + if(pMga->SecondCrtc == FALSE) { + Bool UseHalf = FALSE; + int adjust; + + xf86GetOptValBool(MGAOptions, OPTION_CRTC2HALF, &UseHalf); + adjust = pScrn->videoRam / 2; + + if (UseHalf == TRUE) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Crtc2 will use %dK of VideoRam\n", + adjust); + } else { + adjust = min(adjust, 8192); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Crtc2 will use %dK of VideoRam\n", + adjust); + } + pMgaEnt->mastervideoRam = pScrn->videoRam - adjust; + pScrn->videoRam = pMgaEnt->mastervideoRam; + pMgaEnt->slavevideoRam = adjust; + pMgaEnt->masterFbAddress = pMga->FbAddress; + pMga->FbMapSize = + pMgaEnt->masterFbMapSize = pScrn->videoRam * 1024; + pMgaEnt->slaveFbAddress = pMga->FbAddress + + pMgaEnt->masterFbMapSize; + pMgaEnt->slaveFbMapSize = pMgaEnt->slavevideoRam * 1024; + pMga->realSrcOrg = pMga->SrcOrg = 0; + pMga->DstOrg = 0; + } else { + pMga->FbAddress = pMgaEnt->slaveFbAddress; + pMga->FbMapSize = pMgaEnt->slaveFbMapSize; + pScrn->videoRam = pMgaEnt->slavevideoRam; + pMga->DstOrg = pMga->realSrcOrg = + pMgaEnt->slaveFbAddress - pMgaEnt->masterFbAddress; + pMga->SrcOrg = 0; /* This is not stored in hw format!! */ + } + pMgaEnt->refCount++; + } else { + /* Normal Handling of video ram etc */ + pMga->FbMapSize = pScrn->videoRam * 1024; + switch(pMga->Chipset) { + case PCI_CHIP_MGAG400: + case PCI_CHIP_MGAG200: + case PCI_CHIP_MGAG200_PCI: + pMga->SrcOrg = 0; + pMga->DstOrg = 0; + break; + default: + break; + } + } xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n", pScrn->videoRam); - - pMga->FbMapSize = pScrn->videoRam * 1024; - - /* Set the bpp shift value */ + + /* Set the bpp shift value */ pMga->BppShifts[0] = 0; pMga->BppShifts[1] = 1; pMga->BppShifts[2] = 0; @@ -1670,25 +1865,25 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) * If the user has specified ramdac speed in the XF86Config * file, we respect that setting. */ - if (pMga->pEnt->device->dacSpeeds[0]) { + if (pMga->device->dacSpeeds[0]) { int speed = 0; switch (pScrn->bitsPerPixel) { case 8: - speed = pMga->pEnt->device->dacSpeeds[DAC_BPP8]; + speed = pMga->device->dacSpeeds[DAC_BPP8]; break; case 16: - speed = pMga->pEnt->device->dacSpeeds[DAC_BPP16]; + speed = pMga->device->dacSpeeds[DAC_BPP16]; break; case 24: - speed = pMga->pEnt->device->dacSpeeds[DAC_BPP24]; + speed = pMga->device->dacSpeeds[DAC_BPP24]; break; case 32: - speed = pMga->pEnt->device->dacSpeeds[DAC_BPP32]; + speed = pMga->device->dacSpeeds[DAC_BPP32]; break; } if (speed == 0) - pMga->MaxClock = pMga->pEnt->device->dacSpeeds[0]; + pMga->MaxClock = pMga->device->dacSpeeds[0]; else pMga->MaxClock = speed; from = X_CONFIG; @@ -1696,10 +1891,13 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) pMga->MaxClock = pMga->Dac.maxPixelClock; from = pMga->Dac.ClockFrom; } + if(pMga->SecondCrtc == TRUE) { + /* Override on 2nd crtc */ + pMga->MaxClock = 112000; + } xf86DrvMsg(pScrn->scrnIndex, from, "Max pixel clock is %d MHz\n", pMga->MaxClock / 1000); - - /* + /* * Setup the ClockRanges, which describe what clock ranges are available, * and what sort of modes they can be used for. */ @@ -1708,8 +1906,16 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) clockRanges->minClock = pMga->MinClock; clockRanges->maxClock = pMga->MaxClock; clockRanges->clockIndex = -1; /* programmable */ - clockRanges->interlaceAllowed = TRUE; +#ifdef USEMGAHAL + clockRanges->interlaceAllowed = FALSE; + clockRanges->doubleScanAllowed = FALSE; +#else + if (pMga->SecondCrtc == TRUE) + clockRanges->interlaceAllowed = FALSE; + else + clockRanges->interlaceAllowed = TRUE; clockRanges->doubleScanAllowed = TRUE; +#endif clockRanges->ClockMulFactor = 1; clockRanges->ClockDivFactor = 1; @@ -1788,6 +1994,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) i = 1; } if (i == -1) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Validate Modes Failed\n"); MGAFreeRec(pScrn); return FALSE; } @@ -1800,6 +2007,86 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) MGAFreeRec(pScrn); return FALSE; } + /*******************/ + /* ADDED BY MATROX */ + /*******************/ +#ifdef USEMGAHAL + if(pMga->SecondCrtc == FALSE) { + ulBOARDHANDLESize = MGAGetBOARDHANDLESize(); + pMga->pBoard = (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + ulBOARDHANDLESize); + pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA)); + /* Fill the client part */ + pMga->pClientStruct->pMga = (MGAPtr) pMga; + + /* Determine the Frame buffer limit size */ + if((pMga->Chipset == PCI_CHIP_MGA1064 && pMga->ChipRev < 3) || + (pMga->Chipset == PCI_CHIP_MGA2064)) { + ucMgaBase2 = 0x14; + } else { + ucMgaBase2 = 0x10; + } +#if 0 + /* + * This is bad for cards where there is less physical memory than + * the PCI map size. + */ + ulOrgFBuffer = pciReadLong(pMga->PciTag,ucMgaBase2); + pciWriteLong(pMga->PciTag,ucMgaBase2,0xffffffff); + pMga->FbMapSize = pciReadLong(pMga->PciTag,ucMgaBase2); + pciWriteLong(pMga->PciTag,ucMgaBase2,ulOrgFBuffer); + pMga->FbMapSize = ~(pMga->FbMapSize & 0xfffffff0) + 1; +#endif + /* Open the matrox low level library */ + MGAMapMem(pScrn); + MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA)); + MGAUnmapMem(pScrn); + pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO)); + MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo); + /* copy the board handles */ + if(xf86IsEntityShared(pScrn->entityList[0])) { + pMgaEnt->pClientStruct = pMga->pClientStruct; + pMgaEnt->pBoard = pMga->pBoard; + pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo; + } + mgaModeInfo.flOutput = MGAMODEINFO_ANALOG1; +#if 1 + mgaModeInfo.ulDispWidth = pScrn->virtualX; + mgaModeInfo.ulDispHeight = pScrn->virtualY; +#else + mgaModeInfo.ulDispWidth = pScrn->modes->HDisplay; + mgaModeInfo.ulDispHeight = pScrn->modes->VDisplay; +#endif + mgaModeInfo.ulDeskWidth = pScrn->virtualX; + mgaModeInfo.ulDeskHeight = pScrn->virtualY; + mgaModeInfo.ulBpp = pScrn->bitsPerPixel; + mgaModeInfo.ulZoom = 1; + } else { /* Second CRTC && entity is shared */ + mgaModeInfo.flOutput = MGAMODEINFO_ANALOG2 | + MGAMODEINFO_SECOND_CRTC; +#if 1 + mgaModeInfo.ulDispWidth = pScrn->virtualX; + mgaModeInfo.ulDispHeight = pScrn->virtualY; +#else + mgaModeInfo.ulDispWidth = pScrn->modes->HDisplay; + mgaModeInfo.ulDispHeight = pScrn->modes->VDisplay; +#endif + mgaModeInfo.ulDeskWidth = pScrn->virtualX; + mgaModeInfo.ulDeskHeight = pScrn->virtualY; + mgaModeInfo.ulBpp = pScrn->bitsPerPixel; + mgaModeInfo.ulZoom = 1; + pMga->pBoard = pMgaEnt->pBoard; + pMga->pClientStruct = pMgaEnt->pClientStruct; + pMga->pMgaHwInfo = pMga->pMgaHwInfo; + } + if(MGAValidateMode(pMga->pBoard,&mgaModeInfo) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "MGAValidateMode found the mode to be invalid\n"); + return FALSE; + } + + pScrn->displayWidth = mgaModeInfo.ulFBPitch; + +#endif /* USEMGAHAL */ /* * Set the CRTC parameters for all of the modes based on the type @@ -1809,8 +2096,11 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) * driver and if the driver doesn't provide code to set them. They * are not pre-initialised at all. */ - xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); - +#ifdef USEMGAHAL + xf86SetCrtcForModes(pScrn, 0); +#else + xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); +#endif /* Set the current mode to the first in the list */ pScrn->currentMode = pScrn->modes; @@ -1869,43 +2159,73 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "YDstOrg is set to %d\n", pMga->YDstOrg); - pMga->FbUsableSize = pMga->FbMapSize - pMga->YDstOrg * bytesPerPixel; + if(xf86IsEntityShared(pScrn->entityList[0])) { + if(pMga->SecondCrtc == FALSE) { + pMga->FbUsableSize = pMgaEnt->masterFbMapSize; + /* Allocate HW cursor buffer at the end of video ram */ + if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) { + if( pScrn->virtualY * pScrn->displayWidth * + pScrn->bitsPerPixel / 8 <= + pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) { + pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize; + pMga->FbCursorOffset = + pMgaEnt->masterFbMapSize - + pMga->Dac.CursorOffscreenMemSize; + } else { + pMga->HWCursor = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Too little offscreen memory for HW cursor; " + "using SW cursor\n"); + } + } + } else { /* Second CRTC */ + pMga->FbUsableSize = pMgaEnt->slaveFbMapSize; + pMga->HWCursor = FALSE; + } + } else { + pMga->FbUsableSize = pMga->FbMapSize - pMga->YDstOrg * bytesPerPixel; + /* Allocate HW cursor buffer at the end of video ram */ + if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) { + if( pScrn->virtualY * pScrn->displayWidth * + pScrn->bitsPerPixel / 8 <= + pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) { + pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize; + pMga->FbCursorOffset = + pMga->FbMapSize - pMga->Dac.CursorOffscreenMemSize; + } else { + pMga->HWCursor = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Too little offscreen memory for HW cursor; " + "using SW cursor\n"); + } + } + } /* * XXX This should be taken into account in some way in the mode valdation * section. */ - /* Allocate HW cursor buffer at the end of video ram */ - if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) { - if( pScrn->virtualY * pScrn->displayWidth * pScrn->bitsPerPixel / 8 <= - pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) { - pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize; - pMga->FbCursorOffset = - pMga->FbMapSize - pMga->Dac.CursorOffscreenMemSize; - } else { - pMga->HWCursor = FALSE; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Too little offscreen memory for HW cursor; using SW cursor\n"); - } - } /* Load the required framebuffer */ - if(pMga->Overlay8Plus24) { + if (pMga->Overlay8Plus24) { if (!xf86LoadSubModule(pScrn, "xf8_32bpp")) { MGAFreeRec(pScrn); return FALSE; } - xf86LoaderReqSymbols("cfb8_32ScreenInit", NULL); + reqSym = "cfb8_32ScreenInit"; } else { if (!xf86LoadSubModule(pScrn, "fb")) { MGAFreeRec(pScrn); return FALSE; } + reqSym = "fbScreenInit"; xf86LoaderReqSymbols("fbScreenInit", NULL); #ifdef RENDER xf86LoaderReqSymbols("fbPictureInit", NULL); #endif } + xf86LoaderReqSymbols(reqSym, NULL); + /* Load XAA if needed */ if (!pMga->NoAccel) { @@ -1942,7 +2262,43 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) pMga->CurrentLayout.weight.blue = pScrn->weight.blue; pMga->CurrentLayout.Overlay8Plus24 = pMga->Overlay8Plus24; pMga->CurrentLayout.mode = pScrn->currentMode; +#ifdef USEMGAHAL + /* Close the library after preinit */ + /* This needs to only happen after this board has completed preinit + * both times + */ + if(xf86IsEntityShared(pScrn->entityList[0])) { + /* Entity is shared make sure refcount == 2 */ + /* If ref count is 2 then reset it to 0 */ + if(pMgaEnt->refCount == 2) { + /* Both boards have done there initialization */ + MGACloseLibrary(pMga->pBoard); + + if (pMga->pBoard) + xfree(pMga->pBoard); + if (pMga->pClientStruct) + xfree(pMga->pClientStruct); + if (pMga->pMgaModeInfo) + xfree(pMga->pMgaModeInfo); + if (pMga->pMgaHwInfo) + xfree(pMga->pMgaHwInfo); + pMgaEnt->refCount = 0; + } + } else { + MGACloseLibrary(pMga->pBoard); + + if (pMga->pBoard) + xfree(pMga->pBoard); + if (pMga->pClientStruct) + xfree(pMga->pClientStruct); + if (pMga->pMgaModeInfo) + xfree(pMga->pMgaModeInfo); + if (pMga->pMgaHwInfo) + xfree(pMga->pMgaHwInfo); + } +#endif + xf86SetPrimInitDone(pScrn->entityList[0]); return TRUE; } @@ -2089,10 +2445,51 @@ MGASave(ScrnInfoPtr pScrn) MGAPtr pMga = MGAPTR(pScrn); MGARegPtr mgaReg = &pMga->SavedReg; +#ifdef USEMGAHAL + if(pMga->SecondCrtc == TRUE) return; + + if(pMga->pBoard != NULL) { + MGASaveVgaState(pMga->pBoard); + } +#endif + /* Only save text mode fonts/text for the primary card */ (*pMga->Save)(pScrn, vgaReg, mgaReg, pMga->Primary); } +#ifdef USEMGAHAL +/* Convert DisplayModeRec parameters in MGAMODEINFO parameters. */ +static void FillModeInfoStruct(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + MGAPtr pMga = MGAPTR(pScrn); + pMga->pMgaModeInfo = (LPMGAMODEINFO) xalloc (sizeof(MGAMODEINFO)); + + pMga->pMgaModeInfo->flOutput = 0; + pMga->pMgaModeInfo->ulDispWidth = mode->HDisplay; + pMga->pMgaModeInfo->ulDispHeight = mode->VDisplay; + pMga->pMgaModeInfo->ulDeskWidth = pScrn->virtualX; + pMga->pMgaModeInfo->ulDeskHeight = pScrn->virtualY; + pMga->pMgaModeInfo->ulFBPitch = 0; + pMga->pMgaModeInfo->ulBpp = pScrn->bitsPerPixel; + pMga->pMgaModeInfo->ulZoom = 1; + pMga->pMgaModeInfo->flSignalMode = 0; + pMga->pMgaModeInfo->ulRefreshRate = 0; + pMga->pMgaModeInfo->ulHorizRate = 0; + pMga->pMgaModeInfo->ulPixClock = mode->Clock; + pMga->pMgaModeInfo->ulHFPorch = mode->HSyncStart - mode->HDisplay; + pMga->pMgaModeInfo->ulHSync = mode->HSyncEnd - mode->HSyncStart; + pMga->pMgaModeInfo->ulHBPorch = mode->HTotal - mode->HSyncEnd; + pMga->pMgaModeInfo->ulVFPorch = mode->VSyncStart - mode->VDisplay; + pMga->pMgaModeInfo->ulVSync = mode->VSyncEnd - mode->VSyncStart; + pMga->pMgaModeInfo->ulVBPorch = mode->VTotal - mode->VSyncEnd; + /* Use DstOrg directly */ + /* This is an offset in pixels not memory */ + pMga->pMgaModeInfo->ulDstOrg = pMga->DstOrg / (pScrn->bitsPerPixel / 8); + pMga->pMgaModeInfo->ulDisplayOrg = pMga->DstOrg / (pScrn->bitsPerPixel / 8); + pMga->pMgaModeInfo->ulPanXGran = 0; + pMga->pMgaModeInfo->ulPanYGran = 0; +} +#endif /* USEMGAHAL */ /* * Initialise a new mode. This is currently still using the old @@ -2123,13 +2520,57 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) vgaReg = &hwp->ModeReg; mgaReg = &pMga->ModeReg; +#ifdef USEMGAHAL + FillModeInfoStruct(pScrn,mode); + + if(pMga->SecondCrtc == TRUE) { + pMga->pMgaModeInfo->flOutput = MGAMODEINFO_ANALOG2 | + MGAMODEINFO_SECOND_CRTC | + MGAMODEINFO_FORCE_PITCH | + MGAMODEINFO_FORCE_DISPLAYORG; + } else { + pMga->pMgaModeInfo->flOutput = MGAMODEINFO_ANALOG1 | + MGAMODEINFO_FORCE_PITCH; + } + + pMga->pMgaModeInfo->ulFBPitch = pScrn->displayWidth; + if(MGAValidateMode(pMga->pBoard,pMga->pMgaModeInfo) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Invalid parameters\n"); + return FALSE; + } + + if(MGAValidateVideoParameters(pMga->pBoard,pMga->pMgaModeInfo) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Invalid parameters\n"); + return FALSE; + } +#endif /* USEMGAHAL */ + #ifdef XF86DRI if (pMga->directRenderingEnabled) { DRILock(screenInfo.screens[pScrn->scrnIndex], 0); } #endif + +#ifdef USEMGAHAL + if(MGASetMode(pMga->pBoard,pMga->pMgaModeInfo) != 0) { + return FALSE; + } + +#define outMGAdreg(reg, val) OUTREG8(RAMDAC_OFFSET + (reg), val) + +#define outMGAdac(reg, val) \ + (outMGAdreg(MGA1064_INDEX, reg), outMGAdreg(MGA1064_DATA, val)) + + if(pMga->SecondCrtc == FALSE && pMga->HWCursor == TRUE) { + outMGAdac(MGA1064_CURSOR_BASE_ADR_LOW, pMga->FbCursorOffset >> 10); + outMGAdac(MGA1064_CURSOR_BASE_ADR_HI, pMga->FbCursorOffset >> 18); + } +#endif /* USEMGAHAL */ + +#ifndef USEMGAHAL (*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE); +#endif MGAStormSync(pScrn); MGAStormEngineInit(pScrn); @@ -2163,19 +2604,50 @@ MGARestore(ScrnInfoPtr pScrn) MGAPtr pMga = MGAPTR(pScrn); MGARegPtr mgaReg = &pMga->SavedReg; - if (pScrn->pScreen != NULL) - MGAStormSync(pScrn); + if (pScrn->pScreen != NULL) + MGAStormSync(pScrn); + + if(pMga->SecondCrtc == TRUE) return; /* Only restore text mode fonts/text for the primary card */ vgaHWProtect(pScrn, TRUE); - if (pMga->Primary) + if (pMga->Primary) { +#ifdef USEMGAHAL + if(pMga->pBoard != NULL) { + MGASetVgaMode(pMga->pBoard); + MGARestoreVgaState(pMga->pBoard); + } +#endif (*pMga->Restore)(pScrn, vgaReg, mgaReg, TRUE); - else + } else { vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE); + } vgaHWProtect(pScrn, FALSE); } +/* Workaround for a G400 CRTC2 display problem */ +static void +MGACrtc2FillStrip(ScrnInfoPtr pScrn) +{ + MGAPtr pMga = MGAPTR(pScrn); + + if (pMga->NoAccel) { + /* Clears the whole screen, but ... */ + bzero(pMga->FbStart, + (pScrn->bitsPerPixel >> 3) * pScrn->displayWidth * pScrn->virtualY); + } else { + xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex); + pMga->RestoreAccelState(pScrn); + pMga->SetupForSolidFill(pScrn, 0, GXcopy, 0xFFFFFFFF); + pMga->SubsequentSolidFillRect(pScrn, pScrn->virtualX, 0, + pScrn->displayWidth - pScrn->virtualX, + pScrn->virtualY); + MGAStormSync(pScrn); + } +} + + /* Mandatory */ /* This gets called at the start of each server generation */ @@ -2191,6 +2663,8 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) VisualPtr visual; unsigned char *FBStart; int width, height, displayWidth; + MGAEntPtr pMgaEnt = NULL; + int f; /* * First get the ScrnInfoRec @@ -2200,6 +2674,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) hwp = VGAHWPTR(pScrn); pMga = MGAPTR(pScrn); MGAdac = &pMga->Dac; + /* Map the MGA memory and MMIO areas */ if (pMga->FBDev) { @@ -2210,6 +2685,51 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; } + if (xf86IsEntityShared(pScrn->entityList[0])) { + DevUnion *pPriv; + pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex); + pMgaEnt = pPriv->ptr; + pMgaEnt->refCount++; +#ifdef USEMGAHAL + if(pMgaEnt->refCount == 1) { + pMga->pBoard = + (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + + MGAGetBOARDHANDLESize()); + pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA)); + /* Fill the client part */ + pMga->pClientStruct->pMga = (MGAPtr) pMga; + + MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA)); + + pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO)); + MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo); + /* Now copy these to the entitystructure */ + pMgaEnt->pClientStruct = pMga->pClientStruct; + pMgaEnt->pBoard = pMga->pBoard; + pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo; + } else { /* Ref count is 2 */ + pMga->pClientStruct = pMgaEnt->pClientStruct; + pMga->pBoard = pMgaEnt->pBoard; + pMga->pMgaHwInfo = pMgaEnt->pMgaHwInfo; + } +#endif /* USEMGAHAL */ + } else { +#ifdef USEMGAHAL + pMga->pBoard = + (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + + MGAGetBOARDHANDLESize()); + pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA)); + /* Fill the client part */ + pMga->pClientStruct->pMga = (MGAPtr) pMga; + + MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA)); + + pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO)); + MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo); +#endif /* USEMGAHAL */ + } + + /* Initialise the MMIO vgahw functions */ vgaHWSetMmioFuncs(hwp, pMga->IOBase, PORT_OFFSET); vgaHWGetIOBase(hwp); @@ -2238,7 +2758,11 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Darken the screen for aesthetic reasons and set the viewport */ - MGASaveScreen(pScreen, SCREEN_SAVER_ON); + if (pMga->SecondCrtc == TRUE) { + MGASaveScreenCrtc2(pScreen, SCREEN_SAVER_ON); + } else { + MGASaveScreen(pScreen, SCREEN_SAVER_ON); + } pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); /* @@ -2267,6 +2791,11 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; if (!miSetVisualTypes(24, TrueColorMask, pScrn->rgbBits, TrueColor)) return FALSE; + } else if (pMga->SecondCrtc) { + /* No DirectColor on the second head */ + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, + TrueColor)) + return FALSE; } else { if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; @@ -2313,27 +2842,29 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) * The DRI does not work when textured video is enabled at this time. */ - if (!pMga->NoAccel && pMga->TexturedVideo != TRUE) + if (!pMga->NoAccel && pMga->TexturedVideo != TRUE && + pMga->SecondCrtc == FALSE) pMga->directRenderingEnabled = MGADRIScreenInit(pScreen); else pMga->directRenderingEnabled = FALSE; #endif - - if(pMga->Overlay8Plus24) { + + if (pMga->Overlay8Plus24) { ret = cfb8_32ScreenInit(pScreen, FBStart, width, height, pScrn->xDpi, pScrn->yDpi, displayWidth); } else { ret = fbScreenInit(pScreen, FBStart, width, height, - pScrn->xDpi, pScrn->yDpi, - displayWidth, pScrn->bitsPerPixel); + pScrn->xDpi, pScrn->yDpi, + displayWidth, pScrn->bitsPerPixel); #ifdef RENDER if (ret) fbPictureInit (pScreen, 0, 0); #endif } + if (!ret) return FALSE; @@ -2386,9 +2917,12 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Initialize colormap layer. Must follow initialization of the default colormap */ + if (!pMga->SecondCrtc) + f = CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH; + else + f = CMAP_RELOAD_ON_MODE_SWITCH; if(!xf86HandleColormaps(pScreen, 256, 8, - (pMga->FBDev ? fbdevHWLoadPalette : MGAdac->LoadPalette), NULL, - CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) + (pMga->FBDev ? fbdevHWLoadPalette : MGAdac->LoadPalette), NULL, f)) return FALSE; if(pMga->Overlay8Plus24) { /* Must come after colormap initialization */ @@ -2436,14 +2970,20 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n"); } + if (xf86IsEntityShared(pScrn->entityList[0]) && pMga->SecondCrtc == FALSE) + pMgaEnt->directRenderingEnabled = pMga->directRenderingEnabled; + pMga->have_quiescense = 1; #endif pScrn->memPhysBase = pMga->FbAddress; pScrn->fbOffset = pMga->YDstOrg * (pScrn->bitsPerPixel / 8); - MGAInitVideo(pScreen); - - pScreen->SaveScreen = MGASaveScreen; + if(pMga->SecondCrtc == TRUE) { + pScreen->SaveScreen = MGASaveScreenCrtc2; + } else { + pScreen->SaveScreen = MGASaveScreen; + MGAInitVideo(pScreen); + } /* Wrap the current CloseScreen function */ pMga->CloseScreen = pScreen->CloseScreen; @@ -2454,6 +2994,11 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); } + /* For the second head, work around display problem. */ + if (pMga->SecondCrtc) { + MGACrtc2FillStrip(pScrn); + } + /* Done */ return TRUE; } @@ -2512,6 +3057,33 @@ MGAAdjustFrame(int scrnIndex, int x, int y, int flags) } +#define C2STARTADD0 0x3C28 + +void +MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn; + int Base; + MGAFBLayout *pLayout; + MGAPtr pMga; + + pScrn = xf86Screens[scrnIndex]; + pMga = MGAPTR(pScrn); + pLayout = &pMga->CurrentLayout; + + if(pMga->ShowCache && y && pScrn->vtSema) + y += pScrn->virtualY - 1; + + /* 3-85 c2offset + * 3-93 c2startadd0 + * 3-96 c2vcount + */ + + Base = (y * pLayout->displayWidth + x) * pLayout->bitsPerPixel >> 3; + Base += pMga->DstOrg; + Base &= 0x01ffffc0; + OUTREG(C2STARTADD0, Base); +} /* * This is called when VT switching back to the X server. Its job is @@ -2525,12 +3097,15 @@ static Bool MGAEnterVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + MGAPtr pMga; #ifdef XF86DRI ScreenPtr pScreen; - MGAPtr pMGA; +#endif - pMGA = MGAPTR(pScrn); - if (pMGA->directRenderingEnabled) { + pMga = MGAPTR(pScrn); + +#ifdef XF86DRI + if (pMga->directRenderingEnabled) { pScreen = screenInfo.screens[scrnIndex]; DRIUnlock(pScreen); } @@ -2539,6 +3114,12 @@ MGAEnterVT(int scrnIndex, int flags) if (!MGAModeInit(pScrn, pScrn->currentMode)) return FALSE; MGAAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + /* For the second head, work around display problem. */ + if (pMga->SecondCrtc) { + MGACrtc2FillStrip(pScrn); + } + return TRUE; } @@ -2610,7 +3191,8 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; vgaHWPtr hwp = VGAHWPTR(pScrn); MGAPtr pMga = MGAPTR(pScrn); - + MGAEntPtr pMgaEnt = NULL; + if (pScrn->vtSema) { if (pMga->FBDev) { fbdevHWRestore(pScrn); @@ -2628,7 +3210,43 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen) pMga->directRenderingEnabled=FALSE; } #endif - + + if (xf86IsEntityShared(pScrn->entityList[0])) { + DevUnion *pPriv; + pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex); + pMgaEnt = pPriv->ptr; + pMgaEnt->refCount--; + } + +#ifdef USEMGAHAL + if(xf86IsEntityShared(pScrn->entityList[0])) { + if(pMgaEnt->refCount == 0) { + /* Both boards have closed there screen */ + MGACloseLibrary(pMga->pBoard); + + if (pMga->pBoard) + xfree(pMga->pBoard); + if (pMga->pClientStruct) + xfree(pMga->pClientStruct); + if (pMga->pMgaModeInfo) + xfree(pMga->pMgaModeInfo); + if (pMga->pMgaHwInfo) + xfree(pMga->pMgaHwInfo); + } + } else { + MGACloseLibrary(pMga->pBoard); + + if (pMga->pBoard) + xfree(pMga->pBoard); + if (pMga->pClientStruct) + xfree(pMga->pClientStruct); + if (pMga->pMgaModeInfo) + xfree(pMga->pMgaModeInfo); + if (pMga->pMgaHwInfo) + xfree(pMga->pMgaHwInfo); + } +#endif /* USEMGAHAL */ + if (pMga->AccelInfoRec) XAADestroyInfoRec(pMga->AccelInfoRec); if (pMga->CursorInfoRec) @@ -2649,6 +3267,8 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen) if (xf86IsPc98()) outb(0xfac, 0x00); + xf86ClearPrimInitDone(pScrn->entityList[0]); + if(pMga->BlockHandler) pScreen->BlockHandler = pMga->BlockHandler; @@ -2680,6 +3300,8 @@ static int MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) { int lace; + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + MGAPtr pMga = MGAPTR(pScrn); lace = 1 + ((mode->Flags & V_INTERLACE) != 0); @@ -2691,6 +3313,17 @@ MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) (mode->CrtcVSyncStart <= 4096 * lace) && (mode->CrtcVSyncEnd <= 4096 * lace) && (mode->CrtcVTotal <= 4096 * lace)) { + + /* Can't have horizontal panning for second head of G400 */ + if (pMga->SecondCrtc) { + if (flags == MODECHECK_FINAL) { + if (pMga->allowedWidth == 0) + pMga->allowedWidth = pScrn->virtualX; + if (mode->HDisplay != pMga->allowedWidth) + return(MODE_ONE_WIDTH); + } + } + return(MODE_OK); } else { return(MODE_BAD); @@ -2701,6 +3334,36 @@ MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) /* Do screen blanking */ /* Mandatory */ +#define MGAREG_C2CTL 0x3c10 + +static Bool +MGASaveScreenCrtc2(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = NULL; + MGAPtr pMga = NULL; + Bool on; + CARD32 tmp; + + on = xf86IsUnblank(mode); + + if (on) + SetTimeSinceLastInputEvent(); + if (pScreen != NULL) + pScrn = xf86Screens[pScreen->myNum]; + + if (pScrn != NULL) + pMga = MGAPTR(pScrn); + + if(pMga != NULL && pScrn->vtSema) { + tmp = INREG(MGAREG_C2CTL); + tmp &= ~0x00000008; + if (!on) tmp |= 0x0000008; + OUTREG(MGAREG_C2CTL, tmp); + } + + return TRUE; +} + static Bool MGASaveScreen(ScreenPtr pScreen, int mode) { @@ -2721,8 +3384,6 @@ MGADisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, MGAPtr pMga = MGAPTR(pScrn); unsigned char seq1 = 0, crtcext1 = 0; -ErrorF("MGADisplayPowerManagementSet: %d\n", PowerManagementMode); - switch (PowerManagementMode) { case DPMSModeOn: diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h index 12538fd3c..3f38943ee 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h @@ -429,6 +429,9 @@ #define MGAREG_DWGSYNC 0x2c4c +#define MGAREG_AGP_PLL 0x1e4c +#define AGP_PLL_agp2xpllen_enable 0x1 +#define AGP_PLL_agp2xpllen_disable 0x0 #endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile index 8bd933bbf..e6bdf32af 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile,v 1.8 2000/06/17 00:03:21 martin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile,v 1.9 2000/09/20 00:09:26 keithp Exp $ XCOMM XCOMM This is the Imakefile for the ATI Rage 128 (r128) and XCOMM the ATI Radeon (radeon) driver. @@ -47,7 +47,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ -I$(XF86SRC)/int10 -I$(SERVERSRC)/Xext \ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ -I$(EXTINCSRC) -I$(XF86SRC)/xf24_32bpp \ - $(DRIINCLUDES) + $(DRIINCLUDES) -I$(SERVERSRC)/render #endif DEFINES = $(DRIDEFINES) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c index 5c6f33673..0a1512d9c 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c @@ -122,8 +122,6 @@ const char *fbdevHWSymbols[] = { NULL }; -#if 0 - /* Not used until DDC is supported. */ const char *ddcSymbols[] = { "xf86PrintEDID", "xf86DoEDID_DDC1", @@ -131,13 +129,6 @@ const char *ddcSymbols[] = { NULL }; -const char *i2cSymbols[] = { - "xf86CreateI2CBusRec", - "xf86I2CBusInit", - NULL -}; -#endif - #ifdef XFree86LOADER #ifdef USE_FB static const char *fbSymbols[] = { diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h index bcb2d80e7..1f26edb5c 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h,v 1.11 2000/08/04 16:13:32 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h,v 1.12 2000/09/13 15:47:32 martin Exp $ */ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., @@ -179,7 +179,6 @@ typedef struct { unsigned char *MMIO; /* Map of MMIO region */ unsigned char *FB; /* Map of frame buffer */ - CARD8 *VBIOS; /* Video BIOS pointer */ CARD32 MemCntl; CARD32 BusCntl; @@ -188,6 +187,7 @@ typedef struct { Bool HasPanelRegs; /* Current chip can connect to a FP */ Bool CRTOnly; /* Only use External CRT instead of FP */ + CARD8 *VBIOS; /* Video BIOS for mode validation on FPs */ int FPBIOSstart; /* Start of the flat panel info */ /* Computed values for FPs */ @@ -204,7 +204,6 @@ typedef struct { Bool PaletteSavedOnVT; /* Palette saved on last VT switch */ - I2CBusPtr i2c; XAAInfoRecPtr accel; Bool accelOn; xf86CursorInfoPtr cursor; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c index 4d0ab433e..2f7b28187 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c,v 1.13 2000/06/26 05:41:32 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c,v 1.14 2000/08/24 22:20:17 tsi Exp $ */ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., @@ -791,6 +791,7 @@ static void R128SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) x11perf -putimage100 2150.0/sec 1170.0/sec x11perf -putimage500 108.0/sec 49.8/sec */ +#if R128_IMAGEWRITE static void R128SetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, unsigned int planemask, @@ -911,6 +912,7 @@ static void R128SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) } } } +#endif /* Initialize the acceleration hardware. */ void R128EngineInit(ScrnInfoPtr pScrn) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c index 380fc0c9c..9aea26df5 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c,v 1.4 2000/06/26 05:41:32 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c,v 1.5 2000/08/25 13:42:37 dawes Exp $ */ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c index e39828343..50a982597 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c,v 1.40 2000/08/04 16:13:32 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c,v 1.46 2000/09/20 00:09:26 keithp Exp $ */ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., @@ -120,6 +120,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_sarea.h" #endif +#ifdef RENDER +#include "picturestr.h" +#endif /* Driver data structures */ #include "ati2.h" #include "r128.h" @@ -245,10 +248,7 @@ R128RAMRec R128RAM[] = { /* Memory Specifications extern const char *vgahwSymbols[]; extern const char *fbdevHWSymbols[]; -#if 0 extern const char *ddcSymbols[]; -extern const char *i2cSymbols[]; -#endif /* Allocate our private R128InfoRec. */ static Bool R128GetRec(ScrnInfoPtr pScrn) @@ -977,33 +977,19 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn) static Bool R128PreInitDDC(ScrnInfoPtr pScrn) { - /* FIXME: DDC support goes here. */ -#if 0 - /* Using the GPIO_MONID register for DDC2 - does not appear to work as expected. - Hence, the implementation of DDC is - deferred. */ R128InfoPtr info = R128PTR(pScrn); - Bool ret = TRUE; - + vbeInfoPtr pVbe; + if (!xf86LoadSubModule(pScrn, "ddc")) return FALSE; xf86LoaderReqSymLists(ddcSymbols, NULL); - if (!xf86LoadSubModule(pScrn, "i2c")) return FALSE; - xf86LoaderReqSymLists(i2cSymbols, NULL); - - R128MapMMIO(pScrn); - if (!R128I2CInit(pScrn)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I2C initialization failed\n"); - ret = FALSE; - } else { - xf86SetDDCProperties(pScrn,xf86PrintEDID( - xf86DoEDID_DDC2(pScrn->scrnIndex, info->i2c))); - } - R128UnmapMMIO(pScrn); - return ret; -#else - return TRUE; -#endif + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,info->pEnt->index); + if (!pVbe) return FALSE; + + xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(pVbe,NULL))); + return TRUE; + } else + return FALSE; } /* This is called by R128PreInit to initialize gamma correction. */ @@ -1094,6 +1080,11 @@ static Bool R128PreInitModes(ScrnInfoPtr pScrn) #endif if (mod && !xf86LoadSubModule(pScrn, mod)) return FALSE; xf86LoaderReqSymbols(Sym, NULL); +#ifdef USE_FB +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif +#endif info->CurrentLayout.displayWidth = pScrn->displayWidth; info->CurrentLayout.mode = pScrn->currentMode; @@ -1471,7 +1462,8 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; - + miSetPixmapDepths (); + #ifdef XF86DRI /* Setup DRI after visuals have been established, but before cfbScreenInit is @@ -1511,6 +1503,9 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, pScrn->bitsPerPixel)) return FALSE; +#ifdef RENDER + fbPictureInit (pScreen, 0, 0); +#endif #else switch (pScrn->bitsPerPixel) { case 8: diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h index 890cf0004..8dc4c44a1 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h,v 1.11 2000/07/01 01:40:46 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h,v 1.13 2000/09/13 15:47:32 martin Exp $ */ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h index eb82611a1..600f99bc5 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h @@ -215,7 +215,6 @@ typedef struct { Bool PaletteSavedOnVT; /* Palette saved on last VT switch */ - I2CBusPtr i2c; XAAInfoRecPtr accel; Bool accelOn; xf86CursorInfoPtr cursor; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c index a04f0adad..6821d48ed 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c @@ -668,6 +668,7 @@ static void RADEONSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) } } +#if RADEON_IMAGEWRITE /* Setup for XAA indirect image write. */ static void RADEONSetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, @@ -780,6 +781,7 @@ static void RADEONSubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) } } } +#endif /* Initialize the acceleration hardware. */ void RADEONEngineInit(ScrnInfoPtr pScrn) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c index b3f8ce6b7..fe9ebd382 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c @@ -237,10 +237,7 @@ RADEONRAMRec RADEONRAM[] = { /* Memory Specifications extern const char *vgahwSymbols[]; extern const char *fbdevHWSymbols[]; -#if 0 extern const char *ddcSymbols[]; -extern const char *i2cSymbols[]; -#endif /* Allocate our private RADEONInfoRec. */ static Bool RADEONGetRec(ScrnInfoPtr pScrn) @@ -971,33 +968,19 @@ static Bool RADEONPreInitConfig(ScrnInfoPtr pScrn) static Bool RADEONPreInitDDC(ScrnInfoPtr pScrn) { - /* FIXME: DDC support goes here. */ -#if 0 - /* Using the GPIO_MONID register for DDC2 - does not appear to work as expected. - Hence, the implementation of DDC is - deferred. */ RADEONInfoPtr info = RADEONPTR(pScrn); - Bool ret = TRUE; - + vbeInfoPtr pVbe; + if (!xf86LoadSubModule(pScrn, "ddc")) return FALSE; xf86LoaderReqSymLists(ddcSymbols, NULL); - if (!xf86LoadSubModule(pScrn, "i2c")) return FALSE; - xf86LoaderReqSymLists(i2cSymbols, NULL); - - RADEONMapMMIO(pScrn); - if (!RADEONI2CInit(pScrn)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I2C initialization failed\n"); - ret = FALSE; - } else { - xf86SetDDCProperties(pScrn,xf86PrintEDID( - xf86DoEDID_DDC2(pScrn->scrnIndex, info->i2c))); - } - RADEONUnmapMMIO(pScrn); - return ret; -#else - return TRUE; -#endif + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,info->pEnt->index); + if (!pVbe) return FALSE; + + xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(pVbe,NULL))); + return TRUE; + } else + return FALSE; } /* This is called by RADEONPreInit to initialize gamma correction. */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c index c0c3f1433..87960acf3 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c @@ -161,12 +161,22 @@ TDFXSetLFBConfig(TDFXPtr pTDFX) { } else { int chip; int stride, bits; + int TileAperturePitch, lg2TileAperturePitch; if (pTDFX->cpp==2) stride=pTDFX->stride; else stride=4*pTDFX->stride/pTDFX->cpp; bits=pTDFX->backOffset>>12; + for (lg2TileAperturePitch = 0, TileAperturePitch = 1024; + (lg2TileAperturePitch < 5) && + TileAperturePitch < stride; + lg2TileAperturePitch += 1, TileAperturePitch <<= 1); +#if 0 + fprintf(stderr, "Using %d (== lg2(%d)-10) for tile aperture pitch\n", + lg2TileAperturePitch, TileAperturePitch); + fprintf(stderr, "stride == %d\n", stride); +#endif for (chip=0; chip<pTDFX->numChips; chip++) { TDFXWriteChipLongMMIO(pTDFX, chip, LFBMEMORYCONFIG, (bits&0x1FFF) | - SST_RAW_LFB_ADDR_STRIDE_4K | + SST_RAW_LFB_ADDR_STRIDE(lg2TileAperturePitch) | ((bits&0x6000)<<10) | ((stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT); } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c index da906ecde..201216076 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c @@ -643,7 +643,6 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) ClockRangePtr clockRanges; int i; MessageType from; - char *mod=0, *reqSym=0; int flags24; rgb defaultWeight = {0, 0, 0}; pciVideoPtr match; @@ -668,6 +667,11 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) if (pTDFX->pEnt->location.type != BUS_PCI) return FALSE; + if (flags & PROBE_DETECT) { + TDFXProbeDDC(pScrn, pTDFX->pEnt->index); + return TRUE; + } + /* The vgahw module should be loaded here when needed */ if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; @@ -1200,7 +1204,10 @@ CalcPLL(int freq, int *f_out, int isBanshee) { maxm=24; } else { minm=1; - maxm=64; + maxm=57; /* This used to be 64, alas it seems the last 8 (funny that ?) + * values cause jittering at lower resolutions. I've not done + * any calculations to what the adjustment affects clock ranges, + * but I can still run at 1600x1200@75Hz */ } for (n=1; n<256; n++) { f_cur=REFFREQ*(n+2); @@ -1609,15 +1616,6 @@ static void allocateMemory(ScrnInfoPtr pScrn) { pTDFX = TDFXPTR(pScrn); pTDFX->stride = pScrn->displayWidth*pTDFX->cpp; - /* Layout the memory. Start with all the ram */ - memRemaining=pScrn->videoRam<<10; - /* Remove the cursor space */ - memRemaining-=4096; - /* Remove the main screen and offscreen pixmaps */ - memRemaining-=pTDFX->stride*(pScrn->virtualY+128); - /* Remove one scanline for page alignment */ - memRemaining-=4095; - /* Remove the back and Z buffers */ if (pTDFX->cpp!=3) { screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, TRUE, pTDFX->cpp); @@ -1627,41 +1625,77 @@ static void allocateMemory(ScrnInfoPtr pScrn) { screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, TRUE, 4); } - memRemaining-=screenSizeInTiles*2; - - /* Give all the rest to textures, rounded down to a page */ - texSize=memRemaining&~0xFFF; - - /* Make sure fifo has CMDFIFO_PAGES<fifoSize<255 pages */ - if (memRemaining-texSize<CMDFIFO_PAGES<<12) - texSize=(memRemaining-(CMDFIFO_PAGES<<12))&~0xFFF; - /* Fifo uses the remaining space up to 255 pages */ - fifoSize = (memRemaining-texSize)&~0xFFF; - if (fifoSize>255<<12) fifoSize=255<<12; - - /* Assign the variables */ - /* Cursor */ - pTDFX->cursorOffset=0; /* Size 1024 bytes */ - - /* Point the fifo at the first page */ + memRemaining=((pScrn->videoRam<<10) - 1) &~ 0xFFF; + /* Note that a page is 4096 bytes, and a */ + /* tile is 32 x 128 = 4096 bytes. So, */ + /* page and tile boundaries are the same */ + /* Place the depth offset first, forcing */ + /* it to be on an *odd* page boundary. */ + pTDFX->depthOffset = (memRemaining - screenSizeInTiles) &~ 0xFFF; + if ((pTDFX->depthOffset & (0x1 << 12)) == 0) { +#if 0 + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Changing depth offset from 0x%08x to 0x%08x\n", + pTDFX->depthOffset, + pTDFX->depthOffset - (0x1 << 12)); +#endif + pTDFX->depthOffset -= (0x1 << 12); + } + /* Now, place the back buffer, forcing it */ + /* to be on an *even* page boundary. */ + pTDFX->backOffset = (pTDFX->depthOffset - screenSizeInTiles) &~ 0xFFF; + if (pTDFX->backOffset & (0x1 << 12)) { +#if 0 + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Changing back offset from 0x%08x to 0x%08x\n", + pTDFX->backOffset, + pTDFX->backOffset - (0x1 << 12)); +#endif + pTDFX->backOffset -= (0x1 << 12); + } + /* Now, place the front buffer, forcing */ + /* it to be on a page boundary too, just */ + /* for giggles. */ + pTDFX->fbOffset + = (pTDFX->backOffset - (pScrn->virtualY+128)*pTDFX->stride) &~ 0xFFF; + /* Give the cmd fifo at least */ + /* CMDFIFO_PAGES pages, but no more than */ + /* 255. */ + fifoSize = ((255 <= CMDFIFO_PAGES) ? 255 : CMDFIFO_PAGES) << 12; + /* We give 4096 bytes to the cursor, fifoSize to the */ + /* FIFO, and everything to textures. */ + texSize = (pTDFX->fbOffset - fifoSize - 4096); + pTDFX->texOffset = pTDFX->fbOffset - texSize; + pTDFX->texSize = texSize; pTDFX->fifoOffset = 4096; pTDFX->fifoSize = fifoSize; - - /* Textures */ - pTDFX->texOffset = pTDFX->fifoOffset+fifoSize; - pTDFX->texSize = texSize; - - /* Frame buffer */ - pTDFX->fbOffset=pTDFX->texOffset+pTDFX->texSize; - - /* Back buffer */ - pTDFX->backOffset=pTDFX->fbOffset+(pScrn->virtualY+128)*pTDFX->stride; - /* Round off to a page */ - pTDFX->backOffset=(pTDFX->backOffset+4095)&~0xFFF; - - /* Depth buffer */ - pTDFX->depthOffset=pTDFX->backOffset+screenSizeInTiles; - + pTDFX->cursorOffset = 0; +#if 0 + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Cursor Offset: [0x%08X,0x%08X)\n", + pTDFX->cursorOffset, + pTDFX->cursorOffset+1024); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Fifo Offset: [0x%08X, 0x%08X)\n", + pTDFX->fifoOffset, + pTDFX->fifoOffset+fifoSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Texture Offset: [0x%08X, 0x%08X)\n", + pTDFX->texOffset, + pTDFX->texOffset + texSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Front Buffer Offset: [0x%08X, 0x%08X)\n", + pTDFX->fbOffset, + pTDFX->fbOffset + (pScrn->virtualY+128)*pTDFX->stride); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "BackOffset: [0x%08X, 0x%08X)\n", + pTDFX->backOffset, + pTDFX->backOffset+screenSizeInTiles); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "DepthOffset: [0x%08X, 0x%08X)\n", + pTDFX->depthOffset, + pTDFX->depthOffset+screenSizeInTiles); +#endif /* 0/1 */ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Textures Memory %0.02f MB\n", (float)texSize/1024.0/1024.0); } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile deleted file mode 100644 index 86518badb..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile +++ /dev/null @@ -1,35 +0,0 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile,v 3.4 2000/06/27 14:27:29 tsi Exp $ - - - - -XCOMM $XConsortium: Imakefile /main/4 1996/09/28 17:23:26 rws $ - -#include <Server.tmpl> - -#if AckToolset -IOSRC = inout.S -IOOBJ = inout.o -#endif - -SRCS = am_init.c am_video.c am_io.c ioperm_noop.c \ - VTsw_noop.c $(IOSRC) kmod_noop.c -OBJS = am_init.o am_video.o am_io.o ioperm_noop.o \ - VTsw_noop.o $(IOOBJ) kmod_noop.o - -INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ - -I$(XINCLUDESRC) - -SubdirLibraryRule($(OBJS)) -NormalLibraryObjectRule() -NormalAsmObjectRule() - -ObjectFromSpecialSource(ioperm_noop,../shared/ioperm_noop,/**/) -ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/) -ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/) -#if AckToolset -ObjectFromSpecialAsmSource(inout,../shared/inout,/**/) -#endif - -DependTarget() - diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c deleted file mode 100644 index 5a420efc1..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c +++ /dev/null @@ -1,56 +0,0 @@ -/* drmmodule.c -- Module initialization - * Created: Fri Jun 4 09:05:48 1999 by faith@precisioninsight.com - * Revised: Fri Jun 4 09:09:22 1999 by faith@precisioninsight.com - * - * Copyright 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 (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. - * - * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c,v 1.1 1999/06/07 13:01:42 faith Exp $ - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c,v 1.1 2000/06/17 00:03:27 martin Exp $ - * - */ - -#include "xf86Module.h" - -static MODULESETUPPROTO(drmSetup); - -static XF86ModuleVersionInfo VersRec = -{ - "drm", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XF86_VERSION_CURRENT, - 1, 0, 0, - ABI_CLASS_EXTENSION, - ABI_EXTENSION_VERSION, - MOD_CLASS_NONE, - {0,0,0,0} -}; - -XF86ModuleData drmModuleData = { &VersRec, drmSetup, NULL }; - -static pointer -drmSetup(pointer module, pointer opts, int *errmaj, int *errmin) -{ - return (void *)1; -} diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h deleted file mode 100644 index ddad1be7e..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h +++ /dev/null @@ -1,362 +0,0 @@ -/* drm.h -- Header for Direct Rendering Manager -*- c -*- - * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, 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 - * 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. - * - * Authors: - * Rickard E. (Rik) Faith <faith@valinux.com> - * - * Acknowledgements: - * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg. - * - */ - -#ifndef _DRM_H_ -#define _DRM_H_ - -#include <sys/ioccom.h> /* For _IO* macros */ - -#define DRM_DEV_DRM "/dev/drm" -#define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) -#define DRM_DEV_UID 0 -#define DRM_DEV_GID 0 - - -#define DRM_NAME "drm" /* Name in kernel, /dev */ -#define DRM_MIN_ORDER 5 /* At least 2^5 bytes = 32 bytes */ -#define DRM_MAX_ORDER 22 /* Up to 2^22 bytes = 4MB */ -#define DRM_RAM_PERCENT 10 /* How much system ram can we lock? */ - -#define _DRM_LOCK_HELD 0x80000000 /* Hardware lock is held */ -#define _DRM_LOCK_CONT 0x40000000 /* Hardware lock is contended */ -#define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD) -#define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT) -#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT)) - -typedef unsigned long drm_handle_t; -typedef unsigned int drm_context_t; -typedef unsigned int drm_drawable_t; -typedef unsigned int drm_magic_t; - -/* Warning: If you change this structure, make sure you change - * XF86DRIClipRectRec in the server as well */ - -typedef struct drm_clip_rect { - unsigned short x1; - unsigned short y1; - unsigned short x2; - unsigned short y2; -} drm_clip_rect_t; - -/* Seperate include files for the i810/mga/r128 specific structures */ -#include "mga_drm.h" -#include "i810_drm.h" -#include "r128_drm.h" - -typedef struct drm_version { - int version_major; /* Major version */ - int version_minor; /* Minor version */ - int version_patchlevel;/* Patch level */ - size_t name_len; /* Length of name buffer */ - char *name; /* Name of driver */ - size_t date_len; /* Length of date buffer */ - char *date; /* User-space buffer to hold date */ - size_t desc_len; /* Length of desc buffer */ - char *desc; /* User-space buffer to hold desc */ -} drm_version_t; - -typedef struct drm_unique { - size_t unique_len; /* Length of unique */ - char *unique; /* Unique name for driver instantiation */ -} drm_unique_t; - -typedef struct drm_list { - int count; /* Length of user-space structures */ - drm_version_t *version; -} drm_list_t; - -typedef struct drm_block { - int unused; -} drm_block_t; - -typedef struct drm_control { - enum { - DRM_ADD_COMMAND, - DRM_RM_COMMAND, - DRM_INST_HANDLER, - DRM_UNINST_HANDLER - } func; - int irq; -} drm_control_t; - -typedef enum drm_map_type { - _DRM_FRAME_BUFFER = 0, /* WC (no caching), no core dump */ - _DRM_REGISTERS = 1, /* no caching, no core dump */ - _DRM_SHM = 2, /* shared, cached */ - _DRM_AGP = 3 /* AGP/GART */ -} drm_map_type_t; - -typedef enum drm_map_flags { - _DRM_RESTRICTED = 0x01, /* Cannot be mapped to user-virtual */ - _DRM_READ_ONLY = 0x02, - _DRM_LOCKED = 0x04, /* shared, cached, locked */ - _DRM_KERNEL = 0x08, /* kernel requires access */ - _DRM_WRITE_COMBINING = 0x10, /* use write-combining if available */ - _DRM_CONTAINS_LOCK = 0x20 /* SHM page that contains lock */ -} drm_map_flags_t; - -typedef struct drm_map { - unsigned long offset; /* Requested physical address (0 for SAREA)*/ - unsigned long size; /* Requested physical size (bytes) */ - drm_map_type_t type; /* Type of memory to map */ - drm_map_flags_t flags; /* Flags */ - void *handle; /* User-space: "Handle" to pass to mmap */ - /* Kernel-space: kernel-virtual address */ - int mtrr; /* MTRR slot used */ - /* Private data */ -} drm_map_t; - -typedef enum drm_lock_flags { - _DRM_LOCK_READY = 0x01, /* Wait until hardware is ready for DMA */ - _DRM_LOCK_QUIESCENT = 0x02, /* Wait until hardware quiescent */ - _DRM_LOCK_FLUSH = 0x04, /* Flush this context's DMA queue first */ - _DRM_LOCK_FLUSH_ALL = 0x08, /* Flush all DMA queues first */ - /* These *HALT* flags aren't supported yet - -- they will be used to support the - full-screen DGA-like mode. */ - _DRM_HALT_ALL_QUEUES = 0x10, /* Halt all current and future queues */ - _DRM_HALT_CUR_QUEUES = 0x20 /* Halt all current queues */ -} drm_lock_flags_t; - -typedef struct drm_lock { - int context; - drm_lock_flags_t flags; -} drm_lock_t; - -typedef enum drm_dma_flags { /* These values *MUST* match xf86drm.h */ - /* Flags for DMA buffer dispatch */ - _DRM_DMA_BLOCK = 0x01, /* Block until buffer dispatched. - Note, the buffer may not yet have - been processed by the hardware -- - getting a hardware lock with the - hardware quiescent will ensure - that the buffer has been - processed. */ - _DRM_DMA_WHILE_LOCKED = 0x02, /* Dispatch while lock held */ - _DRM_DMA_PRIORITY = 0x04, /* High priority dispatch */ - - /* Flags for DMA buffer request */ - _DRM_DMA_WAIT = 0x10, /* Wait for free buffers */ - _DRM_DMA_SMALLER_OK = 0x20, /* Smaller-than-requested buffers ok */ - _DRM_DMA_LARGER_OK = 0x40 /* Larger-than-requested buffers ok */ -} drm_dma_flags_t; - -typedef struct drm_buf_desc { - int count; /* Number of buffers of this size */ - int size; /* Size in bytes */ - int low_mark; /* Low water mark */ - int high_mark; /* High water mark */ - enum { - _DRM_PAGE_ALIGN = 0x01, /* Align on page boundaries for DMA */ - _DRM_AGP_BUFFER = 0x02 /* Buffer is in agp space */ - } flags; - unsigned long agp_start; /* Start address of where the agp buffers - * are in the agp aperture */ -} drm_buf_desc_t; - -typedef struct drm_buf_info { - int count; /* Entries in list */ - drm_buf_desc_t *list; -} drm_buf_info_t; - -typedef struct drm_buf_free { - int count; - int *list; -} drm_buf_free_t; - -typedef struct drm_buf_pub { - int idx; /* Index into master buflist */ - int total; /* Buffer size */ - int used; /* Amount of buffer in use (for DMA) */ - void *address; /* Address of buffer */ -} drm_buf_pub_t; - -typedef struct drm_buf_map { - int count; /* Length of buflist */ - void *virtual; /* Mmaped area in user-virtual */ - drm_buf_pub_t *list; /* Buffer information */ -} drm_buf_map_t; - -typedef struct drm_dma { - /* Indices here refer to the offset into - buflist in drm_buf_get_t. */ - int context; /* Context handle */ - int send_count; /* Number of buffers to send */ - int *send_indices; /* List of handles to buffers */ - int *send_sizes; /* Lengths of data to send */ - drm_dma_flags_t flags; /* Flags */ - int request_count; /* Number of buffers requested */ - int request_size; /* Desired size for buffers */ - int *request_indices; /* Buffer information */ - int *request_sizes; - int granted_count; /* Number of buffers granted */ -} drm_dma_t; - -typedef enum { - _DRM_CONTEXT_PRESERVED = 0x01, - _DRM_CONTEXT_2DONLY = 0x02 -} drm_ctx_flags_t; - -typedef struct drm_ctx { - drm_context_t handle; - drm_ctx_flags_t flags; -} drm_ctx_t; - -typedef struct drm_ctx_res { - int count; - drm_ctx_t *contexts; -} drm_ctx_res_t; - -typedef struct drm_draw { - drm_drawable_t handle; -} drm_draw_t; - -typedef struct drm_auth { - drm_magic_t magic; -} drm_auth_t; - -typedef struct drm_irq_busid { - int irq; - int busnum; - int devnum; - int funcnum; -} drm_irq_busid_t; - -typedef struct drm_agp_mode { - unsigned long mode; -} drm_agp_mode_t; - - /* For drm_agp_alloc -- allocated a buffer */ -typedef struct drm_agp_buffer { - unsigned long size; /* In bytes -- will round to page boundary */ - unsigned long handle; /* Used for BIND/UNBIND ioctls */ - unsigned long type; /* Type of memory to allocate */ - unsigned long physical; /* Physical used by i810 */ -} drm_agp_buffer_t; - - /* For drm_agp_bind */ -typedef struct drm_agp_binding { - unsigned long handle; /* From drm_agp_buffer */ - unsigned long offset; /* In bytes -- will round to page boundary */ -} drm_agp_binding_t; - -typedef struct drm_agp_info { - int agp_version_major; - int agp_version_minor; - unsigned long mode; - unsigned long aperture_base; /* physical address */ - unsigned long aperture_size; /* bytes */ - unsigned long memory_allowed; /* bytes */ - unsigned long memory_used; - - /* PCI information */ - unsigned short id_vendor; - unsigned short id_device; -} drm_agp_info_t; - -#define DRM_IOCTL_BASE 'd' -#define DRM_IOCTL_NR(n) ((n) & 0xff) -#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr) -#define DRM_IOR(nr,size) _IOR(DRM_IOCTL_BASE,nr,size) -#define DRM_IOW(nr,size) _IOW(DRM_IOCTL_BASE,nr,size) -#define DRM_IOWR(nr,size) _IOWR(DRM_IOCTL_BASE,nr,size) - - -#define DRM_IOCTL_VERSION DRM_IOWR(0x00, drm_version_t) -#define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, drm_unique_t) -#define DRM_IOCTL_GET_MAGIC DRM_IOR( 0x02, drm_auth_t) -#define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, drm_irq_busid_t) - -#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm_unique_t) -#define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, drm_auth_t) -#define DRM_IOCTL_BLOCK DRM_IOWR(0x12, drm_block_t) -#define DRM_IOCTL_UNBLOCK DRM_IOWR(0x13, drm_block_t) -#define DRM_IOCTL_CONTROL DRM_IOW( 0x14, drm_control_t) -#define DRM_IOCTL_ADD_MAP DRM_IOWR(0x15, drm_map_t) -#define DRM_IOCTL_ADD_BUFS DRM_IOWR(0x16, drm_buf_desc_t) -#define DRM_IOCTL_MARK_BUFS DRM_IOW( 0x17, drm_buf_desc_t) -#define DRM_IOCTL_INFO_BUFS DRM_IOWR(0x18, drm_buf_info_t) -#define DRM_IOCTL_MAP_BUFS DRM_IOWR(0x19, drm_buf_map_t) -#define DRM_IOCTL_FREE_BUFS DRM_IOW( 0x1a, drm_buf_free_t) - -#define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, drm_ctx_t) -#define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, drm_ctx_t) -#define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, drm_ctx_t) -#define DRM_IOCTL_GET_CTX DRM_IOWR(0x23, drm_ctx_t) -#define DRM_IOCTL_SWITCH_CTX DRM_IOW( 0x24, drm_ctx_t) -#define DRM_IOCTL_NEW_CTX DRM_IOW( 0x25, drm_ctx_t) -#define DRM_IOCTL_RES_CTX DRM_IOWR(0x26, drm_ctx_res_t) -#define DRM_IOCTL_ADD_DRAW DRM_IOWR(0x27, drm_draw_t) -#define DRM_IOCTL_RM_DRAW DRM_IOWR(0x28, drm_draw_t) -#define DRM_IOCTL_DMA DRM_IOWR(0x29, drm_dma_t) -#define DRM_IOCTL_LOCK DRM_IOW( 0x2a, drm_lock_t) -#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, drm_lock_t) -#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, drm_lock_t) - -#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30) -#define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31) -#define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, drm_agp_mode_t) -#define DRM_IOCTL_AGP_INFO DRM_IOR( 0x33, drm_agp_info_t) -#define DRM_IOCTL_AGP_ALLOC DRM_IOWR(0x34, drm_agp_buffer_t) -#define DRM_IOCTL_AGP_FREE DRM_IOW( 0x35, drm_agp_buffer_t) -#define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, drm_agp_binding_t) -#define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, drm_agp_binding_t) - -/* Mga specific ioctls */ -#define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t) -#define DRM_IOCTL_MGA_SWAP DRM_IOW( 0x41, drm_mga_swap_t) -#define DRM_IOCTL_MGA_CLEAR DRM_IOW( 0x42, drm_mga_clear_t) -#define DRM_IOCTL_MGA_ILOAD DRM_IOW( 0x43, drm_mga_iload_t) -#define DRM_IOCTL_MGA_VERTEX DRM_IOW( 0x44, drm_mga_vertex_t) -#define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x45, drm_lock_t ) -#define DRM_IOCTL_MGA_INDICES DRM_IOW( 0x46, drm_mga_indices_t) - -/* I810 specific ioctls */ -#define DRM_IOCTL_I810_INIT DRM_IOW( 0x40, drm_i810_init_t) -#define DRM_IOCTL_I810_VERTEX DRM_IOW( 0x41, drm_i810_vertex_t) -#define DRM_IOCTL_I810_CLEAR DRM_IOW( 0x42, drm_i810_clear_t) -#define DRM_IOCTL_I810_FLUSH DRM_IO ( 0x43) -#define DRM_IOCTL_I810_GETAGE DRM_IO ( 0x44) -#define DRM_IOCTL_I810_GETBUF DRM_IOWR(0x45, drm_i810_dma_t) -#define DRM_IOCTL_I810_SWAP DRM_IO ( 0x46) - -/* Rage 128 specific ioctls */ -#define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t) -#define DRM_IOCTL_R128_RESET DRM_IO( 0x41) -#define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42) -#define DRM_IOCTL_R128_CCEIDL DRM_IO( 0x43) -#define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t) -#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t) - -#endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h deleted file mode 100644 index 4c8e09f6a..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h +++ /dev/null @@ -1,188 +0,0 @@ -#ifndef _I810_DRM_H_ -#define _I810_DRM_H_ - -/* WARNING: These defines must be the same as what the Xserver uses. - * if you change them, you must change the defines in the Xserver. - */ - -#ifndef _I810_DEFINES_ -#define _I810_DEFINES_ - -#define I810_DMA_BUF_ORDER 12 -#define I810_DMA_BUF_SZ (1<<I810_DMA_BUF_ORDER) -#define I810_DMA_BUF_NR 256 -#define I810_NR_SAREA_CLIPRECTS 8 - -/* Each region is a minimum of 64k, and there are at most 64 of them. - */ -#define I810_NR_TEX_REGIONS 64 -#define I810_LOG_MIN_TEX_REGION_SIZE 16 -#endif - -#define I810_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */ -#define I810_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */ -#define I810_UPLOAD_CTX 0x4 -#define I810_UPLOAD_BUFFERS 0x8 -#define I810_UPLOAD_TEX0 0x10 -#define I810_UPLOAD_TEX1 0x20 -#define I810_UPLOAD_CLIPRECTS 0x40 - - -/* Indices into buf.Setup where various bits of state are mirrored per - * context and per buffer. These can be fired at the card as a unit, - * or in a piecewise fashion as required. - */ - -/* Destbuffer state - * - backbuffer linear offset and pitch -- invarient in the current dri - * - zbuffer linear offset and pitch -- also invarient - * - drawing origin in back and depth buffers. - * - * Keep the depth/back buffer state here to acommodate private buffers - * in the future. - */ -#define I810_DESTREG_DI0 0 /* CMD_OP_DESTBUFFER_INFO (2 dwords) */ -#define I810_DESTREG_DI1 1 -#define I810_DESTREG_DV0 2 /* GFX_OP_DESTBUFFER_VARS (2 dwords) */ -#define I810_DESTREG_DV1 3 -#define I810_DESTREG_DR0 4 /* GFX_OP_DRAWRECT_INFO (4 dwords) */ -#define I810_DESTREG_DR1 5 -#define I810_DESTREG_DR2 6 -#define I810_DESTREG_DR3 7 -#define I810_DESTREG_DR4 8 -#define I810_DEST_SETUP_SIZE 10 - -/* Context state - */ -#define I810_CTXREG_CF0 0 /* GFX_OP_COLOR_FACTOR */ -#define I810_CTXREG_CF1 1 -#define I810_CTXREG_ST0 2 /* GFX_OP_STIPPLE */ -#define I810_CTXREG_ST1 3 -#define I810_CTXREG_VF 4 /* GFX_OP_VERTEX_FMT */ -#define I810_CTXREG_MT 5 /* GFX_OP_MAP_TEXELS */ -#define I810_CTXREG_MC0 6 /* GFX_OP_MAP_COLOR_STAGES - stage 0 */ -#define I810_CTXREG_MC1 7 /* GFX_OP_MAP_COLOR_STAGES - stage 1 */ -#define I810_CTXREG_MC2 8 /* GFX_OP_MAP_COLOR_STAGES - stage 2 */ -#define I810_CTXREG_MA0 9 /* GFX_OP_MAP_ALPHA_STAGES - stage 0 */ -#define I810_CTXREG_MA1 10 /* GFX_OP_MAP_ALPHA_STAGES - stage 1 */ -#define I810_CTXREG_MA2 11 /* GFX_OP_MAP_ALPHA_STAGES - stage 2 */ -#define I810_CTXREG_SDM 12 /* GFX_OP_SRC_DEST_MONO */ -#define I810_CTXREG_FOG 13 /* GFX_OP_FOG_COLOR */ -#define I810_CTXREG_B1 14 /* GFX_OP_BOOL_1 */ -#define I810_CTXREG_B2 15 /* GFX_OP_BOOL_2 */ -#define I810_CTXREG_LCS 16 /* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */ -#define I810_CTXREG_PV 17 /* GFX_OP_PV_RULE -- Invarient! */ -#define I810_CTXREG_ZA 18 /* GFX_OP_ZBIAS_ALPHAFUNC */ -#define I810_CTXREG_AA 19 /* GFX_OP_ANTIALIAS */ -#define I810_CTX_SETUP_SIZE 20 - -/* Texture state (per tex unit) - */ -#define I810_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (4 dwords) */ -#define I810_TEXREG_MI1 1 -#define I810_TEXREG_MI2 2 -#define I810_TEXREG_MI3 3 -#define I810_TEXREG_MF 4 /* GFX_OP_MAP_FILTER */ -#define I810_TEXREG_MLC 5 /* GFX_OP_MAP_LOD_CTL */ -#define I810_TEXREG_MLL 6 /* GFX_OP_MAP_LOD_LIMITS */ -#define I810_TEXREG_MCS 7 /* GFX_OP_MAP_COORD_SETS ??? */ -#define I810_TEX_SETUP_SIZE 8 - -#define I810_FRONT 0x1 -#define I810_BACK 0x2 -#define I810_DEPTH 0x4 - - -typedef struct _drm_i810_init { - enum { - I810_INIT_DMA = 0x01, - I810_CLEANUP_DMA = 0x02 - } func; - int ring_map_idx; - int buffer_map_idx; - int sarea_priv_offset; - unsigned int ring_start; - unsigned int ring_end; - unsigned int ring_size; - unsigned int front_offset; - unsigned int back_offset; - unsigned int depth_offset; - unsigned int w; - unsigned int h; - unsigned int pitch; - unsigned int pitch_bits; -} drm_i810_init_t; - -/* Warning: If you change the SAREA structure you must change the Xserver - * structure as well */ - -typedef struct _drm_i810_tex_region { - unsigned char next, prev; /* indices to form a circular LRU */ - unsigned char in_use; /* owned by a client, or free? */ - int age; /* tracked by clients to update local LRU's */ -} drm_i810_tex_region_t; - -typedef struct _drm_i810_sarea { - unsigned int ContextState[I810_CTX_SETUP_SIZE]; - unsigned int BufferState[I810_DEST_SETUP_SIZE]; - unsigned int TexState[2][I810_TEX_SETUP_SIZE]; - unsigned int dirty; - - unsigned int nbox; - drm_clip_rect_t boxes[I810_NR_SAREA_CLIPRECTS]; - - /* 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. - */ - - drm_i810_tex_region_t texList[I810_NR_TEX_REGIONS+1]; - /* Last elt is sentinal */ - int texAge; /* last time texture was uploaded */ - int last_enqueue; /* last time a buffer was enqueued */ - int last_dispatch; /* age of the most recently dispatched buffer */ - int last_quiescent; /* */ - int ctxOwner; /* last context to upload state */ - - int vertex_prim; - -} drm_i810_sarea_t; - -typedef struct _drm_i810_clear { - int clear_color; - int clear_depth; - int flags; -} drm_i810_clear_t; - - - -/* These may be placeholders if we have more cliprects than - * I810_NR_SAREA_CLIPRECTS. In that case, the client sets discard to - * false, indicating that the buffer will be dispatched again with a - * new set of cliprects. - */ -typedef struct _drm_i810_vertex { - int idx; /* buffer index */ - int used; /* nr bytes in use */ - int discard; /* client is finished with the buffer? */ -} drm_i810_vertex_t; - -typedef struct drm_i810_dma { - void *virtual; - int request_idx; - int request_size; - int granted; -} drm_i810_dma_t; - -#endif /* _I810_DRM_H_ */ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h deleted file mode 100644 index eefa28d3f..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h +++ /dev/null @@ -1,269 +0,0 @@ -/* mga_drm.h -- Public header for the Matrox g200/g400 driver - * Created: Tue Jan 25 01:50:01 1999 by jhartmann@precisioninsight.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, 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 - * 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. - * - * Authors: Jeff Hartmann <jhartmann@valinux.com> - * Keith Whitwell <keithw@valinux.com> - * - */ - -#ifndef _MGA_DRM_H_ -#define _MGA_DRM_H_ - -/* WARNING: If you change any of these defines, make sure to change the - * defines in the Xserver file (xf86drmMga.h) - */ -#ifndef _MGA_DEFINES_ -#define _MGA_DEFINES_ - -#define MGA_F 0x1 /* fog */ -#define MGA_A 0x2 /* alpha */ -#define MGA_S 0x4 /* specular */ -#define MGA_T2 0x8 /* multitexture */ - -#define MGA_WARP_TGZ 0 -#define MGA_WARP_TGZF (MGA_F) -#define MGA_WARP_TGZA (MGA_A) -#define MGA_WARP_TGZAF (MGA_F|MGA_A) -#define MGA_WARP_TGZS (MGA_S) -#define MGA_WARP_TGZSF (MGA_S|MGA_F) -#define MGA_WARP_TGZSA (MGA_S|MGA_A) -#define MGA_WARP_TGZSAF (MGA_S|MGA_F|MGA_A) -#define MGA_WARP_T2GZ (MGA_T2) -#define MGA_WARP_T2GZF (MGA_T2|MGA_F) -#define MGA_WARP_T2GZA (MGA_T2|MGA_A) -#define MGA_WARP_T2GZAF (MGA_T2|MGA_A|MGA_F) -#define MGA_WARP_T2GZS (MGA_T2|MGA_S) -#define MGA_WARP_T2GZSF (MGA_T2|MGA_S|MGA_F) -#define MGA_WARP_T2GZSA (MGA_T2|MGA_S|MGA_A) -#define MGA_WARP_T2GZSAF (MGA_T2|MGA_S|MGA_F|MGA_A) - -#define MGA_MAX_G400_PIPES 16 -#define MGA_MAX_G200_PIPES 8 /* no multitex */ -#define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES - -#define MGA_CARD_TYPE_G200 1 -#define MGA_CARD_TYPE_G400 2 - -#define MGA_FRONT 0x1 -#define MGA_BACK 0x2 -#define MGA_DEPTH 0x4 - -/* 3d state excluding texture units: - */ -#define MGA_CTXREG_DSTORG 0 /* validated */ -#define MGA_CTXREG_MACCESS 1 -#define MGA_CTXREG_PLNWT 2 -#define MGA_CTXREG_DWGCTL 3 -#define MGA_CTXREG_ALPHACTRL 4 -#define MGA_CTXREG_FOGCOLOR 5 -#define MGA_CTXREG_WFLAG 6 -#define MGA_CTXREG_TDUAL0 7 -#define MGA_CTXREG_TDUAL1 8 -#define MGA_CTXREG_FCOL 9 -#define MGA_CTX_SETUP_SIZE 10 - -/* 2d state - */ -#define MGA_2DREG_PITCH 0 -#define MGA_2D_SETUP_SIZE 1 - -/* Each texture unit has a state: - */ -#define MGA_TEXREG_CTL 0 -#define MGA_TEXREG_CTL2 1 -#define MGA_TEXREG_FILTER 2 -#define MGA_TEXREG_BORDERCOL 3 -#define MGA_TEXREG_ORG 4 /* validated */ -#define MGA_TEXREG_ORG1 5 -#define MGA_TEXREG_ORG2 6 -#define MGA_TEXREG_ORG3 7 -#define MGA_TEXREG_ORG4 8 -#define MGA_TEXREG_WIDTH 9 -#define MGA_TEXREG_HEIGHT 10 -#define MGA_TEX_SETUP_SIZE 11 - -/* What needs to be changed for the current vertex dma buffer? - */ -#define MGA_UPLOAD_CTX 0x1 -#define MGA_UPLOAD_TEX0 0x2 -#define MGA_UPLOAD_TEX1 0x4 -#define MGA_UPLOAD_PIPE 0x8 -#define MGA_UPLOAD_TEX0IMAGE 0x10 /* handled client-side */ -#define MGA_UPLOAD_TEX1IMAGE 0x20 /* handled client-side */ -#define MGA_UPLOAD_2D 0x40 -#define MGA_WAIT_AGE 0x80 /* handled client-side */ -#define MGA_UPLOAD_CLIPRECTS 0x100 /* handled client-side */ -#define MGA_DMA_FLUSH 0x200 /* set when someone gets the lock - quiescent */ - -/* 32 buffers of 64k each, total 2 meg. - */ -#define MGA_DMA_BUF_ORDER 16 -#define MGA_DMA_BUF_SZ (1<<MGA_DMA_BUF_ORDER) -#define MGA_DMA_BUF_NR 31 - -/* Keep these small for testing. - */ -#define MGA_NR_SAREA_CLIPRECTS 8 - -/* 2 heaps (1 for card, 1 for agp), each divided into upto 128 - * regions, subject to a minimum region size of (1<<16) == 64k. - * - * Clients may subdivide regions internally, but when sharing between - * clients, the region size is the minimum granularity. - */ - -#define MGA_CARD_HEAP 0 -#define MGA_AGP_HEAP 1 -#define MGA_NR_TEX_HEAPS 2 -#define MGA_NR_TEX_REGIONS 16 -#define MGA_LOG_MIN_TEX_REGION_SIZE 16 -#endif - -typedef struct _drm_mga_warp_index { - int installed; - unsigned long phys_addr; - int size; -} drm_mga_warp_index_t; - -typedef struct drm_mga_init { - enum { - MGA_INIT_DMA = 0x01, - MGA_CLEANUP_DMA = 0x02 - } func; - int reserved_map_agpstart; - int reserved_map_idx; - int buffer_map_idx; - int sarea_priv_offset; - int primary_size; - int warp_ucode_size; - unsigned int frontOffset; - unsigned int backOffset; - unsigned int depthOffset; - unsigned int textureOffset; - unsigned int textureSize; - unsigned int agpTextureOffset; - unsigned int agpTextureSize; - unsigned int cpp; - unsigned int stride; - int sgram; - int chipset; - drm_mga_warp_index_t WarpIndex[MGA_MAX_WARP_PIPES]; - unsigned int mAccess; -} drm_mga_init_t; - -/* Warning: if you change the sarea structure, you must change the Xserver - * structures as well */ - -typedef struct _drm_mga_tex_region { - unsigned char next, prev; - unsigned char in_use; - unsigned int age; -} drm_mga_tex_region_t; - -typedef struct _drm_mga_sarea { - /* The channel for communication of state information to the kernel - * on firing a vertex dma buffer. - */ - unsigned int ContextState[MGA_CTX_SETUP_SIZE]; - unsigned int ServerState[MGA_2D_SETUP_SIZE]; - unsigned int TexState[2][MGA_TEX_SETUP_SIZE]; - unsigned int WarpPipe; - unsigned int dirty; - - unsigned int nbox; - drm_clip_rect_t boxes[MGA_NR_SAREA_CLIPRECTS]; - - - /* Information about the most recently used 3d drawable. The - * client fills in the req_* fields, the server fills in the - * exported_ fields and puts the cliprects into boxes, above. - * - * The client clears the exported_drawable field before - * clobbering the boxes data. - */ - unsigned int req_drawable; /* the X drawable id */ - unsigned int req_draw_buffer; /* MGA_FRONT or MGA_BACK */ - - unsigned int exported_drawable; - unsigned int exported_index; - unsigned int exported_stamp; - unsigned int exported_buffers; - unsigned int exported_nfront; - unsigned int exported_nback; - int exported_back_x, exported_front_x, exported_w; - int exported_back_y, exported_front_y, exported_h; - drm_clip_rect_t exported_boxes[MGA_NR_SAREA_CLIPRECTS]; - - /* Counters for aging textures and for client-side throttling. - */ - unsigned int last_enqueue; /* last time a buffer was enqueued */ - unsigned int last_dispatch; /* age of the most recently dispatched buffer */ - unsigned int last_quiescent; /* */ - - - /* LRU lists for texture memory in agp space and on the card - */ - drm_mga_tex_region_t texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS+1]; - unsigned int texAge[MGA_NR_TEX_HEAPS]; - - /* Mechanism to validate card state. - */ - int ctxOwner; -} drm_mga_sarea_t; - -/* Device specific ioctls: - */ -typedef struct _drm_mga_clear { - unsigned int clear_color; - unsigned int clear_depth; - unsigned int flags; -} drm_mga_clear_t; - -typedef struct _drm_mga_swap { - int dummy; -} drm_mga_swap_t; - -typedef struct _drm_mga_iload { - int idx; - int length; - unsigned int destOrg; -} drm_mga_iload_t; - -typedef struct _drm_mga_vertex { - int idx; /* buffer to queue */ - int used; /* bytes in use */ - int discard; /* client finished with buffer? */ -} drm_mga_vertex_t; - -typedef struct _drm_mga_indices { - int idx; /* buffer to queue */ - unsigned int start; - unsigned int end; - int discard; /* client finished with buffer? */ -} drm_mga_indices_t; - -#endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h deleted file mode 100644 index bff103c23..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h +++ /dev/null @@ -1,111 +0,0 @@ -/* r128_drm.h -- Public header for the r128 driver -*- linux-c -*- - * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com - * - * Copyright 2000 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 (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. - * - * Authors: Kevin E. Martin <kevin@precisioninsight.com> - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h,v 1.1 2000/06/17 00:03:29 martin Exp $ - */ - -#ifndef _R128_DRM_H_ -#define _R128_DRM_H_ - -/* WARNING: If you change any of these defines, make sure to change the - * defines in the Xserver file (xf86drmR128.h) - */ -typedef struct drm_r128_init { - enum { - R128_INIT_CCE = 0x01, - R128_CLEANUP_CCE = 0x02 - } func; - int sarea_priv_offset; - int is_pci; - int cce_mode; - int cce_fifo_size; - int cce_secure; - int ring_size; - int usec_timeout; - - int fb_offset; - int agp_ring_offset; - int agp_read_ptr_offset; - int agp_vertbufs_offset; - int agp_indbufs_offset; - int agp_textures_offset; - int mmio_offset; -} drm_r128_init_t; - -typedef struct drm_r128_packet { - unsigned long *buffer; - int count; - int flags; -} drm_r128_packet_t; - -typedef enum drm_r128_prim { - _DRM_R128_PRIM_NONE = 0x0001, - _DRM_R128_PRIM_POINT = 0x0002, - _DRM_R128_PRIM_LINE = 0x0004, - _DRM_R128_PRIM_POLY_LINE = 0x0008, - _DRM_R128_PRIM_TRI_LIST = 0x0010, - _DRM_R128_PRIM_TRI_FAN = 0x0020, - _DRM_R128_PRIM_TRI_STRIP = 0x0040, - _DRM_R128_PRIM_TRI_TYPE2 = 0x0080 -} drm_r128_prim_t; - -typedef struct drm_r128_vertex { - /* Indices here refer to the offset into - buflist in drm_buf_get_t. */ - int send_count; /* Number of buffers to send */ - int *send_indices; /* List of handles to buffers */ - int *send_sizes; /* Lengths of data to send */ - drm_r128_prim_t prim; /* Primitive type */ - int request_count; /* Number of buffers requested */ - int *request_indices; /* Buffer information */ - int *request_sizes; - int granted_count; /* Number of buffers granted */ -} drm_r128_vertex_t; - -/* WARNING: If you change any of these defines, make sure to change the - * defines in the Xserver file (r128_sarea.h) - */ -#define R128_LOCAL_TEX_HEAP 0 -#define R128_AGP_TEX_HEAP 1 -#define R128_NR_TEX_HEAPS 2 -#define R128_NR_TEX_REGIONS 64 -#define R128_LOG_TEX_GRANULARITY 16 - -typedef struct drm_tex_region { - unsigned char next, prev; - unsigned char in_use; - int age; -} drm_tex_region_t; - -typedef struct drm_r128_sarea { - drm_tex_region_t tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1]; - int tex_age[R128_NR_TEX_HEAPS]; - int ctx_owner; - int ring_write; -} drm_r128_sarea_t; - -#endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c deleted file mode 100644 index 67cd444be..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c +++ /dev/null @@ -1,435 +0,0 @@ -/* xf86drmHash.c -- Small hash table support for integer -> integer mapping - * Created: Sun Apr 18 09:35:45 1999 by faith@precisioninsight.com - * Revised: Thu Jun 3 16:11:06 1999 by faith@precisioninsight.com - * - * Copyright 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 (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. - * - * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c,v 1.3 1999/06/07 13:01:42 faith Exp $ - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c,v 1.1 2000/06/17 00:03:27 martin Exp $ - * - * DESCRIPTION - * - * This file contains a straightforward implementation of a fixed-sized - * hash table using self-organizing linked lists [Knuth73, pp. 398-399] for - * collision resolution. There are two potentially interesting things - * about this implementation: - * - * 1) The table is power-of-two sized. Prime sized tables are more - * traditional, but do not have a significant advantage over power-of-two - * sized table, especially when double hashing is not used for collision - * resolution. - * - * 2) The hash computation uses a table of random integers [Hanson97, - * pp. 39-41]. - * - * FUTURE ENHANCEMENTS - * - * With a table size of 512, the current implementation is sufficient for a - * few hundred keys. Since this is well above the expected size of the - * tables for which this implementation was designed, the implementation of - * dynamic hash tables was postponed until the need arises. A common (and - * naive) approach to dynamic hash table implementation simply creates a - * new hash table when necessary, rehashes all the data into the new table, - * and destroys the old table. The approach in [Larson88] is superior in - * two ways: 1) only a portion of the table is expanded when needed, - * distributing the expansion cost over several insertions, and 2) portions - * of the table can be locked, enabling a scalable thread-safe - * implementation. - * - * REFERENCES - * - * [Hanson97] David R. Hanson. C Interfaces and Implementations: - * Techniques for Creating Reusable Software. Reading, Massachusetts: - * Addison-Wesley, 1997. - * - * [Knuth73] Donald E. Knuth. The Art of Computer Programming. Volume 3: - * Sorting and Searching. Reading, Massachusetts: Addison-Wesley, 1973. - * - * [Larson88] Per-Ake Larson. "Dynamic Hash Tables". CACM 31(4), April - * 1988, pp. 446-457. - * - */ - -#define HASH_MAIN 0 - -#if HASH_MAIN -# include <stdio.h> -# include <stdlib.h> -#else -# include "xf86drm.h" -# ifdef XFree86LOADER -# include "xf86.h" -# include "xf86_ansic.h" -# else -# include <stdio.h> -# include <stdlib.h> -# endif -#endif - -#define N(x) drm##x - -#define HASH_MAGIC 0xdeadbeef -#define HASH_DEBUG 0 -#define HASH_SIZE 512 /* Good for about 100 entries */ - /* If you change this value, you probably - have to change the HashHash hashing - function! */ - -#if HASH_MAIN -#define HASH_ALLOC malloc -#define HASH_FREE free -#define HASH_RANDOM_DECL -#define HASH_RANDOM_INIT(seed) srandom(seed) -#define HASH_RANDOM random() -#else -#define HASH_ALLOC drmMalloc -#define HASH_FREE drmFree -#define HASH_RANDOM_DECL void *state -#define HASH_RANDOM_INIT(seed) state = drmRandomCreate(seed) -#define HASH_RANDOM drmRandom(state) - -#endif - -typedef struct HashBucket { - unsigned long key; - void *value; - struct HashBucket *next; -} HashBucket, *HashBucketPtr; - -typedef struct HashTable { - unsigned long magic; - unsigned long entries; - unsigned long hits; /* At top of linked list */ - unsigned long partials; /* Not at top of linked list */ - unsigned long misses; /* Not in table */ - HashBucketPtr buckets[HASH_SIZE]; - int p0; - HashBucketPtr p1; -} HashTable, *HashTablePtr; - -#if HASH_MAIN -extern void *N(HashCreate)(void); -extern int N(HashDestroy)(void *t); -extern int N(HashLookup)(void *t, unsigned long key, unsigned long *value); -extern int N(HashInsert)(void *t, unsigned long key, unsigned long value); -extern int N(HashDelete)(void *t, unsigned long key); -#endif - -static unsigned long HashHash(unsigned long key) -{ - unsigned long hash = 0; - unsigned long tmp = key; - static int init = 0; - static unsigned long scatter[256]; - int i; - - if (!init) { - HASH_RANDOM_DECL; - HASH_RANDOM_INIT(37); - for (i = 0; i < 256; i++) scatter[i] = HASH_RANDOM; - ++init; - } - - while (tmp) { - hash = (hash << 1) + scatter[tmp & 0xff]; - tmp >>= 8; - } - - hash %= HASH_SIZE; -#if HASH_DEBUG - printf( "Hash(%d) = %d\n", key, hash); -#endif - return hash; -} - -void *N(HashCreate)(void) -{ - HashTablePtr table; - int i; - - table = HASH_ALLOC(sizeof(*table)); - if (!table) return NULL; - table->magic = HASH_MAGIC; - table->entries = 0; - table->hits = 0; - table->partials = 0; - table->misses = 0; - - for (i = 0; i < HASH_SIZE; i++) table->buckets[i] = NULL; - return table; -} - -int N(HashDestroy)(void *t) -{ - HashTablePtr table = (HashTablePtr)t; - HashBucketPtr bucket; - HashBucketPtr next; - int i; - - if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - - for (i = 0; i < HASH_SIZE; i++) { - for (bucket = table->buckets[i]; bucket;) { - next = bucket->next; - HASH_FREE(bucket); - bucket = next; - } - } - HASH_FREE(table); - return 0; -} - -/* Find the bucket and organize the list so that this bucket is at the - top. */ - -static HashBucketPtr HashFind(HashTablePtr table, - unsigned long key, unsigned long *h) -{ - unsigned long hash = HashHash(key); - HashBucketPtr prev = NULL; - HashBucketPtr bucket; - - if (h) *h = hash; - - for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) { - if (bucket->key == key) { - if (prev) { - /* Organize */ - prev->next = bucket->next; - bucket->next = table->buckets[hash]; - table->buckets[hash] = bucket; - ++table->partials; - } else { - ++table->hits; - } - return bucket; - } - prev = bucket; - } - ++table->misses; - return NULL; -} - -int N(HashLookup)(void *t, unsigned long key, void **value) -{ - HashTablePtr table = (HashTablePtr)t; - HashBucketPtr bucket; - - if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - - bucket = HashFind(table, key, NULL); - if (!bucket) return 1; /* Not found */ - *value = bucket->value; - return 0; /* Found */ -} - -int N(HashInsert)(void *t, unsigned long key, void *value) -{ - HashTablePtr table = (HashTablePtr)t; - HashBucketPtr bucket; - unsigned long hash; - - if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - - if (HashFind(table, key, &hash)) return 1; /* Already in table */ - - bucket = HASH_ALLOC(sizeof(*bucket)); - if (!bucket) return -1; /* Error */ - bucket->key = key; - bucket->value = value; - bucket->next = table->buckets[hash]; - table->buckets[hash] = bucket; -#if HASH_DEBUG - printf("Inserted %d at %d/%p\n", key, hash, bucket); -#endif - return 0; /* Added to table */ -} - -int N(HashDelete)(void *t, unsigned long key) -{ - HashTablePtr table = (HashTablePtr)t; - unsigned long hash; - HashBucketPtr bucket; - - if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - - bucket = HashFind(table, key, &hash); - - if (!bucket) return 1; /* Not found */ - - table->buckets[hash] = bucket->next; - HASH_FREE(bucket); - return 0; -} - -int N(HashNext)(void *t, unsigned long *key, void **value) -{ - HashTablePtr table = (HashTablePtr)t; - - for (; table->p0 < HASH_SIZE; - ++table->p0, table->p1 = table->buckets[table->p0]) { - if (table->p1) { - *key = table->p1->key; - *value = table->p1->value; - table->p1 = table->p1->next; - return 1; - } - } - return 0; -} - -int N(HashFirst)(void *t, unsigned long *key, void **value) -{ - HashTablePtr table = (HashTablePtr)t; - - if (table->magic != HASH_MAGIC) return -1; /* Bad magic */ - - table->p0 = 0; - table->p1 = table->buckets[0]; - return N(HashNext)(table, key, value); -} - -#if HASH_MAIN -#define DIST_LIMIT 10 -static int dist[DIST_LIMIT]; - -static void clear_dist(void) { - int i; - - for (i = 0; i < DIST_LIMIT; i++) dist[i] = 0; -} - -static int count_entries(HashBucketPtr bucket) -{ - int count = 0; - - for (; bucket; bucket = bucket->next) ++count; - return count; -} - -static void update_dist(int count) -{ - if (count >= DIST_LIMIT) ++dist[DIST_LIMIT-1]; - else ++dist[count]; -} - -static void compute_dist(HashTablePtr table) -{ - int i; - HashBucketPtr bucket; - - printf("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n", - table->entries, table->hits, table->partials, table->misses); - clear_dist(); - for (i = 0; i < HASH_SIZE; i++) { - bucket = table->buckets[i]; - update_dist(count_entries(bucket)); - } - for (i = 0; i < DIST_LIMIT; i++) { - if (i != DIST_LIMIT-1) printf("%5d %10d\n", i, dist[i]); - else printf("other %10d\n", dist[i]); - } -} - -static void check_table(HashTablePtr table, - unsigned long key, unsigned long value) -{ - unsigned long retval = 0; - int retcode = N(HashLookup)(table, key, &retval); - - switch (retcode) { - case -1: - printf("Bad magic = 0x%08lx:" - " key = %lu, expected = %lu, returned = %lu\n", - table->magic, key, value, retval); - break; - case 1: - printf("Not found: key = %lu, expected = %lu returned = %lu\n", - key, value, retval); - break; - case 0: - if (value != retval) - printf("Bad value: key = %lu, expected = %lu, returned = %lu\n", - key, value, retval); - break; - default: - printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n", - retcode, key, value, retval); - break; - } -} - -int main(void) -{ - HashTablePtr table; - int i; - - printf("\n***** 256 consecutive integers ****\n"); - table = N(HashCreate)(); - for (i = 0; i < 256; i++) N(HashInsert)(table, i, i); - for (i = 0; i < 256; i++) check_table(table, i, i); - for (i = 256; i >= 0; i--) check_table(table, i, i); - compute_dist(table); - N(HashDestroy)(table); - - printf("\n***** 1024 consecutive integers ****\n"); - table = N(HashCreate)(); - for (i = 0; i < 1024; i++) N(HashInsert)(table, i, i); - for (i = 0; i < 1024; i++) check_table(table, i, i); - for (i = 1024; i >= 0; i--) check_table(table, i, i); - compute_dist(table); - N(HashDestroy)(table); - - printf("\n***** 1024 consecutive page addresses (4k pages) ****\n"); - table = N(HashCreate)(); - for (i = 0; i < 1024; i++) N(HashInsert)(table, i*4096, i); - for (i = 0; i < 1024; i++) check_table(table, i*4096, i); - for (i = 1024; i >= 0; i--) check_table(table, i*4096, i); - compute_dist(table); - N(HashDestroy)(table); - - printf("\n***** 1024 random integers ****\n"); - table = N(HashCreate)(); - srandom(0xbeefbeef); - for (i = 0; i < 1024; i++) N(HashInsert)(table, random(), i); - srandom(0xbeefbeef); - for (i = 0; i < 1024; i++) check_table(table, random(), i); - srandom(0xbeefbeef); - for (i = 0; i < 1024; i++) check_table(table, random(), i); - compute_dist(table); - N(HashDestroy)(table); - - printf("\n***** 5000 random integers ****\n"); - table = N(HashCreate)(); - srandom(0xbeefbeef); - for (i = 0; i < 5000; i++) N(HashInsert)(table, random(), i); - srandom(0xbeefbeef); - for (i = 0; i < 5000; i++) check_table(table, random(), i); - srandom(0xbeefbeef); - for (i = 0; i < 5000; i++) check_table(table, random(), i); - compute_dist(table); - N(HashDestroy)(table); - - return 0; -} -#endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c deleted file mode 100644 index 067c6376e..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c +++ /dev/null @@ -1,86 +0,0 @@ -#ifdef XFree86Server -# include "xf86.h" -# include "xf86_OSproc.h" -# include "xf86_ansic.h" -# include "xf86Priv.h" -# define _DRM_MALLOC xalloc -# define _DRM_FREE xfree -# ifndef XFree86LOADER -# include <sys/stat.h> -# include <sys/mman.h> -# endif -#else -# include <stdio.h> -# include <stdlib.h> -# include <unistd.h> -# include <string.h> -# include <ctype.h> -# include <fcntl.h> -# include <errno.h> -# include <signal.h> -# include <sys/types.h> -# include <sys/stat.h> -# include <sys/ioctl.h> -# include <sys/mman.h> -# include <sys/time.h> -# ifdef DRM_USE_MALLOC -# define _DRM_MALLOC malloc -# define _DRM_FREE free -extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *); -extern int xf86RemoveSIGIOHandler(int fd); -# else -# include <Xlibint.h> -# define _DRM_MALLOC Xmalloc -# define _DRM_FREE Xfree -# endif -#endif - -/* Not all systems have MAP_FAILED defined */ -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -#include "xf86drm.h" -#include "xf86drmI810.h" -#include "drm.h" - -Bool drmI810CleanupDma(int driSubFD) -{ - drm_i810_init_t init; - - memset(&init, 0, sizeof(drm_i810_init_t)); - init.func = I810_CLEANUP_DMA; - - if(ioctl(driSubFD, DRM_IOCTL_I810_INIT, &init)) { - return FALSE; - } - - return TRUE; -} - -Bool drmI810InitDma(int driSubFD, drmI810Init *info) -{ - drm_i810_init_t init; - - memset(&init, 0, sizeof(drm_i810_init_t)); - - init.func = I810_INIT_DMA; - init.ring_map_idx = info->ring_map_idx; - init.buffer_map_idx = info->buffer_map_idx; - init.ring_start = info->start; - init.ring_end = info->end; - init.ring_size = info->size; - init.sarea_priv_offset = info->sarea_off; - init.front_offset = info->front_offset; - init.back_offset = info->back_offset; - init.depth_offset = info->depth_offset; - init.w = info->w; - init.h = info->h; - init.pitch = info->pitch; - init.pitch_bits = info->pitch_bits; - - if(ioctl(driSubFD, DRM_IOCTL_I810_INIT, &init)) { - return FALSE; - } - return TRUE; -} diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c deleted file mode 100644 index aa3a6c745..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c +++ /dev/null @@ -1,116 +0,0 @@ -#ifdef XFree86Server -# include "xf86.h" -# include "xf86_OSproc.h" -# include "xf86_ansic.h" -# include "xf86Priv.h" -# define _DRM_MALLOC xalloc -# define _DRM_FREE xfree -# ifndef XFree86LOADER -# include <sys/stat.h> -# include <sys/mman.h> -# endif -#else -# include <stdio.h> -# include <stdlib.h> -# include <unistd.h> -# include <string.h> -# include <ctype.h> -# include <fcntl.h> -# include <errno.h> -# include <signal.h> -# include <sys/types.h> -# include <sys/stat.h> -# include <sys/ioctl.h> -# include <sys/mman.h> -# include <sys/time.h> -# ifdef DRM_USE_MALLOC -# define _DRM_MALLOC malloc -# define _DRM_FREE free -extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *); -extern int xf86RemoveSIGIOHandler(int fd); -# else -# include <Xlibint.h> -# define _DRM_MALLOC Xmalloc -# define _DRM_FREE Xfree -# endif -#endif - -/* Not all systems have MAP_FAILED defined */ -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -#include "xf86drm.h" -#include "xf86drmMga.h" -#include "drm.h" - -Bool drmMgaCleanupDma(int driSubFD) -{ - drm_mga_init_t init; - memset(&init, 0, sizeof(drm_mga_init_t)); - init.func = MGA_CLEANUP_DMA; - if(ioctl(driSubFD, DRM_IOCTL_MGA_INIT, &init)) { - return FALSE; - } - - return TRUE; -} - -Bool drmMgaLockUpdate(int driSubFD, drmLockFlags flags) -{ - drm_lock_t lock; - - memset(&lock, 0, sizeof(drm_lock_t)); - - if (flags & DRM_LOCK_QUIESCENT) lock.flags |= _DRM_LOCK_QUIESCENT; - if (flags & DRM_LOCK_FLUSH) lock.flags |= _DRM_LOCK_FLUSH; - if (flags & DRM_LOCK_FLUSH_ALL) lock.flags |= _DRM_LOCK_FLUSH_ALL; - - if(ioctl(driSubFD, DRM_IOCTL_MGA_FLUSH, &lock)) { - return FALSE; - } - - return TRUE; -} - -Bool drmMgaInitDma(int driSubFD, drmMgaInit *info) -{ - drm_mga_init_t init; - int i; - - memset(&init, 0, sizeof(drm_mga_init_t)); - init.func = MGA_INIT_DMA; - init.reserved_map_agpstart = info->reserved_map_agpstart; - init.reserved_map_idx = info->reserved_map_idx; - init.buffer_map_idx = info->buffer_map_idx; - init.sarea_priv_offset = info->sarea_priv_offset; - init.primary_size = info->primary_size; - init.warp_ucode_size = info->warp_ucode_size; - init.frontOffset = info->frontOffset; - init.backOffset = info->backOffset; - init.depthOffset = info->depthOffset; - init.textureOffset = info->textureOffset; - init.textureSize = info->textureSize; - init.agpTextureSize = info->agpTextureSize; - init.agpTextureOffset = info->agpTextureOffset; - init.cpp = info->cpp; - init.stride = info->stride; - init.sgram = info->sgram; - init.chipset = info->chipset; - - for(i = 0; i < MGA_MAX_WARP_PIPES; i++) { - init.WarpIndex[i].installed = info->WarpIndex[i].installed; - init.WarpIndex[i].phys_addr = info->WarpIndex[i].phys_addr; - init.WarpIndex[i].size = info->WarpIndex[i].size; - } - - init.mAccess = info->mAccess; - - - - if(ioctl(driSubFD, DRM_IOCTL_MGA_INIT, &init)) { - return FALSE; - } - return TRUE; -} - diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c deleted file mode 100644 index 07904c754..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c +++ /dev/null @@ -1,198 +0,0 @@ -/* xf86drmR128.c -- User-level interface to Rage 128 DRM device - * Created: Sun Apr 9 18:13:54 2000 by kevin@precisioninsight.com - * - * Copyright 1999, 2000 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 (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: Kevin E. Martin <kevin@precisioninsight.com> - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c,v 1.1 2000/06/17 00:03:27 martin Exp $ - * - */ - -#ifdef XFree86Server -# include "xf86.h" -# include "xf86_OSproc.h" -# include "xf86_ansic.h" -# include "xf86Priv.h" -# define _DRM_MALLOC xalloc -# define _DRM_FREE xfree -# ifndef XFree86LOADER -# include <sys/stat.h> -# include <sys/mman.h> -# endif -#else -# include <stdio.h> -# include <stdlib.h> -# include <unistd.h> -# include <string.h> -# include <ctype.h> -# include <fcntl.h> -# include <errno.h> -# include <signal.h> -# include <sys/types.h> -# include <sys/stat.h> -# include <sys/ioctl.h> -# include <sys/mman.h> -# include <sys/time.h> -# ifdef DRM_USE_MALLOC -# define _DRM_MALLOC malloc -# define _DRM_FREE free -extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *); -extern int xf86RemoveSIGIOHandler(int fd); -# else -# include <Xlibint.h> -# define _DRM_MALLOC Xmalloc -# define _DRM_FREE Xfree -# endif -#endif - -/* Not all systems have MAP_FAILED defined */ -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -#include "xf86drm.h" -#include "xf86drmR128.h" -#include "drm.h" - -int drmR128InitCCE(int fd, drmR128Init *info) -{ - drm_r128_init_t init; - - memset(&init, 0, sizeof(drm_r128_init_t)); - - init.func = R128_INIT_CCE; - init.sarea_priv_offset = info->sarea_priv_offset; - init.is_pci = info->is_pci; - init.cce_mode = info->cce_mode; - init.cce_fifo_size = info->cce_fifo_size; - init.cce_secure = info->cce_secure; - init.ring_size = info->ring_size; - init.usec_timeout = info->usec_timeout; - - init.fb_offset = info->fb_offset; - init.agp_ring_offset = info->agp_ring_offset; - init.agp_read_ptr_offset = info->agp_read_ptr_offset; - init.agp_vertbufs_offset = info->agp_vertbufs_offset; - init.agp_indbufs_offset = info->agp_indbufs_offset; - init.agp_textures_offset = info->agp_textures_offset; - init.mmio_offset = info->mmio_offset; - - if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno; - - return 0; -} - -int drmR128CleanupCCE(int fd) -{ - drm_r128_init_t init; - - memset(&init, 0, sizeof(drm_r128_init_t)); - - init.func = R128_CLEANUP_CCE; - - if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno; - - return 0; -} - -int drmR128EngineReset(int fd) -{ - if (ioctl(fd, DRM_IOCTL_R128_RESET, NULL)) return -errno; - - return 0; -} - -int drmR128EngineFlush(int fd) -{ - if (ioctl(fd, DRM_IOCTL_R128_FLUSH, NULL)) return -errno; - - return 0; -} - -int drmR128CCEWaitForIdle(int fd) -{ - if (ioctl(fd, DRM_IOCTL_R128_CCEIDL, NULL)) return -errno; - - return 0; -} - -int drmR128SubmitPackets(int fd, CARD32 *buffer, int *count, int flags) -{ - drm_r128_packet_t packet; - int ret; - - memset(&packet, 0, sizeof(drm_r128_packet_t)); - - packet.count = *count; - packet.flags = flags; - - while (packet.count > 0) { - packet.buffer = buffer + (*count - packet.count); - ret = ioctl(fd, DRM_IOCTL_R128_PACKET, &packet); - if (ret < 0 && ret != -EAGAIN) { - *count = packet.count; - return -errno; - } - } - - *count = 0; - return 0; -} - -int drmR128GetVertexBuffers(int fd, int count, int *indices, int *sizes) -{ - drm_r128_vertex_t v; - - v.send_count = 0; - v.send_indices = NULL; - v.send_sizes = NULL; - v.prim = DRM_R128_PRIM_NONE; - v.request_count = count; - v.request_indices = indices; - v.request_sizes = sizes; - v.granted_count = 0; - - if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v)) return -errno; - - return v.granted_count; -} - -int drmR128FlushVertexBuffers(int fd, int count, int *indices, - int *sizes, drmR128PrimType prim) -{ - drm_r128_vertex_t v; - - v.send_count = count; - v.send_indices = indices; - v.send_sizes = sizes; - v.prim = prim; - v.request_count = 0; - v.request_indices = NULL; - v.request_sizes = NULL; - v.granted_count = 0; - - if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v) < 0) return -errno; - - return 0; -} diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c deleted file mode 100644 index d0f49906b..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c +++ /dev/null @@ -1,219 +0,0 @@ -/* xf86drmRandom.c -- "Minimal Standard" PRNG Implementation - * Created: Mon Apr 19 08:28:13 1999 by faith@precisioninsight.com - * Revised: Thu Jun 24 14:53:45 1999 by faith@precisioninsight.com - * - * Copyright 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 (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. - * - * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmRandom.c,v 1.4 1999/06/24 18:54:55 faith Exp $ - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c,v 1.1 2000/06/17 00:03:28 martin Exp $ - * - * DESCRIPTION - * - * This file contains a simple, straightforward implementation of the Park - * & Miller "Minimal Standard" PRNG [PM88, PMS93], which is a Lehmer - * multiplicative linear congruential generator (MLCG) with a period of - * 2^31-1. - * - * This implementation is intended to provide a reliable, portable PRNG - * that is suitable for testing a hash table implementation and for - * implementing skip lists. - * - * FUTURE ENHANCEMENTS - * - * If initial seeds are not selected randomly, two instances of the PRNG - * can be correlated. [Knuth81, pp. 32-33] describes a shuffling technique - * that can eliminate this problem. - * - * If PRNGs are used for simulation, the period of the current - * implementation may be too short. [LE88] discusses methods of combining - * MLCGs to produce much longer periods, and suggests some alternative - * values for A and M. [LE90 and Sch92] also provide information on - * long-period PRNGs. - * - * REFERENCES - * - * [Knuth81] Donald E. Knuth. The Art of Computer Programming. Volume 2: - * Seminumerical Algorithms. Reading, Massachusetts: Addison-Wesley, 1981. - * - * [LE88] Pierre L'Ecuyer. "Efficient and Portable Combined Random Number - * Generators". CACM 31(6), June 1988, pp. 742-774. - * - * [LE90] Pierre L'Ecuyer. "Random Numbers for Simulation". CACM 33(10, - * October 1990, pp. 85-97. - * - * [PM88] Stephen K. Park and Keith W. Miller. "Random Number Generators: - * Good Ones are Hard to Find". CACM 31(10), October 1988, pp. 1192-1201. - * - * [Sch92] Bruce Schneier. "Pseudo-Ransom Sequence Generator for 32-Bit - * CPUs". Dr. Dobb's Journal 17(2), February 1992, pp. 34, 37-38, 40. - * - * [PMS93] Stephen K. Park, Keith W. Miller, and Paul K. Stockmeyer. In - * "Technical Correspondence: Remarks on Choosing and Implementing Random - * Number Generators". CACM 36(7), July 1993, pp. 105-110. - * - */ - -#define RANDOM_MAIN 0 - -#if RANDOM_MAIN -# include <stdio.h> -# include <stdlib.h> -#else -# include "xf86drm.h" -# ifdef XFree86LOADER -# include "xf86.h" -# include "xf86_ansic.h" -# else -# include <stdio.h> -# include <stdlib.h> -# endif -#endif - -#define N(x) drm##x - -#define RANDOM_MAGIC 0xfeedbeef -#define RANDOM_DEBUG 0 - -#if RANDOM_MAIN -#define RANDOM_ALLOC malloc -#define RANDOM_FREE free -#else -#define RANDOM_ALLOC drmMalloc -#define RANDOM_FREE drmFree -#endif - -typedef struct RandomState { - unsigned long magic; - unsigned long a; - unsigned long m; - unsigned long q; /* m div a */ - unsigned long r; /* m mod a */ - unsigned long check; - long seed; -} RandomState; - -#if RANDOM_MAIN -extern void *N(RandomCreate)(unsigned long seed); -extern int N(RandomDestroy)(void *state); -extern unsigned long N(Random)(void *state); -extern double N(RandomDouble)(void *state); -#endif - -void *N(RandomCreate)(unsigned long seed) -{ - RandomState *state; - - state = RANDOM_ALLOC(sizeof(*state)); - if (!state) return NULL; - state->magic = RANDOM_MAGIC; -#if 0 - /* Park & Miller, October 1988 */ - state->a = 16807; - state->m = 2147483647; - state->check = 1043618065; /* After 10000 iterations */ -#else - /* Park, Miller, and Stockmeyer, July 1993 */ - state->a = 48271; - state->m = 2147483647; - state->check = 399268537; /* After 10000 iterations */ -#endif - state->q = state->m / state->a; - state->r = state->m % state->a; - - state->seed = seed; - /* Check for illegal boundary conditions, - and choose closest legal value. */ - if (state->seed <= 0) state->seed = 1; - if (state->seed >= state->m) state->seed = state->m - 1; - - return state; -} - -int N(RandomDestroy)(void *state) -{ - RANDOM_FREE(state); - return 0; -} - -unsigned long N(Random)(void *state) -{ - RandomState *s = (RandomState *)state; - long hi; - long lo; - - hi = s->seed / s->q; - lo = s->seed % s->q; - s->seed = s->a * lo - s->r * hi; - if (s->seed <= 0) s->seed += s->m; - - return s->seed; -} - -double N(RandomDouble)(void *state) -{ - RandomState *s = (RandomState *)state; - - return (double)N(Random)(state)/(double)s->m; -} - -#if RANDOM_MAIN -static void check_period(long seed) -{ - unsigned long count = 0; - unsigned long initial; - void *state; - - state = N(RandomCreate)(seed); - initial = N(Random)(state); - ++count; - while (initial != N(Random)(state)) { - if (!++count) break; - } - printf("With seed of %10ld, period = %10lu (0x%08lx)\n", - seed, count, count); - N(RandomDestroy)(state); -} - -int main(void) -{ - RandomState *state; - int i; - unsigned long rand; - - state = N(RandomCreate)(1); - for (i = 0; i < 10000; i++) { - rand = N(Random)(state); - } - printf("After 10000 iterations: %lu (%lu expected): %s\n", - rand, state->check, - rand - state->check ? "*INCORRECT*" : "CORRECT"); - N(RandomDestroy)(state); - - printf("Checking periods...\n"); - check_period(1); - check_period(2); - check_period(31415926); - - return 0; -} -#endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c deleted file mode 100644 index 51a54f934..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c +++ /dev/null @@ -1,490 +0,0 @@ -/* xf86drmSL.c -- Skip list support - * Created: Mon May 10 09:28:13 1999 by faith@precisioninsight.com - * Revised: Thu Jun 3 16:13:01 1999 by faith@precisioninsight.com - * - * Copyright 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 (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. - * - * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSL.c,v 1.2 1999/06/07 13:01:42 faith Exp $ - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c,v 1.1 2000/06/17 00:03:28 martin Exp $ - * - * DESCRIPTION - * - * This file contains a straightforward skip list implementation.n - * - * FUTURE ENHANCEMENTS - * - * REFERENCES - * - * [Pugh90] William Pugh. Skip Lists: A Probabilistic Alternative to - * Balanced Trees. CACM 33(6), June 1990, pp. 668-676. - * - */ - -#define SL_MAIN 0 - -#if SL_MAIN -# include <stdio.h> -# include <stdlib.h> -# include <sys/time.h> -#else -# include "xf86drm.h" -# ifdef XFree86LOADER -# include "xf86.h" -# include "xf86_ansic.h" -# else -# include <stdio.h> -# include <stdlib.h> -# endif -#endif - -#define N(x) drm##x - -#define SL_LIST_MAGIC 0xfacade00LU -#define SL_ENTRY_MAGIC 0x00fab1edLU -#define SL_FREED_MAGIC 0xdecea5edLU -#define SL_MAX_LEVEL 16 -#define SL_DEBUG 0 -#define SL_RANDOM_SEED 0xc01055a1LU - -#if SL_MAIN -#define SL_ALLOC malloc -#define SL_FREE free -#define SL_RANDOM_DECL static int state = 0; -#define SL_RANDOM_INIT(seed) if (!state) { srandom(seed); ++state; } -#define SL_RANDOM random() -#else -#define SL_ALLOC drmMalloc -#define SL_FREE drmFree -#define SL_RANDOM_DECL static void *state = NULL -#define SL_RANDOM_INIT(seed) if (!state) state = drmRandomCreate(seed) -#define SL_RANDOM drmRandom(state) - -#endif - -typedef struct SLEntry { - unsigned long magic; /* SL_ENTRY_MAGIC */ - unsigned long key; - void *value; - int levels; - struct SLEntry *forward[1]; /* variable sized array */ -} SLEntry, *SLEntryPtr; - -typedef struct SkipList { - unsigned long magic; /* SL_LIST_MAGIC */ - int level; - int count; - SLEntryPtr head; - SLEntryPtr p0; /* Position for iteration */ -} SkipList, *SkipListPtr; - -#if SL_MAIN -extern void *N(SLCreate)(void); -extern int N(SLDestroy)(void *l); -extern int N(SLLookup)(void *l, unsigned long key, void **value); -extern int N(SLInsert)(void *l, unsigned long key, void *value); -extern int N(SLDelete)(void *l, unsigned long key); -extern int N(SLNext)(void *l, unsigned long *key, void **value); -extern int N(SLFirst)(void *l, unsigned long *key, void **value); -extern void N(SLDump)(void *l); -extern int N(SLLookupNeighbors)(void *l, unsigned long key, - unsigned long *prev_key, void **prev_value, - unsigned long *next_key, void **next_value); -#endif - -static SLEntryPtr SLCreateEntry(int max_level, unsigned long key, void *value) -{ - SLEntryPtr entry; - - if (max_level < 0 || max_level > SL_MAX_LEVEL) max_level = SL_MAX_LEVEL; - - entry = SL_ALLOC(sizeof(*entry) - + (max_level + 1) * sizeof(entry->forward[0])); - if (!entry) return NULL; - entry->magic = SL_ENTRY_MAGIC; - entry->key = key; - entry->value = value; - entry->levels = max_level + 1; - - return entry; -} - -static int SLRandomLevel(void) -{ - int level = 1; - SL_RANDOM_DECL; - - SL_RANDOM_INIT(SL_RANDOM_SEED); - - while ((SL_RANDOM & 0x01) && level < SL_MAX_LEVEL) ++level; - return level; -} - -void *N(SLCreate)(void) -{ - SkipListPtr list; - int i; - - list = SL_ALLOC(sizeof(*list)); - if (!list) return NULL; - list->magic = SL_LIST_MAGIC; - list->level = 0; - list->head = SLCreateEntry(SL_MAX_LEVEL, 0, NULL); - list->count = 0; - - for (i = 0; i <= SL_MAX_LEVEL; i++) list->head->forward[i] = NULL; - - return list; -} - -int N(SLDestroy)(void *l) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr entry; - SLEntryPtr next; - - if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */ - - for (entry = list->head; entry; entry = next) { - if (entry->magic != SL_ENTRY_MAGIC) return -1; /* Bad magic */ - next = entry->forward[0]; - entry->magic = SL_FREED_MAGIC; - SL_FREE(entry); - } - - list->magic = SL_FREED_MAGIC; - SL_FREE(list); - return 0; -} - -static SLEntryPtr SLLocate(void *l, unsigned long key, SLEntryPtr *update) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr entry; - int i; - - if (list->magic != SL_LIST_MAGIC) return NULL; - - for (i = list->level, entry = list->head; i >= 0; i--) { - while (entry->forward[i] && entry->forward[i]->key < key) - entry = entry->forward[i]; - update[i] = entry; - } - - return entry->forward[0]; -} - -int N(SLInsert)(void *l, unsigned long key, void *value) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr entry; - SLEntryPtr update[SL_MAX_LEVEL + 1]; - int level; - int i; - - if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */ - - entry = SLLocate(list, key, update); - - if (entry && entry->key == key) return 1; /* Already in list */ - - - level = SLRandomLevel(); - if (level > list->level) { - level = ++list->level; - update[level] = list->head; - } - - entry = SLCreateEntry(level, key, value); - - /* Fix up forward pointers */ - for (i = 0; i <= level; i++) { - entry->forward[i] = update[i]->forward[i]; - update[i]->forward[i] = entry; - } - - ++list->count; - return 0; /* Added to table */ -} - -int N(SLDelete)(void *l, unsigned long key) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr update[SL_MAX_LEVEL + 1]; - SLEntryPtr entry; - int i; - - if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */ - - entry = SLLocate(list, key, update); - - if (!entry || entry->key != key) return 1; /* Not found */ - - /* Fix up forward pointers */ - for (i = 0; i <= list->level; i++) { - if (update[i]->forward[i] == entry) - update[i]->forward[i] = entry->forward[i]; - } - - entry->magic = SL_FREED_MAGIC; - SL_FREE(entry); - - while (list->level && !list->head->forward[list->level]) --list->level; - --list->count; - return 0; -} - -int N(SLLookup)(void *l, unsigned long key, void **value) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr update[SL_MAX_LEVEL + 1]; - SLEntryPtr entry; - - entry = SLLocate(list, key, update); - - if (entry && entry->key == key) { - *value = entry; - return 0; - } - *value = NULL; - return -1; -} - -int N(SLLookupNeighbors)(void *l, unsigned long key, - unsigned long *prev_key, void **prev_value, - unsigned long *next_key, void **next_value) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr update[SL_MAX_LEVEL + 1]; - SLEntryPtr entry; - int retcode = 0; - - entry = SLLocate(list, key, update); - - *prev_key = *next_key = key; - *prev_value = *next_value = NULL; - - if (update[0]) { - *prev_key = update[0]->key; - *prev_value = update[0]->value; - ++retcode; - if (update[0]->forward[0]) { - *next_key = update[0]->forward[0]->key; - *next_value = update[0]->forward[0]->value; - ++retcode; - } - } - return retcode; -} - -int N(SLNext)(void *l, unsigned long *key, void **value) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr entry; - - if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */ - - entry = list->p0; - - if (entry) { - list->p0 = entry->forward[0]; - *key = entry->key; - *value = entry->value; - return 1; - } - list->p0 = NULL; - return 0; -} - -int N(SLFirst)(void *l, unsigned long *key, void **value) -{ - SkipListPtr list = (SkipListPtr)l; - - if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */ - - list->p0 = list->head->forward[0]; - return N(SLNext)(list, key, value); -} - -/* Dump internal data structures for debugging. */ -void N(SLDump)(void *l) -{ - SkipListPtr list = (SkipListPtr)l; - SLEntryPtr entry; - int i; - - if (list->magic != SL_LIST_MAGIC) { - printf("Bad magic: 0x%08lx (expected 0x%08lx)\n", - list->magic, SL_LIST_MAGIC); - return; - } - - printf("Level = %d, count = %d\n", list->level, list->count); - for (entry = list->head; entry; entry = entry->forward[0]) { - if (entry->magic != SL_ENTRY_MAGIC) { - printf("Bad magic: 0x%08lx (expected 0x%08lx)\n", - list->magic, SL_ENTRY_MAGIC); - } - printf("\nEntry %p <0x%08lx, %p> has %2d levels\n", - entry, entry->key, entry->value, entry->levels); - for (i = 0; i < entry->levels; i++) { - if (entry->forward[i]) { - printf(" %2d: %p <0x%08lx, %p>\n", - i, - entry->forward[i], - entry->forward[i]->key, - entry->forward[i]->value); - } else { - printf(" %2d: %p\n", i, entry->forward[i]); - } - } - } -} - -#if SL_MAIN -static void print(SkipListPtr list) -{ - unsigned long key; - void *value; - - if (N(SLFirst)(list, &key, &value)) { - do { - printf("key = %5lu, value = %p\n", key, value); - } while (N(SLNext)(list, &key, &value)); - } -} - -static double do_time(int size, int iter) -{ - SkipListPtr list; - int i, j; - unsigned long keys[1000000]; - unsigned long previous; - unsigned long key; - void *value; - struct timeval start, stop; - double usec; - SL_RANDOM_DECL; - - SL_RANDOM_INIT(12345); - - list = N(SLCreate)(); - - for (i = 0; i < size; i++) { - keys[i] = SL_RANDOM; - N(SLInsert)(list, keys[i], NULL); - } - - previous = 0; - if (N(SLFirst)(list, &key, &value)) { - do { - if (key <= previous) { - printf( "%lu !< %lu\n", previous, key); - } - previous = key; - } while (N(SLNext)(list, &key, &value)); - } - - gettimeofday(&start, NULL); - for (j = 0; j < iter; j++) { - for (i = 0; i < size; i++) { - if (N(SLLookup)(list, keys[i], &value)) - printf("Error %lu %d\n", keys[i], i); - } - } - gettimeofday(&stop, NULL); - - usec = (double)(stop.tv_sec * 1000000 + stop.tv_usec - - start.tv_sec * 1000000 - start.tv_usec) / (size * iter); - - printf("%0.2f microseconds for list length %d\n", usec, size); - - N(SLDestroy)(list); - - return usec; -} - -static void print_neighbors(void *list, unsigned long key) -{ - unsigned long prev_key = 0; - unsigned long next_key = 0; - void *prev_value; - void *next_value; - int retval; - - retval = drmSLLookupNeighbors(list, key, - &prev_key, &prev_value, - &next_key, &next_value); - printf("Neighbors of %5lu: %d %5lu %5lu\n", - key, retval, prev_key, next_key); -} - -int main(void) -{ - SkipListPtr list; - double usec, usec2, usec3, usec4; - - list = N(SLCreate)(); - printf( "list at %p\n", list); - - print(list); - printf("\n==============================\n\n"); - - N(SLInsert)(list, 123, NULL); - N(SLInsert)(list, 213, NULL); - N(SLInsert)(list, 50, NULL); - print(list); - printf("\n==============================\n\n"); - - print_neighbors(list, 0); - print_neighbors(list, 50); - print_neighbors(list, 51); - print_neighbors(list, 123); - print_neighbors(list, 200); - print_neighbors(list, 213); - print_neighbors(list, 256); - printf("\n==============================\n\n"); - - N(SLDelete)(list, 50); - print(list); - printf("\n==============================\n\n"); - - N(SLDump)(list); - N(SLDestroy)(list); - printf("\n==============================\n\n"); - - usec = do_time(100, 10000); - usec2 = do_time(1000, 500); - printf("Table size increased by %0.2f, search time increased by %0.2f\n", - 1000.0/100.0, usec2 / usec); - - usec3 = do_time(10000, 50); - printf("Table size increased by %0.2f, search time increased by %0.2f\n", - 10000.0/100.0, usec3 / usec); - - usec4 = do_time(100000, 4); - printf("Table size increased by %0.2f, search time increased by %0.2f\n", - 100000.0/100.0, usec4 / usec); - - return 0; -} -#endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile index 7a5fea61c..6457b2732 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile @@ -2,14 +2,6 @@ XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imake #include <Server.tmpl> -LinkSourceFile(xf86drm.c,..) -LinkSourceFile(xf86drmHash.c,..) -LinkSourceFile(xf86drmRandom.c,..) -LinkSourceFile(xf86drmSL.c,..) -LinkSourceFile(xf86drm.h,$(XF86OSSRC)) -LinkSourceFile(xf86_OSproc.h,$(XF86OSSRC)) -LinkSourceFile(sigio.c,$(XF86OSSRC)/shared) - XCOMM This is a kludge until we determine how best to build the XCOMM kernel-specific device driver. This allows us to continue XCOMM to maintain the single Makefile.linux with kernel-specific diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux index a9f744691..506e437b0 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux @@ -24,7 +24,6 @@ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. # -# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux,v 1.9 2000/08/04 03:51:47 tsi Exp $ # # ***** NOTE NOTE NOTE NOTE NOTE ***** # To override the automatic Linux source tree determination, pass the @@ -50,7 +49,6 @@ MODS= gamma.o tdfx.o r128.o radeon.o LIBS= libdrm.a -PROGS= drmstat DRMOBJS= init.o memory.o proc.o auth.o context.o drawable.o bufs.o \ lists.o lock.o ioctl.o fops.o vm.o dma.o ctxbitmap.o @@ -68,9 +66,6 @@ R128HEADERS= r128_drv.h r128_drm.h $(DRMHEADERS) RADEONOBJS= radeon_drv.o radeon_dma.o radeon_bufs.o radeon_context.o RADEONHEADERS= radeon_drv.h radeon_drm.h $(DRMHEADERS) -PROGOBJS= drmstat.po xf86drm.po xf86drmHash.po xf86drmRandom.po sigio.po -PROGHEADERS= xf86drm.h $(DRMHEADERS) - INC= /usr/include CFLAGS= -O2 $(WARNINGS) @@ -121,7 +116,9 @@ all:; @echo Error: Could not locate kernel tree in $A $B $C else SMP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ | grep -s 'SMP = ' | cut -d' ' -f3) -MODVERSIONS := $(shell gcc -E -I $(TREE) picker.c 2>/dev/null \ +MODULES := $(shell gcc -E -nostdinc -I $(TREE) picker.c 2>/dev/null \ + | grep -s 'MODULES = ' | cut -d' ' -f3) +MODVERSIONS := $(shell gcc -E -nostdinc -I $(TREE) picker.c 2>/dev/null \ | grep -s 'MODVERSIONS = ' | cut -d' ' -f3) AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ | grep -s 'AGP = ' | cut -d' ' -f3) @@ -165,12 +162,20 @@ SISHEADERS= sis_drv.h sis_ds.h sis_drm.h $(DRMHEADERS) endif all::;@echo === KERNEL HEADERS IN $(TREE) -all::;@echo === SMP=${SMP} MODVERSIONS=${MODVERSIONS} AGP=${AGP} SIS=${SIS} +all::;@echo === SMP=${SMP} MODULES=${MODULES} MODVERSIONS=${MODVERSIONS} AGP=${AGP} all::;@echo === kill_fasync has $(PARAMS) parameters all::;@echo === Compiling for machine $(MACHINE) + +ifeq ($(MODULES),0) +all::;@echo +all::;@echo "*** Kernel modules must be configured. Build aborted." +all::;@echo +else all:: $(LIBS) $(MODS) $(PROGS) endif +endif + # **** End of SMP/MODVERSIONS detection # **** Handle SMP/MODVERSIONS @@ -225,9 +230,6 @@ i810.o: $(I810OBJS) $(LIBS) $(LD) -r $^ -o $@ endif -drmstat: $(PROGOBJS) - $(CC) $(PRGCFLAGS) $^ $(PRGLIBS) -o $@ - .PHONY: ChangeLog ChangeLog: @rm -f Changelog @@ -241,9 +243,6 @@ ChangeLog: %.o: %.c $(CC) $(MODCFLAGS) -I$(TREE) -c $< -o $@ -%.po: %.c - $(CC) $(PRGCFLAGS) -DDRM_USE_MALLOC -c $< -o $@ - $(DRMOBJS): $(DRMHEADERS) $(GAMMAOBJS): $(GAMMAHEADERS) $(TDFXOBJS): $(TDFXHEADERS) @@ -253,7 +252,6 @@ ifeq ($(AGP),1) $(MGAOBJS): $(MGAHEADERS) $(I810OBJS): $(I810HEADERS) endif -$(PROGOBJS): $(PROGHEADERS) clean: - rm -f *.o *.a *.po *~ core $(PROGS) + rm -f *.o *.a *~ core diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c index ac2d1bc5a..5cc3ec369 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c @@ -397,10 +397,10 @@ int drm_dma_enqueue(drm_device_t *dev, drm_dma_t *d) atomic_inc(&q->use_count); if (atomic_read(&q->block_write)) { - current->state = TASK_INTERRUPTIBLE; add_wait_queue(&q->write_queue, &entry); atomic_inc(&q->block_count); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!atomic_read(&q->block_write)) break; schedule(); if (signal_pending(current)) { @@ -486,14 +486,16 @@ static int drm_dma_get_buffers_of_order(drm_device_t *dev, drm_dma_t *d, buf->pending); } buf->pid = current->pid; - copy_to_user_ret(&d->request_indices[i], + if (copy_to_user(&d->request_indices[i], &buf->idx, - sizeof(buf->idx), - -EFAULT); - copy_to_user_ret(&d->request_sizes[i], + sizeof(buf->idx))) + return -EFAULT; + + if (copy_to_user(&d->request_sizes[i], &buf->total, - sizeof(buf->total), - -EFAULT); + sizeof(buf->total))) + return -EFAULT; + ++d->granted_count; } return 0; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h index d5ad7f5fb..6cc9500f1 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h @@ -35,7 +35,13 @@ #ifndef _DRM_H_ #define _DRM_H_ +#if defined(__linux__) #include <asm/ioctl.h> /* For _IO* macros */ +#define DRM_IOCTL_NR(n) _IOC_NR(n) +#elif defined(__FreeBSD__) +#include <sys/ioccom.h> +#define DRM_IOCTL_NR(n) ((n) & 0xff) +#endif #define DRM_PROC_DEVICES "/proc/devices" #define DRM_PROC_MISC "/proc/misc" @@ -290,7 +296,6 @@ typedef struct drm_agp_info { } drm_agp_info_t; #define DRM_IOCTL_BASE 'd' -#define DRM_IOCTL_NR(n) _IOC_NR(n) #define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr) #define DRM_IOR(nr,size) _IOR(DRM_IOCTL_BASE,nr,size) #define DRM_IOW(nr,size) _IOW(DRM_IOCTL_BASE,nr,size) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h index 3d5219db8..6be90c516 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h @@ -28,12 +28,17 @@ * Rickard E. (Rik) Faith <faith@valinux.com> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h,v 1.9 2000/08/28 02:43:14 tsi Exp $ */ #ifndef _DRM_P_H_ #define _DRM_P_H_ #ifdef __KERNEL__ +#ifdef __alpha__ +/* add include of current.h so that "current" is defined + * before static inline funcs in wait.h. Doing this so we + * can build the DRM (part of PI DRI). 4/21/2000 S + B */ +#include <asm/current.h> +#endif /* __alpha__ */ #include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> @@ -48,6 +53,9 @@ #include <linux/sched.h> #include <linux/smp_lock.h> /* For (un)lock_kernel */ #include <linux/mm.h> +#ifdef __alpha__ +#include <asm/pgtable.h> /* For pte_wrprotect */ +#endif #include <asm/io.h> #include <asm/mman.h> #include <asm/uaccess.h> @@ -58,10 +66,13 @@ #include <linux/types.h> #include <linux/agp_backend.h> #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0) +#if LINUX_VERSION_CODE >= 0x020100 /* KERNEL_VERSION(2,1,0) */ #include <linux/tqueue.h> #include <linux/poll.h> #endif +#if LINUX_VERSION_CODE < 0x020400 +#include "compat-pre24.h" +#endif #include "drm.h" #define DRM_DEBUG_CODE 2 /* Include debugging code (if > 1, then @@ -141,15 +152,75 @@ typedef struct wait_queue *wait_queue_head_t; #define module_exit(x) void cleanup_module(void) { x(); } #endif - /* virt_to_page added in 2.4.0-test6 */ -#if LINUX_VERSION_CODE < 0x020400 -#define virt_to_page(kaddr) (mem_map + MAP_NR(kaddr)) -#endif - /* Generic cmpxchg added in 2.3.x */ #ifndef __HAVE_ARCH_CMPXCHG /* Include this here so that driver can be used with older kernels. */ +#if defined(__alpha__) +static __inline__ unsigned long +__cmpxchg_u32(volatile int *m, int old, int new) +{ + unsigned long prev, cmp; + + __asm__ __volatile__( + "1: ldl_l %0,%2\n" + " cmpeq %0,%3,%1\n" + " beq %1,2f\n" + " mov %4,%1\n" + " stl_c %1,%2\n" + " beq %1,3f\n" + "2: mb\n" + ".subsection 2\n" + "3: br 1b\n" + ".previous" + : "=&r"(prev), "=&r"(cmp), "=m"(*m) + : "r"((long) old), "r"(new), "m"(*m)); + + return prev; +} + +static __inline__ unsigned long +__cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new) +{ + unsigned long prev, cmp; + + __asm__ __volatile__( + "1: ldq_l %0,%2\n" + " cmpeq %0,%3,%1\n" + " beq %1,2f\n" + " mov %4,%1\n" + " stq_c %1,%2\n" + " beq %1,3f\n" + "2: mb\n" + ".subsection 2\n" + "3: br 1b\n" + ".previous" + : "=&r"(prev), "=&r"(cmp), "=m"(*m) + : "r"((long) old), "r"(new), "m"(*m)); + + return prev; +} + +static __inline__ unsigned long +__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) +{ + switch (size) { + case 4: + return __cmpxchg_u32(ptr, old, new); + case 8: + return __cmpxchg_u64(ptr, old, new); + } + return old; +} +#define cmpxchg(ptr,o,n) \ + ({ \ + __typeof__(*(ptr)) _o_ = (o); \ + __typeof__(*(ptr)) _n_ = (n); \ + (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \ + (unsigned long)_n_, sizeof(*(ptr))); \ + }) + +#elif __i386__ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) { @@ -180,6 +251,7 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, #define cmpxchg(ptr,o,n) \ ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \ (unsigned long)(n),sizeof(*(ptr)))) +#endif /* i386 & alpha */ #endif /* Macros to make printk easier */ @@ -358,6 +430,7 @@ typedef struct drm_file { struct drm_file *next; struct drm_file *prev; struct drm_device *dev; + int remove_auth_on_close; } drm_file_t; @@ -452,6 +525,11 @@ typedef struct { extern drm_agp_func_t drm_agp; #endif +typedef struct drm_sigdata { + int context; + drm_hw_lock_t *lock; +} drm_sigdata_t; + typedef struct drm_device { const char *name; /* Simple driver name */ char *unique; /* Unique identifier: e.g., busid */ @@ -536,6 +614,8 @@ typedef struct drm_device { #endif unsigned long *ctx_bitmap; void *dev_private; + drm_sigdata_t sigdata; /* For block_all_signals */ + sigset_t sigmask; } drm_device_t; @@ -730,6 +810,7 @@ extern int drm_flush_unblock(drm_device_t *dev, int context, drm_lock_flags_t flags); extern int drm_flush_block_and_flush(drm_device_t *dev, int context, drm_lock_flags_t flags); +extern int drm_notifier(void *priv); /* Context Bitmap support (ctxbitmap.c) */ extern int drm_ctxbitmap_init(drm_device_t *dev); diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c index a99f24cae..4ab67281c 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c @@ -542,10 +542,9 @@ static int gamma_dma_send_buffers(drm_device_t *dev, drm_dma_t *d) if (d->flags & _DRM_DMA_BLOCK) { DRM_DEBUG("%d waiting\n", current->pid); - current->state = TASK_INTERRUPTIBLE; for (;;) { - if (!last_buf->waiting - && !last_buf->pending) + current->state = TASK_INTERRUPTIBLE; + if (!last_buf->waiting && !last_buf->pending) break; /* finished */ schedule(); if (signal_pending(current)) { @@ -586,7 +585,8 @@ int gamma_dma(struct inode *inode, struct file *filp, unsigned int cmd, int retcode = 0; drm_dma_t d; - copy_from_user_ret(&d, (drm_dma_t *)arg, sizeof(d), -EFAULT); + if (copy_from_user(&d, (drm_dma_t *)arg, sizeof(d))) + return -EFAULT; DRM_DEBUG("%d %d: %d send, %d req\n", current->pid, d.context, d.send_count, d.request_count); @@ -621,7 +621,8 @@ int gamma_dma(struct inode *inode, struct file *filp, unsigned int cmd, DRM_DEBUG("%d returning, granted = %d\n", current->pid, d.granted_count); - copy_to_user_ret((drm_dma_t *)arg, &d, sizeof(d), -EFAULT); + if (copy_to_user((drm_dma_t *)arg, &d, sizeof(d))) + return -EFAULT; return retcode; } @@ -710,7 +711,8 @@ int gamma_control(struct inode *inode, struct file *filp, unsigned int cmd, drm_control_t ctl; int retcode; - copy_from_user_ret(&ctl, (drm_control_t *)arg, sizeof(ctl), -EFAULT); + if (copy_from_user(&ctl, (drm_control_t *)arg, sizeof(ctl))) + return -EFAULT; switch (ctl.func) { case DRM_INST_HANDLER: @@ -742,7 +744,8 @@ int gamma_lock(struct inode *inode, struct file *filp, unsigned int cmd, dev->lck_start = start = get_cycles(); #endif - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", @@ -774,6 +777,7 @@ int gamma_lock(struct inode *inode, struct file *filp, unsigned int cmd, } add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ ret = -EINTR; @@ -790,7 +794,6 @@ int gamma_lock(struct inode *inode, struct file *filp, unsigned int cmd, /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; schedule(); if (signal_pending(current)) { ret = -ERESTARTSYS; @@ -804,6 +807,15 @@ int gamma_lock(struct inode *inode, struct file *filp, unsigned int cmd, drm_flush_unblock(dev, lock.context, lock.flags); /* cleanup phase */ if (!ret) { + sigemptyset(&dev->sigmask); + sigaddset(&dev->sigmask, SIGSTOP); + sigaddset(&dev->sigmask, SIGTSTP); + sigaddset(&dev->sigmask, SIGTTIN); + sigaddset(&dev->sigmask, SIGTTOU); + dev->sigdata.context = lock.context; + dev->sigdata.lock = dev->lock.hw_lock; + block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); + if (lock.flags & _DRM_LOCK_READY) gamma_dma_ready(dev); if (lock.flags & _DRM_LOCK_QUIESCENT) { diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c index 12945310e..26fe0c1c1 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c @@ -29,7 +29,6 @@ * Keith Whitwell <keithw@valinux.com> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c,v 1.6 2000/08/28 02:43:15 tsi Exp $ */ #define __NO_VERSION__ #include "drmP.h" @@ -253,16 +252,15 @@ static int i810_dma_get_buffer(drm_device_t *dev, drm_i810_dma_t *d, buf = i810_freelist_get(dev); if (!buf) { retcode = -ENOMEM; - DRM_DEBUG("%s retcode %d\n", __FUNCTION__, retcode); - goto out_get_buf; + DRM_DEBUG("retcode=%d\n", retcode); + return retcode; } retcode = i810_map_buffer(buf, filp); if(retcode) { i810_freelist_put(dev, buf); - DRM_DEBUG("mapbuf failed in %s retcode %d\n", - __FUNCTION__, retcode); - goto out_get_buf; + DRM_DEBUG("mapbuf failed, retcode %d\n", retcode); + return retcode; } buf->pid = priv->pid; buf_priv = buf->dev_private; @@ -271,7 +269,6 @@ static int i810_dma_get_buffer(drm_device_t *dev, drm_i810_dma_t *d, d->request_size = buf->total; d->virtual = buf_priv->virtual; -out_get_buf: return retcode; } @@ -491,8 +488,8 @@ int i810_dma_init(struct inode *inode, struct file *filp, drm_i810_init_t init; int retcode = 0; - copy_from_user_ret(&init, (drm_i810_init_t *)arg, - sizeof(init), -EFAULT); + if (copy_from_user(&init, (drm_i810_init_t *)arg, sizeof(init))) + return -EFAULT; switch(init.func) { case I810_INIT_DMA: @@ -1006,7 +1003,8 @@ int i810_control(struct inode *inode, struct file *filp, unsigned int cmd, DRM_DEBUG( "i810_control\n"); - copy_from_user_ret(&ctl, (drm_control_t *)arg, sizeof(ctl), -EFAULT); + if (copy_from_user(&ctl, (drm_control_t *)arg, sizeof(ctl))) + return -EFAULT; switch (ctl.func) { case DRM_INST_HANDLER: @@ -1069,11 +1067,11 @@ static void i810_dma_quiescent(drm_device_t *dev) return; } atomic_set(&dev_priv->flush_done, 0); - current->state = TASK_INTERRUPTIBLE; add_wait_queue(&dev_priv->flush_queue, &entry); end = jiffies + (HZ*3); for (;;) { + current->state = TASK_INTERRUPTIBLE; i810_dma_quiescent_emit(dev); if (atomic_read(&dev_priv->flush_done) == 1) break; if((signed)(end - jiffies) <= 0) { @@ -1104,10 +1102,10 @@ static int i810_flush_queue(drm_device_t *dev) return 0; } atomic_set(&dev_priv->flush_done, 0); - current->state = TASK_INTERRUPTIBLE; add_wait_queue(&dev_priv->flush_queue, &entry); end = jiffies + (HZ*3); for (;;) { + current->state = TASK_INTERRUPTIBLE; i810_dma_emit_flush(dev); if (atomic_read(&dev_priv->flush_done) == 1) break; if((signed)(end - jiffies) <= 0) { @@ -1179,7 +1177,8 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd, int ret = 0; drm_lock_t lock; - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", @@ -1200,6 +1199,7 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd, if (!ret) { add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ ret = -EINTR; @@ -1215,7 +1215,6 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd, /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; DRM_DEBUG("Calling lock schedule\n"); schedule(); if (signal_pending(current)) { @@ -1228,6 +1227,15 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd, } if (!ret) { + sigemptyset(&dev->sigmask); + sigaddset(&dev->sigmask, SIGSTOP); + sigaddset(&dev->sigmask, SIGTSTP); + sigaddset(&dev->sigmask, SIGTTIN); + sigaddset(&dev->sigmask, SIGTTOU); + dev->sigdata.context = lock.context; + dev->sigdata.lock = dev->lock.hw_lock; + block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); + if (lock.flags & _DRM_LOCK_QUIESCENT) { DRM_DEBUG("_DRM_LOCK_QUIESCENT\n"); DRM_DEBUG("fred\n"); @@ -1267,8 +1275,8 @@ int i810_dma_vertex(struct inode *inode, struct file *filp, dev_priv->sarea_priv; drm_i810_vertex_t vertex; - copy_from_user_ret(&vertex, (drm_i810_vertex_t *)arg, sizeof(vertex), - -EFAULT); + if (copy_from_user(&vertex, (drm_i810_vertex_t *)arg, sizeof(vertex))) + return -EFAULT; if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_dma_vertex called without lock held\n"); @@ -1299,8 +1307,8 @@ int i810_clear_bufs(struct inode *inode, struct file *filp, drm_device_t *dev = priv->dev; drm_i810_clear_t clear; - copy_from_user_ret(&clear, (drm_i810_clear_t *)arg, sizeof(clear), - -EFAULT); + if (copy_from_user(&clear, (drm_i810_clear_t *)arg, sizeof(clear))) + return -EFAULT; if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_clear_bufs called without lock held\n"); @@ -1357,7 +1365,8 @@ int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd, dev_priv->sarea_priv; DRM_DEBUG("getbuf\n"); - copy_from_user_ret(&d, (drm_i810_dma_t *)arg, sizeof(d), -EFAULT); + if (copy_from_user(&d, (drm_i810_dma_t *)arg, sizeof(d))) + return -EFAULT; if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_dma called without lock held\n"); @@ -1371,7 +1380,8 @@ int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd, DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", current->pid, retcode, d.granted); - copy_to_user_ret((drm_dma_t *)arg, &d, sizeof(d), -EFAULT); + if (copy_to_user((drm_dma_t *)arg, &d, sizeof(d))) + return -EFAULT; sarea_priv->last_dispatch = (int) hw_status[5]; return retcode; @@ -1396,14 +1406,16 @@ int i810_copybuf(struct inode *inode, struct file *filp, unsigned int cmd, return -EINVAL; } - copy_from_user_ret(&d, (drm_i810_copy_t *)arg, sizeof(d), -EFAULT); + if (copy_from_user(&d, (drm_i810_copy_t *)arg, sizeof(d))) + return -EFAULT; if(d.idx > dma->buf_count) return -EINVAL; buf = dma->buflist[ d.idx ]; buf_priv = buf->dev_private; if (buf_priv->currently_mapped != I810_BUF_MAPPED) return -EPERM; - copy_from_user_ret(buf_priv->virtual, d.address, d.used, -EFAULT); + if (copy_from_user(buf_priv->virtual, d.address, d.used)) + return -EFAULT; sarea_priv->last_dispatch = (int) hw_status[5]; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c index 5e86ea49d..ed880c41a 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c @@ -1,6 +1,6 @@ /* i810_drv.c -- I810 driver -*- linux-c -*- * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com - * + * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. @@ -11,11 +11,11 @@ * 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 @@ -28,7 +28,6 @@ * Jeff Hartmann <jhartmann@valinux.com> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c,v 1.5 2000/08/28 02:43:15 tsi Exp $ */ #include <linux/config.h> #include "drmP.h" @@ -36,7 +35,7 @@ #define I810_NAME "i810" #define I810_DESC "Intel I810" -#define I810_DATE "20000719" +#define I810_DATE "20000928" #define I810_MAJOR 1 #define I810_MINOR 1 #define I810_PATCHLEVEL 0 @@ -144,7 +143,7 @@ __setup("i810=", i810_options); static int i810_setup(drm_device_t *dev) { int i; - + atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); dev->buf_use = 0; @@ -189,22 +188,22 @@ static int i810_setup(drm_device_t *dev) #endif dev->ctx_start = 0; dev->lck_start = 0; - + dev->buf_rp = dev->buf; dev->buf_wp = dev->buf; dev->buf_end = dev->buf + DRM_BSZ; dev->buf_async = NULL; init_waitqueue_head(&dev->buf_readers); init_waitqueue_head(&dev->buf_writers); - + DRM_DEBUG("\n"); - + /* The kernel's context could be created here, but is now created in drm_dma_enqueue. This is more resource-efficient for hardware that does not do DMA, but may mean that drm_select_queue fails between the time the interrupt is initialized and the time the queues are initialized. */ - + return 0; } @@ -219,15 +218,15 @@ static int i810_takedown(drm_device_t *dev) DRM_DEBUG("\n"); if (dev->irq) i810_irq_uninstall(dev); - + down(&dev->struct_sem); del_timer(&dev->timer); - + if (dev->devname) { drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); dev->devname = NULL; } - + if (dev->unique) { drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); dev->unique = NULL; @@ -245,7 +244,7 @@ static int i810_takedown(drm_device_t *dev) if (dev->agp) { drm_agp_mem_t *entry; drm_agp_mem_t *nexte; - + /* Remove AGP resources, but leave dev->agp intact until r128_cleanup is called. */ for (entry = dev->agp->memory; entry; entry = nexte) { @@ -255,10 +254,10 @@ static int i810_takedown(drm_device_t *dev) drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); } dev->agp->memory = NULL; - + if (dev->agp->acquired && drm_agp.release) (*drm_agp.release)(); - + dev->agp->acquired = 0; dev->agp->enabled = 0; } @@ -270,7 +269,7 @@ static int i810_takedown(drm_device_t *dev) } dev->vmalist = NULL; } - + /* Clear map area and mtrr information */ if (dev->maplist) { for (i = 0; i < dev->map_count; i++) { @@ -306,7 +305,7 @@ static int i810_takedown(drm_device_t *dev) dev->maplist = NULL; dev->map_count = 0; } - + if (dev->queuelist) { for (i = 0; i < dev->queue_count; i++) { drm_waitlist_destroy(&dev->queuelist[i]->waitlist); @@ -332,7 +331,7 @@ static int i810_takedown(drm_device_t *dev) wake_up_interruptible(&dev->lock.lock_queue); } up(&dev->struct_sem); - + return 0; } @@ -349,7 +348,7 @@ static int i810_init(void) memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); - + #ifdef MODULE drm_parse_options(i810); #endif @@ -403,7 +402,7 @@ static void i810_cleanup(void) drm_device_t *dev = &i810_device; DRM_DEBUG("\n"); - + drm_proc_cleanup(); if (misc_deregister(&i810_misc)) { DRM_ERROR("Cannot unload module\n"); @@ -429,17 +428,18 @@ int i810_version(struct inode *inode, struct file *filp, unsigned int cmd, drm_version_t version; int len; - copy_from_user_ret(&version, + if (copy_from_user(&version, (drm_version_t *)arg, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; #define DRM_COPY(name,value) \ len = strlen(value); \ if (len > name##_len) len = name##_len; \ name##_len = strlen(value); \ if (len && name) { \ - copy_to_user_ret(name, value, len, -EFAULT); \ + if (copy_to_user(name, value, len)) \ + return -EFAULT; \ } version.version_major = I810_MAJOR; @@ -450,10 +450,10 @@ int i810_version(struct inode *inode, struct file *filp, unsigned int cmd, DRM_COPY(version.date, I810_DATE); DRM_COPY(version.desc, I810_DESC); - copy_to_user_ret((drm_version_t *)arg, + if (copy_to_user((drm_version_t *)arg, &version, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; return 0; } @@ -461,7 +461,7 @@ int i810_open(struct inode *inode, struct file *filp) { drm_device_t *dev = &i810_device; int retcode = 0; - + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { #if LINUX_VERSION_CODE < 0x020333 @@ -498,7 +498,7 @@ int i810_release(struct inode *inode, struct file *filp) drm_lock_free(dev, &dev->lock.hw_lock->lock, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); - + /* FIXME: may require heavy-handed reset of hardware at this point, possibly processed via a callback to the X @@ -508,6 +508,7 @@ int i810_release(struct inode *inode, struct file *filp) DECLARE_WAITQUEUE(entry, current); add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ retcode = -EINTR; @@ -519,10 +520,9 @@ int i810_release(struct inode *inode, struct file *filp) dev->lock.lock_time = jiffies; atomic_inc(&dev->total_locks); break; /* Got lock */ - } + } /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; schedule(); if (signal_pending(current)) { retcode = -ERESTARTSYS; @@ -545,7 +545,7 @@ int i810_release(struct inode *inode, struct file *filp) if (priv->next) priv->next->prev = priv->prev; else dev->file_last = priv->prev; up(&dev->struct_sem); - + drm_free(priv, sizeof(*priv), DRM_MEM_FILES); #if LINUX_VERSION_CODE < 0x020333 MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */ @@ -585,7 +585,7 @@ int i810_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, atomic_inc(&dev->ioctl_count); atomic_inc(&dev->total_ioctl); ++priv->ioctl_count; - + DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", current->pid, cmd, nr, dev->device, priv->authenticated); @@ -605,7 +605,7 @@ int i810_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, retcode = (func)(inode, filp, cmd, arg); } } - + atomic_dec(&dev->ioctl_count); return retcode; } @@ -617,8 +617,9 @@ int i810_unlock(struct inode *inode, struct file *filp, unsigned int cmd, drm_device_t *dev = priv->dev; drm_lock_t lock; - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); - + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; + if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); @@ -642,6 +643,7 @@ int i810_unlock(struct inode *inode, struct file *filp, unsigned int cmd, atomic_inc(&dev->histo.lhld[drm_histogram_slot(get_cycles() - dev->lck_start)]); #endif - + + unblock_all_signals(); return 0; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c index 0a21a9106..60e66b8fb 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c @@ -28,14 +28,12 @@ * Rickard E. (Rik) Faith <faith@valinux.com> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c,v 1.9 2000/08/28 02:43:15 tsi Exp $ */ #define __NO_VERSION__ #include "drmP.h" int drm_waitlist_create(drm_waitlist_t *bl, int count) { - DRM_DEBUG("%d\n", count); if (bl->count) return -EINVAL; bl->count = count; @@ -51,7 +49,6 @@ int drm_waitlist_create(drm_waitlist_t *bl, int count) int drm_waitlist_destroy(drm_waitlist_t *bl) { - DRM_DEBUG("\n"); if (bl->rp != bl->wp) return -EINVAL; if (bl->bufs) drm_free(bl->bufs, (bl->count + 2) * sizeof(*bl->bufs), @@ -70,8 +67,6 @@ int drm_waitlist_put(drm_waitlist_t *bl, drm_buf_t *buf) unsigned long flags; left = DRM_LEFTCOUNT(bl); - DRM_DEBUG("put %d (%d left, rp = %p, wp = %p)\n", - buf->idx, left, bl->rp, bl->wp); if (!left) { DRM_ERROR("Overflow while adding buffer %d from pid %d\n", buf->idx, buf->pid); @@ -104,13 +99,11 @@ drm_buf_t *drm_waitlist_get(drm_waitlist_t *bl) if (++bl->rp >= bl->end) bl->rp = bl->bufs; spin_unlock_irqrestore(&bl->read_lock, flags); - DRM_DEBUG("get %d\n", buf->idx); return buf; } int drm_freelist_create(drm_freelist_t *bl, int count) { - DRM_DEBUG("\n"); atomic_set(&bl->count, 0); bl->next = NULL; init_waitqueue_head(&bl->waiting); @@ -124,7 +117,6 @@ int drm_freelist_create(drm_freelist_t *bl, int count) int drm_freelist_destroy(drm_freelist_t *bl) { - DRM_DEBUG("\n"); atomic_set(&bl->count, 0); bl->next = NULL; return 0; @@ -143,9 +135,6 @@ int drm_freelist_put(drm_device_t *dev, drm_freelist_t *bl, drm_buf_t *buf) DRM_ERROR("Freed buffer %d: w%d, p%d, l%d\n", buf->idx, buf->waiting, buf->pending, buf->list); } - DRM_DEBUG("%d, count = %d, wfh = %d, w%d, p%d\n", - buf->idx, atomic_read(&bl->count), atomic_read(&bl->wfh), - buf->waiting, buf->pending); if (!bl) return 1; #if DRM_DMA_HISTOGRAM buf->time_freed = get_cycles(); @@ -191,9 +180,6 @@ static drm_buf_t *drm_freelist_try(drm_freelist_t *bl) atomic_dec(&bl->count); buf->next = NULL; buf->list = DRM_LIST_NONE; - DRM_DEBUG("%d, count = %d, wfh = %d, w%d, p%d\n", - buf->idx, atomic_read(&bl->count), atomic_read(&bl->wfh), - buf->waiting, buf->pending); if (buf->waiting || buf->pending) { DRM_ERROR("Free buffer %d: w%d, p%d, l%d\n", buf->idx, buf->waiting, buf->pending, buf->list); @@ -213,13 +199,10 @@ drm_buf_t *drm_freelist_get(drm_freelist_t *bl, int block) if (atomic_read(&bl->count) <= bl->low_mark) /* Became low */ atomic_set(&bl->wfh, 1); if (atomic_read(&bl->wfh)) { - DRM_DEBUG("Block = %d, count = %d, wfh = %d\n", - block, atomic_read(&bl->count), - atomic_read(&bl->wfh)); if (block) { add_wait_queue(&bl->waiting, &entry); - current->state = TASK_INTERRUPTIBLE; for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!atomic_read(&bl->wfh) && (buf = drm_freelist_try(bl))) break; schedule(); @@ -231,7 +214,5 @@ drm_buf_t *drm_freelist_get(drm_freelist_t *bl, int block) return buf; } - DRM_DEBUG("Count = %d, wfh = %d\n", - atomic_read(&bl->count), atomic_read(&bl->wfh)); return drm_freelist_try(bl); } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c index 550827278..90d2f1300 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c @@ -50,7 +50,6 @@ int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context) { unsigned int old, new, prev; - DRM_DEBUG("%d attempts\n", context); do { old = *lock; if (old & _DRM_LOCK_HELD) new = old | _DRM_LOCK_CONT; @@ -68,11 +67,8 @@ int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context) } if (new == (context | _DRM_LOCK_HELD)) { /* Have lock */ - DRM_DEBUG("%d\n", context); return 1; } - DRM_DEBUG("%d unable to get lock held by %d\n", - context, _DRM_LOCKING_CONTEXT(old)); return 0; } @@ -89,7 +85,6 @@ int drm_lock_transfer(drm_device_t *dev, new = context | _DRM_LOCK_HELD; prev = cmpxchg(lock, old, new); } while (prev != old); - DRM_DEBUG("%d => %d\n", _DRM_LOCKING_CONTEXT(old), context); return 1; } @@ -99,7 +94,6 @@ int drm_lock_free(drm_device_t *dev, unsigned int old, new, prev; pid_t pid = dev->lock.pid; - DRM_DEBUG("%d\n", context); dev->lock.pid = 0; do { old = *lock; @@ -128,10 +122,10 @@ static int drm_flush_queue(drm_device_t *dev, int context) atomic_inc(&q->use_count); if (atomic_read(&q->use_count) > 1) { atomic_inc(&q->block_write); - current->state = TASK_INTERRUPTIBLE; add_wait_queue(&q->flush_queue, &entry); atomic_inc(&q->block_count); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!DRM_BUFCOUNT(&q->waitlist)) break; schedule(); if (signal_pending(current)) { @@ -218,8 +212,41 @@ int drm_finish(struct inode *inode, struct file *filp, unsigned int cmd, DRM_DEBUG("\n"); - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; ret = drm_flush_block_and_flush(dev, lock.context, lock.flags); drm_flush_unblock(dev, lock.context, lock.flags); return ret; } + +/* If we get here, it means that the process has called DRM_IOCTL_LOCK + without calling DRM_IOCTL_UNLOCK. + + If the lock is not held, then let the signal proceed as usual. + + If the lock is held, then set the contended flag and keep the signal + blocked. + + + Return 1 if the signal should be delivered normally. + Return 0 if the signal should be blocked. */ + +int drm_notifier(void *priv) +{ + drm_sigdata_t *s = (drm_sigdata_t *)priv; + unsigned int old, new, prev; + + + /* Allow signal delivery if lock isn't held */ + if (!_DRM_LOCK_IS_HELD(s->lock->lock) + || _DRM_LOCKING_CONTEXT(s->lock->lock) != s->context) return 1; + + /* Otherwise, set flag to force call to + drmUnlock */ + do { + old = s->lock->lock; + new = old | _DRM_LOCK_CONT; + prev = cmpxchg(&s->lock->lock, old, new); + } while (prev != old); + return 0; +} diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c index b97eb4959..05d941b4c 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c @@ -57,16 +57,16 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; count = request.count; order = drm_order(request.size); size = 1 << order; agp_offset = request.agp_start; - alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size; + alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size):size; page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; total = PAGE_SIZE << page_order; byte_count = 0; @@ -119,8 +119,6 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, buf->order = order; buf->used = 0; - DRM_DEBUG("offset : %ld\n", offset); - buf->offset = offset; /* Hrm */ buf->bus_address = dev->agp->base + agp_offset + offset; buf->address = (void *)(agp_offset + offset + dev->agp->base); @@ -130,7 +128,8 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, init_waitqueue_head(&buf->dma_wait); buf->pid = 0; - buf->dev_private = drm_alloc(sizeof(drm_mga_buf_priv_t), DRM_MEM_BUFS); + buf->dev_private = drm_alloc(sizeof(drm_mga_buf_priv_t), + DRM_MEM_BUFS); buf->dev_priv_size = sizeof(drm_mga_buf_priv_t); #if DRM_DMA_HISTOGRAM @@ -142,9 +141,6 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, offset = offset + alignment; entry->buf_count++; byte_count += PAGE_SIZE << page_order; - - DRM_DEBUG("buffer %d @ %p\n", - entry->buf_count, buf->address); } dma->buflist = drm_realloc(dma->buflist, @@ -173,10 +169,10 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, request.count = entry->buf_count; request.size = size; - copy_to_user_ret((drm_buf_desc_t *)arg, + if (copy_to_user((drm_buf_desc_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; atomic_dec(&dev->buf_alloc); @@ -219,10 +215,10 @@ int mga_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd, if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; count = request.count; order = drm_order(request.size); @@ -234,7 +230,7 @@ int mga_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd, if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL; if (dev->queue_count) return -EBUSY; /* Not while in use */ - alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size; + alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size):size; page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; total = PAGE_SIZE << page_order; @@ -348,10 +344,10 @@ int mga_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd, request.count = entry->buf_count; request.size = size; - copy_to_user_ret((drm_buf_desc_t *)arg, + if (copy_to_user((drm_buf_desc_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; atomic_dec(&dev->buf_alloc); return 0; @@ -362,10 +358,10 @@ int mga_addbufs(struct inode *inode, struct file *filp, unsigned int cmd, { drm_buf_desc_t request; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; if(request.flags & _DRM_AGP_BUFFER) return mga_addbufs_agp(inode, filp, cmd, arg); @@ -393,58 +389,47 @@ int mga_infobufs(struct inode *inode, struct file *filp, unsigned int cmd, ++dev->buf_use; /* Can't allocate more after this call */ spin_unlock(&dev->count_lock); - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_info_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) { if (dma->bufs[i].buf_count) ++count; } - DRM_DEBUG("count = %d\n", count); - if (request.count >= count) { for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) { if (dma->bufs[i].buf_count) { - copy_to_user_ret(&request.list[count].count, + if (copy_to_user(&request.list[count].count, &dma->bufs[i].buf_count, sizeof(dma->bufs[0] - .buf_count), - -EFAULT); - copy_to_user_ret(&request.list[count].size, + .buf_count)) || + copy_to_user(&request.list[count].size, &dma->bufs[i].buf_size, - sizeof(dma->bufs[0].buf_size), - -EFAULT); - copy_to_user_ret(&request.list[count].low_mark, + sizeof(dma->bufs[0].buf_size)) || + copy_to_user(&request.list[count].low_mark, &dma->bufs[i] .freelist.low_mark, sizeof(dma->bufs[0] - .freelist.low_mark), - -EFAULT); - copy_to_user_ret(&request.list[count] + .freelist.low_mark)) || + copy_to_user(&request.list[count] .high_mark, &dma->bufs[i] .freelist.high_mark, sizeof(dma->bufs[0] - .freelist.high_mark), - -EFAULT); - DRM_DEBUG("%d %d %d %d %d\n", - i, - dma->bufs[i].buf_count, - dma->bufs[i].buf_size, - dma->bufs[i].freelist.low_mark, - dma->bufs[i].freelist.high_mark); + .freelist.high_mark))) + return -EFAULT; ++count; } } } request.count = count; - copy_to_user_ret((drm_buf_info_t *)arg, + if (copy_to_user((drm_buf_info_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; return 0; } @@ -461,13 +446,9 @@ int mga_markbufs(struct inode *inode, struct file *filp, unsigned int cmd, if (!dma) return -EINVAL; - copy_from_user_ret(&request, - (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + if (copy_from_user(&request, (drm_buf_desc_t *)arg, sizeof(request))) + return -EFAULT; - DRM_DEBUG("%d, %d, %d\n", - request.size, request.low_mark, request.high_mark); order = drm_order(request.size); if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL; entry = &dma->bufs[order]; @@ -496,17 +477,16 @@ int mga_freebufs(struct inode *inode, struct file *filp, unsigned int cmd, if (!dma) return -EINVAL; - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_free_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; - DRM_DEBUG("%d\n", request.count); for (i = 0; i < request.count; i++) { - copy_from_user_ret(&idx, + if (copy_from_user(&idx, &request.list[i], - sizeof(idx), - -EFAULT); + sizeof(idx))) + return -EFAULT; if (idx < 0 || idx >= dma->buf_count) { DRM_ERROR("Index %d (of %d max)\n", idx, dma->buf_count - 1); @@ -539,25 +519,19 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd, if (!dma) return -EINVAL; - DRM_DEBUG("\n"); - spin_lock(&dev->count_lock); if (atomic_read(&dev->buf_alloc)) { spin_unlock(&dev->count_lock); - DRM_DEBUG("Busy\n"); return -EBUSY; } ++dev->buf_use; /* Can't allocate more after this call */ spin_unlock(&dev->count_lock); - copy_from_user_ret(&request, + if (copy_from_user(&request, (drm_buf_map_t *)arg, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; - DRM_DEBUG("mga_mapbufs\n"); - DRM_DEBUG("dma->flags : %x\n", dma->flags); - if (request.count >= dma->buf_count) { if(dma->flags & _DRM_DMA_USE_AGP) { drm_mga_private_t *dev_priv = dev->dev_private; @@ -565,7 +539,6 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd, map = dev->maplist[dev_priv->buffer_map_idx]; if (!map) { - DRM_DEBUG("map is null\n"); retcode = -EINVAL; goto done; } @@ -628,10 +601,10 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd, request.count = dma->buf_count; DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode); - copy_to_user_ret((drm_buf_map_t *)arg, + if (copy_to_user((drm_buf_map_t *)arg, &request, - sizeof(request), - -EFAULT); + sizeof(request))) + return -EFAULT; DRM_DEBUG("retcode : %d\n", retcode); diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c index 546aac165..b26c7c98e 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c @@ -28,7 +28,6 @@ * Jeff Hartmann <jhartmann@valinux.com> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c,v 1.4 2000/08/28 02:43:15 tsi Exp $ */ #define __NO_VERSION__ #include "drmP.h" @@ -36,9 +35,7 @@ static int mga_alloc_queue(drm_device_t *dev) { - int temp = drm_ctxbitmap_next(dev); - DRM_DEBUG("mga_alloc_queue: %d\n", temp); - return temp; + return drm_ctxbitmap_next(dev); } int mga_context_switch(drm_device_t *dev, int old, int new) @@ -103,20 +100,21 @@ int mga_resctx(struct inode *inode, struct file *filp, unsigned int cmd, drm_ctx_t ctx; int i; - DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS); - copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT); + if (copy_from_user(&res, (drm_ctx_res_t *)arg, sizeof(res))) + return -EFAULT; if (res.count >= DRM_RESERVED_CONTEXTS) { memset(&ctx, 0, sizeof(ctx)); for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { ctx.handle = i; - copy_to_user_ret(&res.contexts[i], + if (copy_to_user(&res.contexts[i], &i, - sizeof(i), - -EFAULT); + sizeof(i))) + return -EFAULT; } } res.count = DRM_RESERVED_CONTEXTS; - copy_to_user_ret((drm_ctx_res_t *)arg, &res, sizeof(res), -EFAULT); + if (copy_to_user((drm_ctx_res_t *)arg, &res, sizeof(res))) + return -EFAULT; return 0; } @@ -127,18 +125,18 @@ int mga_addctx(struct inode *inode, struct file *filp, unsigned int cmd, drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; if ((ctx.handle = mga_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) { /* Skip kernel's context and get a new one. */ ctx.handle = mga_alloc_queue(dev); } if (ctx.handle == -1) { - DRM_DEBUG("Not enough free contexts.\n"); - /* Should this return -EBUSY instead? */ return -ENOMEM; } DRM_DEBUG("%d\n", ctx.handle); - copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT); + if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx))) + return -EFAULT; return 0; } @@ -154,10 +152,12 @@ int mga_getctx(struct inode *inode, struct file *filp, unsigned int cmd, { drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t*)arg, sizeof(ctx))) + return -EFAULT; /* This is 0, because we don't hanlde any context flags */ ctx.flags = 0; - copy_to_user_ret((drm_ctx_t*)arg, &ctx, sizeof(ctx), -EFAULT); + if (copy_to_user((drm_ctx_t*)arg, &ctx, sizeof(ctx))) + return -EFAULT; return 0; } @@ -168,7 +168,8 @@ int mga_switchctx(struct inode *inode, struct file *filp, unsigned int cmd, drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); return mga_context_switch(dev, dev->last_context, ctx.handle); } @@ -180,7 +181,8 @@ int mga_newctx(struct inode *inode, struct file *filp, unsigned int cmd, drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); mga_context_switch_complete(dev, ctx.handle); @@ -194,8 +196,11 @@ int mga_rmctx(struct inode *inode, struct file *filp, unsigned int cmd, drm_device_t *dev = priv->dev; drm_ctx_t ctx; - copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx))) + return -EFAULT; DRM_DEBUG("%d\n", ctx.handle); + if(ctx.handle == DRM_KERNEL_CONTEXT+1) priv->remove_auth_on_close = 1; + if(ctx.handle != DRM_KERNEL_CONTEXT) { drm_ctxbitmap_free(dev, ctx.handle); } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c index 4daa03acb..4e1871e28 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c @@ -52,34 +52,28 @@ static unsigned long mga_alloc_page(drm_device_t *dev) { unsigned long address; - DRM_DEBUG("%s\n", __FUNCTION__); address = __get_free_page(GFP_KERNEL); if(address == 0UL) { return 0; } atomic_inc(&virt_to_page(address)->count); - set_bit(PG_locked, &virt_to_page(address)->flags); + set_bit(PG_reserved, &virt_to_page(address)->flags); return address; } static void mga_free_page(drm_device_t *dev, unsigned long page) { - DRM_DEBUG("%s\n", __FUNCTION__); - - if(page == 0UL) { - return; - } + if(!page) return; atomic_dec(&virt_to_page(page)->count); - clear_bit(PG_locked, &virt_to_page(page)->flags); - wake_up(&virt_to_page(page)->wait); + clear_bit(PG_reserved, &virt_to_page(page)->flags); free_page(page); return; } static void mga_delay(void) { - return; + return; } /* These are two age tags that will never be sent to @@ -96,8 +90,6 @@ static int mga_freelist_init(drm_device_t *dev) drm_mga_freelist_t *item; int i; - DRM_DEBUG("%s\n", __FUNCTION__); - dev_priv->head = drm_alloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER); if(dev_priv->head == NULL) return -ENOMEM; memset(dev_priv->head, 0, sizeof(drm_mga_freelist_t)); @@ -132,8 +124,6 @@ static void mga_freelist_cleanup(drm_device_t *dev) drm_mga_freelist_t *item; drm_mga_freelist_t *prev; - DRM_DEBUG("%s\n", __FUNCTION__); - item = dev_priv->head; while(item) { prev = item; @@ -153,7 +143,7 @@ static inline void mga_dma_quiescent(drm_device_t *dev) unsigned long end; int i; - DRM_DEBUG("%s\n", __FUNCTION__); + DRM_DEBUG("dispatch_status = 0x%02x\n", dev_priv->dispatch_status); end = jiffies + (HZ*3); while(1) { if(!test_and_set_bit(MGA_IN_DISPATCH, @@ -164,8 +154,10 @@ static inline void mga_dma_quiescent(drm_device_t *dev) DRM_ERROR("irqs: %d wanted %d\n", atomic_read(&dev->total_irq), atomic_read(&dma->total_lost)); - DRM_ERROR("lockup\n"); - goto out_nolock; + DRM_ERROR("lockup: dispatch_status = 0x%02x," + " jiffies = %lu, end = %lu\n", + dev_priv->dispatch_status, jiffies, end); + return; } for (i = 0 ; i < 2000 ; i++) mga_delay(); } @@ -177,15 +169,16 @@ static inline void mga_dma_quiescent(drm_device_t *dev) atomic_read(&dev->total_irq), atomic_read(&dma->total_lost)); DRM_ERROR("lockup\n"); - goto out_status; + clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status); + return; } for (i = 0 ; i < 2000 ; i++) mga_delay(); } sarea_priv->dirty |= MGA_DMA_FLUSH; -out_status: clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status); -out_nolock: + DRM_DEBUG("exit, dispatch_status = 0x%02x\n", + dev_priv->dispatch_status); } static void mga_reset_freelist(drm_device_t *dev) @@ -216,29 +209,26 @@ drm_buf_t *mga_freelist_get(drm_device_t *dev) static int failed = 0; int return_null = 0; - DRM_DEBUG("%s : tail->age : %d last_prim_age : %d\n", __FUNCTION__, - dev_priv->tail->age, dev_priv->last_prim_age); - if(failed >= 1000 && dev_priv->tail->age >= dev_priv->last_prim_age) { - DRM_DEBUG("I'm waiting on the freelist!!! %d\n", - dev_priv->last_prim_age); - set_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status); + DRM_DEBUG("Waiting on freelist," + " tail->age = %d, last_prim_age= %d\n", + dev_priv->tail->age, + dev_priv->last_prim_age); add_wait_queue(&dev_priv->buf_queue, &entry); + set_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status); for (;;) { - mga_dma_schedule(dev, 0); current->state = TASK_INTERRUPTIBLE; - if(!test_bit(MGA_IN_GETBUF, - &dev_priv->dispatch_status)) + mga_dma_schedule(dev, 0); + if(dev_priv->tail->age < dev_priv->last_prim_age) break; atomic_inc(&dev->total_sleeps); schedule(); if (signal_pending(current)) { ++return_null; - clear_bit(MGA_IN_GETBUF, - &dev_priv->dispatch_status); break; } } + clear_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status); current->state = TASK_RUNNING; remove_wait_queue(&dev_priv->buf_queue, &entry); if (return_null) return NULL; @@ -254,6 +244,7 @@ drm_buf_t *mga_freelist_get(drm_device_t *dev) failed = 0; return next->buf; } + failed++; return NULL; } @@ -267,8 +258,6 @@ int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf) drm_mga_freelist_t *head; drm_mga_freelist_t *next; - DRM_DEBUG("%s\n", __FUNCTION__); - if(buf_priv->my_freelist->age == MGA_BUF_USED) { /* Discarded buffer, put it on the tail */ next = buf_priv->my_freelist; @@ -278,7 +267,6 @@ int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf) next->prev = prev; next->next = NULL; dev_priv->tail = next; - DRM_DEBUG("Discarded\n"); } else { /* Normally aged buffer, put it on the head + 1, * as the real head is a sentinal element @@ -302,7 +290,6 @@ static int mga_init_primary_bufs(drm_device_t *dev, drm_mga_init_t *init) int i, temp, size_of_buf; int offset = init->reserved_map_agpstart; - DRM_DEBUG("%s\n", __FUNCTION__); dev_priv->primary_size = ((init->primary_size + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; size_of_buf = dev_priv->primary_size / MGA_NUM_PRIM_BUFS; @@ -323,7 +310,7 @@ static int mga_init_primary_bufs(drm_device_t *dev, drm_mga_init_t *init) dev_priv->ioremap = drm_ioremap(dev->agp->base + offset, temp); if(dev_priv->ioremap == NULL) { - DRM_DEBUG("Ioremap failed\n"); + DRM_ERROR("Ioremap failed\n"); return -ENOMEM; } init_waitqueue_head(&dev_priv->wait_queue); @@ -370,7 +357,6 @@ void mga_fire_primary(drm_device_t *dev, drm_mga_prim_buf_t *prim) int next_idx; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); dev_priv->last_prim = prim; /* We never check for overflow, b/c there is always room */ @@ -387,14 +373,12 @@ void mga_fire_primary(drm_device_t *dev, drm_mga_prim_buf_t *prim) end = jiffies + (HZ*3); if(sarea_priv->dirty & MGA_DMA_FLUSH) { - DRM_DEBUG("Dma top flush\n"); while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) { if((signed)(end - jiffies) <= 0) { DRM_ERROR("irqs: %d wanted %d\n", atomic_read(&dev->total_irq), atomic_read(&dma->total_lost)); - DRM_ERROR("lockup in fire primary " - "(Dma Top Flush)\n"); + DRM_ERROR("lockup (flush)\n"); goto out_prim_wait; } @@ -402,14 +386,12 @@ void mga_fire_primary(drm_device_t *dev, drm_mga_prim_buf_t *prim) } sarea_priv->dirty &= ~(MGA_DMA_FLUSH); } else { - DRM_DEBUG("Status wait\n"); while((MGA_READ(MGAREG_STATUS) & 0x00020001) != 0x00020000) { if((signed)(end - jiffies) <= 0) { DRM_ERROR("irqs: %d wanted %d\n", atomic_read(&dev->total_irq), atomic_read(&dma->total_lost)); - DRM_ERROR("lockup in fire primary " - "(Status Wait)\n"); + DRM_ERROR("lockup (wait)\n"); goto out_prim_wait; } @@ -452,7 +434,6 @@ int mga_advance_primary(drm_device_t *dev) /* This needs to reset the primary buffer if available, * we should collect stats on how many times it bites * it's tail */ - DRM_DEBUG("%s\n", __FUNCTION__); next_prim_idx = dev_priv->current_prim_idx + 1; if(next_prim_idx >= MGA_NUM_PRIM_BUFS) @@ -464,9 +445,8 @@ int mga_advance_primary(drm_device_t *dev) if(test_and_set_bit(MGA_BUF_IN_USE, &prim_buffer->buffer_status)) { add_wait_queue(&dev_priv->wait_queue, &entry); - current->state = TASK_INTERRUPTIBLE; - for (;;) { + current->state = TASK_INTERRUPTIBLE; mga_dma_schedule(dev, 0); if(!test_and_set_bit(MGA_BUF_IN_USE, &prim_buffer->buffer_status)) @@ -479,7 +459,7 @@ int mga_advance_primary(drm_device_t *dev) break; } } - current->state = TASK_RUNNING; + current->state = TASK_RUNNING; remove_wait_queue(&dev_priv->wait_queue, &entry); if(ret) return ret; } @@ -491,10 +471,10 @@ int mga_advance_primary(drm_device_t *dev) prim_buffer->sec_used = 0; prim_buffer->prim_age = dev_priv->next_prim_age++; if(prim_buffer->prim_age == 0 || prim_buffer->prim_age == 0xffffffff) { - mga_flush_queue(dev); - mga_dma_quiescent(dev); - mga_reset_freelist(dev); - prim_buffer->prim_age = (dev_priv->next_prim_age += 2); + mga_flush_queue(dev); + mga_dma_quiescent(dev); + mga_reset_freelist(dev); + prim_buffer->prim_age = (dev_priv->next_prim_age += 2); } /* Reset all buffer status stuff */ @@ -511,67 +491,55 @@ int mga_advance_primary(drm_device_t *dev) static inline int mga_decide_to_fire(drm_device_t *dev) { drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; - drm_device_dma_t *dma = dev->dma; - - DRM_DEBUG("%s\n", __FUNCTION__); if(test_bit(MGA_BUF_FORCE_FIRE, &dev_priv->next_prim->buffer_status)) { - atomic_inc(&dma->total_prio); return 1; } if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) && dev_priv->next_prim->num_dwords) { - atomic_inc(&dma->total_prio); return 1; } if (test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) && dev_priv->next_prim->num_dwords) { - atomic_inc(&dma->total_prio); return 1; } if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS - 1) { if(test_bit(MGA_BUF_SWAP_PENDING, &dev_priv->next_prim->buffer_status)) { - atomic_inc(&dma->total_dmas); return 1; } } if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS / 2) { if(dev_priv->next_prim->sec_used >= MGA_DMA_BUF_NR / 8) { - atomic_inc(&dma->total_hit); return 1; } } if(atomic_read(&dev_priv->pending_bufs) >= MGA_NUM_PRIM_BUFS / 2) { if(dev_priv->next_prim->sec_used >= MGA_DMA_BUF_NR / 4) { - atomic_inc(&dma->total_missed_free); return 1; } } - atomic_inc(&dma->total_tried); return 0; } int mga_dma_schedule(drm_device_t *dev, int locked) { drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; - drm_device_dma_t *dma = dev->dma; - int retval = 0; + int retval = 0; - if (test_and_set_bit(0, &dev->dma_flag)) { - atomic_inc(&dma->total_missed_dma); + if (!dev_priv) return -EBUSY; + + if (test_and_set_bit(0, &dev->dma_flag)) { retval = -EBUSY; goto sch_out_wakeup; } - DRM_DEBUG("%s\n", __FUNCTION__); - if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) || test_bit(MGA_IN_WAIT, &dev_priv->dispatch_status) || test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) { @@ -580,18 +548,14 @@ int mga_dma_schedule(drm_device_t *dev, int locked) if (!locked && !drm_lock_take(&dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) { - atomic_inc(&dma->total_missed_lock); clear_bit(0, &dev->dma_flag); - DRM_DEBUG("Not locked\n"); retval = -EBUSY; goto sch_out_wakeup; } - DRM_DEBUG("I'm locked\n"); if(!test_and_set_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status)) { /* Fire dma buffer */ if(mga_decide_to_fire(dev)) { - DRM_DEBUG("idx :%d\n", dev_priv->next_prim->idx); clear_bit(MGA_BUF_FORCE_FIRE, &dev_priv->next_prim->buffer_status); if(dev_priv->current_prim == dev_priv->next_prim) { @@ -603,8 +567,6 @@ int mga_dma_schedule(drm_device_t *dev, int locked) } else { clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status); } - } else { - DRM_DEBUG("I can't get the dispatch lock\n"); } if (!locked) { @@ -614,6 +576,8 @@ int mga_dma_schedule(drm_device_t *dev, int locked) } } + clear_bit(0, &dev->dma_flag); + sch_out_wakeup: if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) && atomic_read(&dev_priv->pending_bufs) == 0) { @@ -622,18 +586,10 @@ sch_out_wakeup: wake_up_interruptible(&dev_priv->flush_queue); } - if(test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) && - dev_priv->tail->age < dev_priv->last_prim_age) { - clear_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status); - DRM_DEBUG("Waking up buf queue\n"); + if(test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) + && dev_priv->tail->age < dev_priv->last_prim_age) wake_up_interruptible(&dev_priv->buf_queue); - } else if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) { - DRM_DEBUG("Not waking buf_queue on %d %d\n", - atomic_read(&dev->total_irq), - dev_priv->last_prim_age); - } - clear_bit(0, &dev->dma_flag); return retval; } @@ -643,7 +599,6 @@ static void mga_dma_service(int irq, void *device, struct pt_regs *regs) drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; drm_mga_prim_buf_t *last_prim_buffer; - DRM_DEBUG("%s\n", __FUNCTION__); atomic_inc(&dev->total_irq); if((MGA_READ(MGAREG_STATUS) & 0x00000001) != 0x00000001) return; MGA_WRITE(MGAREG_ICLEAR, 0x00000001); @@ -653,28 +608,28 @@ static void mga_dma_service(int irq, void *device, struct pt_regs *regs) dev_priv->sarea_priv->last_dispatch = dev_priv->last_prim_age = last_prim_buffer->prim_age; clear_bit(MGA_BUF_IN_USE, &last_prim_buffer->buffer_status); - wake_up_interruptible(&dev_priv->wait_queue); clear_bit(MGA_BUF_SWAP_PENDING, &last_prim_buffer->buffer_status); clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status); atomic_dec(&dev_priv->pending_bufs); queue_task(&dev->tq, &tq_immediate); mark_bh(IMMEDIATE_BH); + wake_up_interruptible(&dev_priv->wait_queue); } static void mga_dma_task_queue(void *device) { - DRM_DEBUG("%s\n", __FUNCTION__); mga_dma_schedule((drm_device_t *)device, 0); } int mga_dma_cleanup(drm_device_t *dev) { - DRM_DEBUG("%s\n", __FUNCTION__); - if(dev->dev_private) { drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; + if (dev->irq) mga_flush_queue(dev); + mga_dma_quiescent(dev); + if(dev_priv->ioremap) { int temp = (dev_priv->warp_ucode_size + dev_priv->primary_size + @@ -717,7 +672,6 @@ int mga_dma_cleanup(drm_device_t *dev) static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { drm_mga_private_t *dev_priv; drm_map_t *sarea_map = NULL; - int i; DRM_DEBUG("%s\n", __FUNCTION__); @@ -730,7 +684,6 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { if((init->reserved_map_idx >= dev->map_count) || (init->buffer_map_idx >= dev->map_count)) { mga_dma_cleanup(dev); - DRM_DEBUG("reserved_map or buffer_map are invalid\n"); return -EINVAL; } @@ -758,7 +711,7 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { dev_priv->WarpPipe = 0xff000000; dev_priv->vertexsize = 0; - DRM_DEBUG("chipset: %d ucode_size: %d backOffset: %x depthOffset: %x\n", + DRM_DEBUG("chipset=%d ucode_size=%d backOffset=%x depthOffset=%x\n", dev_priv->chipset, dev_priv->warp_ucode_size, dev_priv->backOffset, dev_priv->depthOffset); DRM_DEBUG("cpp: %d sgram: %d stride: %d maccess: %x\n", @@ -768,13 +721,6 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { memcpy(&dev_priv->WarpIndex, &init->WarpIndex, sizeof(drm_mga_warp_index_t) * MGA_MAX_WARP_PIPES); - for (i = 0 ; i < MGA_MAX_WARP_PIPES ; i++) - DRM_DEBUG("warp pipe %d: installed: %d phys: %lx size: %x\n", - i, - dev_priv->WarpIndex[i].installed, - dev_priv->WarpIndex[i].phys_addr, - dev_priv->WarpIndex[i].size); - if(mga_init_primary_bufs(dev, init) != 0) { DRM_ERROR("Can not initialize primary buffers\n"); mga_dma_cleanup(dev); @@ -839,8 +785,6 @@ int mga_dma_init(struct inode *inode, struct file *filp, drm_device_t *dev = priv->dev; drm_mga_init_t init; - DRM_DEBUG("%s\n", __FUNCTION__); - if (copy_from_user(&init, (drm_mga_init_t *)arg, sizeof(init))) return -EFAULT; @@ -927,8 +871,6 @@ int mga_control(struct inode *inode, struct file *filp, unsigned int cmd, if (copy_from_user(&ctl, (drm_control_t *)arg, sizeof(ctl))) return -EFAULT; - DRM_DEBUG("%s\n", __FUNCTION__); - switch (ctl.func) { case DRM_INST_HANDLER: return mga_irq_install(dev, ctl.irq); @@ -945,18 +887,16 @@ static int mga_flush_queue(drm_device_t *dev) drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; int ret = 0; - DRM_DEBUG("%s\n", __FUNCTION__); - - if(dev_priv == NULL) { - return 0; - } + if(!dev_priv) return 0; if(dev_priv->next_prim->num_dwords != 0) { - current->state = TASK_INTERRUPTIBLE; add_wait_queue(&dev_priv->flush_queue, &entry); + if (test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status)) + DRM_ERROR("Incorrect mga_flush_queue logic\n"); set_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status); mga_dma_schedule(dev, 0); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status)) break; @@ -969,7 +909,7 @@ static int mga_flush_queue(drm_device_t *dev) break; } } - current->state = TASK_RUNNING; + current->state = TASK_RUNNING; remove_wait_queue(&dev_priv->flush_queue, &entry); } return ret; @@ -985,7 +925,8 @@ void mga_reclaim_buffers(drm_device_t *dev, pid_t pid) if(dev->dev_private == NULL) return; if(dma->buflist == NULL) return; - DRM_DEBUG("%s\n", __FUNCTION__); + DRM_DEBUG("buf_count=%d\n", dma->buf_count); + mga_flush_queue(dev); for (i = 0; i < dma->buf_count; i++) { @@ -1011,7 +952,6 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, int ret = 0; drm_lock_t lock; - DRM_DEBUG("%s\n", __FUNCTION__); if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) return -EFAULT; @@ -1021,13 +961,7 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, return -EINVAL; } - DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", - lock.context, current->pid, dev->lock.hw_lock->lock, - lock.flags); - - if (lock.context < 0) { - return -EINVAL; - } + if (lock.context < 0) return -EINVAL; /* Only one queue: */ @@ -1035,6 +969,7 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, if (!ret) { add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ ret = -EINTR; @@ -1050,7 +985,6 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; schedule(); if (signal_pending(current)) { ret = -ERESTARTSYS; @@ -1078,7 +1012,8 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, } } - DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); + if (ret) DRM_DEBUG("%d %s\n", lock.context, + ret ? "interrupted" : "has lock"); return ret; } @@ -1090,12 +1025,11 @@ int mga_flush_ioctl(struct inode *inode, struct file *filp, drm_lock_t lock; drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; - DRM_DEBUG("%s\n", __FUNCTION__); if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) return -EFAULT; if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { - DRM_ERROR("mga_flush_ioctl called without lock held\n"); + DRM_ERROR("lock not held\n"); return -EINVAL; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c index 38bc716b7..4aaac6254 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c @@ -1,6 +1,6 @@ /* mga_drv.c -- Matrox g200/g400 driver -*- linux-c -*- * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com - * + * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. @@ -11,11 +11,11 @@ * 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 @@ -29,18 +29,17 @@ * * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c,v 1.4 2000/08/28 02:43:15 tsi Exp $ */ #include <linux/config.h> #include "drmP.h" #include "mga_drv.h" #define MGA_NAME "mga" -#define MGA_DESC "Matrox g200/g400" -#define MGA_DATE "20000719" -#define MGA_MAJOR 1 +#define MGA_DESC "Matrox G200/G400" +#define MGA_DATE "20000928" +#define MGA_MAJOR 2 #define MGA_MINOR 0 -#define MGA_PATCHLEVEL 0 +#define MGA_PATCHLEVEL 1 static drm_device_t mga_device; drm_ctx_t mga_res_ctx; @@ -124,7 +123,7 @@ static char *mga = NULL; #endif MODULE_AUTHOR("VA Linux Systems, Inc."); -MODULE_DESCRIPTION("Matrox g200/g400"); +MODULE_DESCRIPTION("Matrox G200/G400"); MODULE_PARM(mga, "s"); #ifndef MODULE @@ -145,7 +144,7 @@ __setup("mga=", mga_options); static int mga_setup(drm_device_t *dev) { int i; - + atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); dev->buf_use = 0; @@ -188,22 +187,22 @@ static int mga_setup(drm_device_t *dev) dev->ctx_start = 0; dev->lck_start = 0; - + dev->buf_rp = dev->buf; dev->buf_wp = dev->buf; dev->buf_end = dev->buf + DRM_BSZ; dev->buf_async = NULL; init_waitqueue_head(&dev->buf_readers); init_waitqueue_head(&dev->buf_writers); - + DRM_DEBUG("\n"); - + /* The kernel's context could be created here, but is now created in drm_dma_enqueue. This is more resource-efficient for hardware that does not do DMA, but may mean that drm_select_queue fails between the time the interrupt is initialized and the time the queues are initialized. */ - + return 0; } @@ -217,16 +216,17 @@ static int mga_takedown(drm_device_t *dev) DRM_DEBUG("\n"); + if (dev->dev_private) mga_dma_cleanup(dev); if (dev->irq) mga_irq_uninstall(dev); - + down(&dev->struct_sem); del_timer(&dev->timer); - + if (dev->devname) { drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); dev->devname = NULL; } - + if (dev->unique) { drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); dev->unique = NULL; @@ -244,7 +244,7 @@ static int mga_takedown(drm_device_t *dev) if (dev->agp) { drm_agp_mem_t *entry; drm_agp_mem_t *nexte; - + /* Remove AGP resources, but leave dev->agp intact until cleanup is called. */ for (entry = dev->agp->memory; entry; entry = nexte) { @@ -254,10 +254,10 @@ static int mga_takedown(drm_device_t *dev) drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); } dev->agp->memory = NULL; - + if (dev->agp->acquired && drm_agp.release) (*drm_agp.release)(); - + dev->agp->acquired = 0; dev->agp->enabled = 0; } @@ -269,7 +269,7 @@ static int mga_takedown(drm_device_t *dev) } dev->vmalist = NULL; } - + /* Clear map area and mtrr information */ if (dev->maplist) { for (i = 0; i < dev->map_count; i++) { @@ -305,7 +305,7 @@ static int mga_takedown(drm_device_t *dev) dev->maplist = NULL; dev->map_count = 0; } - + if (dev->queuelist) { for (i = 0; i < dev->queue_count; i++) { drm_waitlist_destroy(&dev->queuelist[i]->waitlist); @@ -331,7 +331,7 @@ static int mga_takedown(drm_device_t *dev) wake_up_interruptible(&dev->lock.lock_queue); } up(&dev->struct_sem); - + return 0; } @@ -348,11 +348,10 @@ static int mga_init(void) memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); - + #ifdef MODULE drm_parse_options(mga); #endif - DRM_DEBUG("doing misc_register\n"); if ((retcode = misc_register(&mga_misc))) { DRM_ERROR("Cannot register \"%s\"\n", MGA_NAME); return retcode; @@ -360,11 +359,8 @@ static int mga_init(void) dev->device = MKDEV(MISC_MAJOR, mga_misc.minor); dev->name = MGA_NAME; - DRM_DEBUG("doing mem init\n"); drm_mem_init(); - DRM_DEBUG("doing proc init\n"); drm_proc_init(dev); - DRM_DEBUG("doing agp init\n"); dev->agp = drm_agp_init(); if(dev->agp == NULL) { DRM_INFO("The mga drm module requires the agpgart module" @@ -381,7 +377,6 @@ static int mga_init(void) MTRR_TYPE_WRCOMB, 1); #endif - DRM_DEBUG("doing ctxbitmap init\n"); if((retcode = drm_ctxbitmap_init(dev))) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); drm_proc_cleanup(); @@ -408,7 +403,7 @@ static void mga_cleanup(void) drm_device_t *dev = &mga_device; DRM_DEBUG("\n"); - + drm_proc_cleanup(); if (misc_deregister(&mga_misc)) { DRM_ERROR("Cannot unload module\n"); @@ -416,11 +411,10 @@ static void mga_cleanup(void) DRM_INFO("Module unloaded\n"); } drm_ctxbitmap_cleanup(dev); - mga_dma_cleanup(dev); #ifdef CONFIG_MTRR if(dev->agp && dev->agp->agp_mtrr) { int retval; - retval = mtrr_del(dev->agp->agp_mtrr, + retval = mtrr_del(dev->agp->agp_mtrr, dev->agp->agp_info.aper_base, dev->agp->agp_info.aper_size * 1024*1024); DRM_DEBUG("mtrr_del = %d\n", retval); @@ -445,17 +439,18 @@ int mga_version(struct inode *inode, struct file *filp, unsigned int cmd, drm_version_t version; int len; - copy_from_user_ret(&version, + if (copy_from_user(&version, (drm_version_t *)arg, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; #define DRM_COPY(name,value) \ len = strlen(value); \ if (len > name##_len) len = name##_len; \ name##_len = strlen(value); \ if (len && name) { \ - copy_to_user_ret(name, value, len, -EFAULT); \ + if (copy_to_user(name, value, len)) \ + return -EFAULT; \ } version.version_major = MGA_MAJOR; @@ -466,10 +461,10 @@ int mga_version(struct inode *inode, struct file *filp, unsigned int cmd, DRM_COPY(version.date, MGA_DATE); DRM_COPY(version.desc, MGA_DESC); - copy_to_user_ret((drm_version_t *)arg, + if (copy_to_user((drm_version_t *)arg, &version, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; return 0; } @@ -477,7 +472,7 @@ int mga_open(struct inode *inode, struct file *filp) { drm_device_t *dev = &mga_device; int retcode = 0; - + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { #if LINUX_VERSION_CODE < 0x020333 @@ -508,22 +503,27 @@ int mga_release(struct inode *inode, struct file *filp) if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) && dev->lock.pid == current->pid) { mga_reclaim_buffers(dev, priv->pid); - DRM_ERROR("Process %d dead, freeing lock for context %d\n", - current->pid, - _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); + DRM_INFO("Process %d dead (ctx %d, d_s = 0x%02x)\n", + current->pid, + _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock), + dev->dev_private ? + ((drm_mga_private_t *)dev->dev_private) + ->dispatch_status + : 0); + + if (dev->dev_private) + ((drm_mga_private_t *)dev->dev_private) + ->dispatch_status &= MGA_IN_DISPATCH; + drm_lock_free(dev, &dev->lock.hw_lock->lock, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); - - /* FIXME: may require heavy-handed reset of - hardware at this point, possibly - processed via a callback to the X - server. */ } else if (dev->lock.hw_lock) { /* The lock is required to reclaim buffers */ DECLARE_WAITQUEUE(entry, current); add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ retcode = -EINTR; @@ -535,10 +535,9 @@ int mga_release(struct inode *inode, struct file *filp) dev->lock.lock_time = jiffies; atomic_inc(&dev->total_locks); break; /* Got lock */ - } + } /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; schedule(); if (signal_pending(current)) { retcode = -ERESTARTSYS; @@ -549,6 +548,9 @@ int mga_release(struct inode *inode, struct file *filp) remove_wait_queue(&dev->lock.lock_queue, &entry); if(!retcode) { mga_reclaim_buffers(dev, priv->pid); + if (dev->dev_private) + ((drm_mga_private_t *)dev->dev_private) + ->dispatch_status &= MGA_IN_DISPATCH; drm_lock_free(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT); } @@ -556,12 +558,19 @@ int mga_release(struct inode *inode, struct file *filp) drm_fasync(-1, filp, 0); down(&dev->struct_sem); + if (priv->remove_auth_on_close == 1) { + drm_file_t *temp = dev->file_first; + while(temp) { + temp->authenticated = 0; + temp = temp->next; + } + } if (priv->prev) priv->prev->next = priv->next; else dev->file_first = priv->next; if (priv->next) priv->next->prev = priv->prev; else dev->file_last = priv->prev; up(&dev->struct_sem); - + drm_free(priv, sizeof(*priv), DRM_MEM_FILES); #if LINUX_VERSION_CODE < 0x020333 MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */ @@ -602,9 +611,6 @@ int mga_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, atomic_inc(&dev->ioctl_count); atomic_inc(&dev->total_ioctl); ++priv->ioctl_count; - - DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", - current->pid, cmd, nr, dev->device, priv->authenticated); if (nr >= MGA_IOCTL_COUNT) { retcode = -EINVAL; @@ -613,7 +619,10 @@ int mga_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, func = ioctl->func; if (!func) { - DRM_DEBUG("no function\n"); + DRM_DEBUG("no function: pid = %d, cmd = 0x%02x," + " nr = 0x%02x, dev 0x%x, auth = %d\n", + current->pid, cmd, nr, dev->device, + priv->authenticated); retcode = -EINVAL; } else if ((ioctl->root_only && !capable(CAP_SYS_ADMIN)) || (ioctl->auth_needed && !priv->authenticated)) { @@ -622,7 +631,7 @@ int mga_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, retcode = (func)(inode, filp, cmd, arg); } } - + atomic_dec(&dev->ioctl_count); return retcode; } @@ -634,17 +643,15 @@ int mga_unlock(struct inode *inode, struct file *filp, unsigned int cmd, drm_device_t *dev = priv->dev; drm_lock_t lock; - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); - + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; + if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); return -EINVAL; } - DRM_DEBUG("%d frees lock (%d holds)\n", - lock.context, - _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); atomic_inc(&dev->total_unlocks); if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock)) atomic_inc(&dev->total_contends); @@ -652,9 +659,8 @@ int mga_unlock(struct inode *inode, struct file *filp, unsigned int cmd, mga_dma_schedule(dev, 1); if (drm_lock_free(dev, &dev->lock.hw_lock->lock, - DRM_KERNEL_CONTEXT)) { - DRM_ERROR("\n"); - } + DRM_KERNEL_CONTEXT)) DRM_ERROR("\n"); + unblock_all_signals(); return 0; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h index 101409cb2..e37cc2ef4 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h @@ -11,11 +11,11 @@ * 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 @@ -28,7 +28,6 @@ * Jeff Hartmann <jhartmann@valinux.com> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h,v 1.4 2000/08/28 02:43:15 tsi Exp $ */ #ifndef _MGA_DRV_H_ #define _MGA_DRV_H_ @@ -51,7 +50,7 @@ typedef struct { } drm_mga_prim_buf_t; typedef struct _drm_mga_freelist { - unsigned int age; + __volatile__ unsigned int age; drm_buf_t *buf; struct _drm_mga_freelist *next; struct _drm_mga_freelist *prev; @@ -83,6 +82,7 @@ typedef struct _drm_mga_private { int use_agp; drm_mga_warp_index_t WarpIndex[MGA_MAX_G400_PIPES]; unsigned int WarpPipe; + unsigned int vertexsize; atomic_t pending_bufs; void *status_page; unsigned long real_status_page; @@ -98,7 +98,7 @@ typedef struct _drm_mga_private { wait_queue_head_t wait_queue; /* Processes waiting until interrupt */ wait_queue_head_t buf_queue; /* Processes waiting for a free buf */ /* Some validated register values: - */ + */ u32 mAccess; } drm_mga_private_t; @@ -129,7 +129,6 @@ extern int mga_dma_init(struct inode *inode, struct file *filp, extern int mga_dma_cleanup(drm_device_t *dev); extern int mga_flush_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern void mga_flush_write_combine(void); extern unsigned int mga_create_sync_tag(drm_device_t *dev); extern drm_buf_t *mga_freelist_get(drm_device_t *dev); extern int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf); @@ -138,9 +137,9 @@ extern void mga_reclaim_buffers(drm_device_t *dev, pid_t pid); /* mga_bufs.c */ -extern int mga_addbufs(struct inode *inode, struct file *filp, +extern int mga_addbufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int mga_infobufs(struct inode *inode, struct file *filp, +extern int mga_infobufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int mga_markbufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); @@ -180,6 +179,7 @@ extern int mga_rmctx(struct inode *inode, struct file *filp, extern int mga_context_switch(drm_device_t *dev, int old, int new); extern int mga_context_switch_complete(drm_device_t *dev, int new); +#define mga_flush_write_combine() mb() typedef enum { TT_GENERAL, @@ -202,7 +202,7 @@ typedef struct { #define ISREG0(r) (r >= DWGREG0 && r <= DWGREG0_END) #define ADRINDEX0(r) (u8)((r - DWGREG0) >> 2) #define ADRINDEX1(r) (u8)(((r - DWGREG1) >> 2) | 0x80) -#define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r)) +#define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r)) #define MGA_VERBOSE 0 #define MGA_NUM_PRIM_BUFS 8 @@ -213,13 +213,12 @@ typedef struct { #define PRIM_OVERFLOW(dev, dev_priv, length) do { \ drm_mga_prim_buf_t *tmp_buf = \ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ - if( test_bit(MGA_BUF_NEEDS_OVERFLOW, \ - &tmp_buf->buffer_status)) { \ + if( test_bit(MGA_BUF_NEEDS_OVERFLOW, &tmp_buf->buffer_status)) { \ mga_advance_primary(dev); \ mga_dma_schedule(dev, 1); \ tmp_buf = dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ } else if( tmp_buf->max_dwords - tmp_buf->num_dwords < length || \ - tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \ + tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \ set_bit(MGA_BUF_FORCE_FIRE, &tmp_buf->buffer_status); \ mga_advance_primary(dev); \ mga_dma_schedule(dev, 1); \ @@ -296,7 +295,7 @@ drm_mga_prim_buf_t *tmp_buf = \ num_dwords + 1 + outcount, ADRINDEX(reg), val); \ if( ++outcount == 4) { \ outcount = 0; \ - dma_ptr[0] = *(u32 *)tempIndex; \ + dma_ptr[0] = *(unsigned long *)tempIndex; \ dma_ptr+=5; \ num_dwords += 5; \ } \ @@ -378,6 +377,72 @@ drm_mga_prim_buf_t *tmp_buf = \ #define MGAREG_YTOP 0x1c98 #define MGAREG_ZORG 0x1c0c +/* Warp registers */ +#define MGAREG_WR0 0x2d00 +#define MGAREG_WR1 0x2d04 +#define MGAREG_WR2 0x2d08 +#define MGAREG_WR3 0x2d0c +#define MGAREG_WR4 0x2d10 +#define MGAREG_WR5 0x2d14 +#define MGAREG_WR6 0x2d18 +#define MGAREG_WR7 0x2d1c +#define MGAREG_WR8 0x2d20 +#define MGAREG_WR9 0x2d24 +#define MGAREG_WR10 0x2d28 +#define MGAREG_WR11 0x2d2c +#define MGAREG_WR12 0x2d30 +#define MGAREG_WR13 0x2d34 +#define MGAREG_WR14 0x2d38 +#define MGAREG_WR15 0x2d3c +#define MGAREG_WR16 0x2d40 +#define MGAREG_WR17 0x2d44 +#define MGAREG_WR18 0x2d48 +#define MGAREG_WR19 0x2d4c +#define MGAREG_WR20 0x2d50 +#define MGAREG_WR21 0x2d54 +#define MGAREG_WR22 0x2d58 +#define MGAREG_WR23 0x2d5c +#define MGAREG_WR24 0x2d60 +#define MGAREG_WR25 0x2d64 +#define MGAREG_WR26 0x2d68 +#define MGAREG_WR27 0x2d6c +#define MGAREG_WR28 0x2d70 +#define MGAREG_WR29 0x2d74 +#define MGAREG_WR30 0x2d78 +#define MGAREG_WR31 0x2d7c +#define MGAREG_WR32 0x2d80 +#define MGAREG_WR33 0x2d84 +#define MGAREG_WR34 0x2d88 +#define MGAREG_WR35 0x2d8c +#define MGAREG_WR36 0x2d90 +#define MGAREG_WR37 0x2d94 +#define MGAREG_WR38 0x2d98 +#define MGAREG_WR39 0x2d9c +#define MGAREG_WR40 0x2da0 +#define MGAREG_WR41 0x2da4 +#define MGAREG_WR42 0x2da8 +#define MGAREG_WR43 0x2dac +#define MGAREG_WR44 0x2db0 +#define MGAREG_WR45 0x2db4 +#define MGAREG_WR46 0x2db8 +#define MGAREG_WR47 0x2dbc +#define MGAREG_WR48 0x2dc0 +#define MGAREG_WR49 0x2dc4 +#define MGAREG_WR50 0x2dc8 +#define MGAREG_WR51 0x2dcc +#define MGAREG_WR52 0x2dd0 +#define MGAREG_WR53 0x2dd4 +#define MGAREG_WR54 0x2dd8 +#define MGAREG_WR55 0x2ddc +#define MGAREG_WR56 0x2de0 +#define MGAREG_WR57 0x2de4 +#define MGAREG_WR58 0x2de8 +#define MGAREG_WR59 0x2dec +#define MGAREG_WR60 0x2df0 +#define MGAREG_WR61 0x2df4 +#define MGAREG_WR62 0x2df8 +#define MGAREG_WR63 0x2dfc + #define PDEA_pagpxfer_enable 0x2 #define WIA_wmode_suspend 0x0 @@ -397,8 +462,8 @@ drm_mga_prim_buf_t *tmp_buf = \ #define DC_atype_zi 0x30 #define DC_atype_blk 0x40 #define DC_atype_i 0x70 -#define DC_linear_xy 0x0 -#define DC_linear_linear 0x80 +#define DC_linear_xy 0x0 +#define DC_linear_linear 0x80 #define DC_zmode_nozcmp 0x0 #define DC_zmode_ze 0x200 #define DC_zmode_zne 0x300 @@ -406,16 +471,16 @@ drm_mga_prim_buf_t *tmp_buf = \ #define DC_zmode_zlte 0x500 #define DC_zmode_zgt 0x600 #define DC_zmode_zgte 0x700 -#define DC_solid_disable 0x0 -#define DC_solid_enable 0x800 -#define DC_arzero_disable 0x0 -#define DC_arzero_enable 0x1000 -#define DC_sgnzero_disable 0x0 -#define DC_sgnzero_enable 0x2000 -#define DC_shftzero_disable 0x0 -#define DC_shftzero_enable 0x4000 -#define DC_bop_SHIFT 16 -#define DC_trans_SHIFT 20 +#define DC_solid_disable 0x0 +#define DC_solid_enable 0x800 +#define DC_arzero_disable 0x0 +#define DC_arzero_enable 0x1000 +#define DC_sgnzero_disable 0x0 +#define DC_sgnzero_enable 0x2000 +#define DC_shftzero_disable 0x0 +#define DC_shftzero_enable 0x4000 +#define DC_bop_SHIFT 16 +#define DC_trans_SHIFT 20 #define DC_bltmod_bmonolef 0x0 #define DC_bltmod_bmonowf 0x8000000 #define DC_bltmod_bplan 0x2000000 @@ -424,21 +489,22 @@ drm_mga_prim_buf_t *tmp_buf = \ #define DC_bltmod_bu32rgb 0xe000000 #define DC_bltmod_bu24bgr 0x16000000 #define DC_bltmod_bu24rgb 0x1e000000 -#define DC_pattern_disable 0x0 -#define DC_pattern_enable 0x20000000 -#define DC_transc_disable 0x0 -#define DC_transc_enable 0x40000000 -#define DC_clipdis_disable 0x0 -#define DC_clipdis_enable 0x80000000 +#define DC_pattern_disable 0x0 +#define DC_pattern_enable 0x20000000 +#define DC_transc_disable 0x0 +#define DC_transc_enable 0x40000000 +#define DC_clipdis_disable 0x0 +#define DC_clipdis_enable 0x80000000 -#define SETADD_mode_vertlist 0x0 + +#define SETADD_mode_vertlist 0x0 #define MGA_CLEAR_CMD (DC_opcod_trap | DC_arzero_enable | \ DC_sgnzero_enable | DC_shftzero_enable | \ (0xC << DC_bop_SHIFT) | DC_clipdis_enable | \ DC_solid_enable | DC_transc_enable) - + #define MGA_COPY_CMD (DC_opcod_bitblt | DC_atype_rpl | DC_linear_xy | \ DC_solid_disable | DC_arzero_disable | \ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c index b4c164343..9bbd254c1 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c @@ -11,11 +11,11 @@ * 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 @@ -28,7 +28,6 @@ * Keith Whitwell <keithw@valinux.com> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c,v 1.5 2000/08/28 02:43:15 tsi Exp $ */ #define __NO_VERSION__ #include "drmP.h" @@ -39,13 +38,13 @@ * change these values */ -#define MGAEMITCLIP_SIZE 10 -#define MGAEMITCTX_SIZE 15 -#define MGAG200EMITTEX_SIZE 20 -#define MGAG400EMITTEX0_SIZE 30 -#define MGAG400EMITTEX1_SIZE 25 -#define MGAG400EMITPIPE_SIZE 50 -#define MGAG200EMITPIPE_SIZE 15 +#define MGAEMITCLIP_SIZE 10 +#define MGAEMITCTX_SIZE 20 +#define MGAG200EMITTEX_SIZE 20 +#define MGAG400EMITTEX0_SIZE 30 +#define MGAG400EMITTEX1_SIZE 25 +#define MGAG400EMITPIPE_SIZE 50 +#define MGAG200EMITPIPE_SIZE 15 #define MAX_STATE_SIZE ((MGAEMITCLIP_SIZE * MGA_NR_SAREA_CLIPRECTS) + \ MGAEMITCTX_SIZE + MGAG400EMITTEX0_SIZE + \ @@ -57,24 +56,24 @@ static void mgaEmitClipRect(drm_mga_private_t * dev_priv, drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->ContextState; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); /* This takes 10 dwords */ PRIMGETPTR(dev_priv); - /* Force reset of dwgctl (eliminates clip disable) */ + /* Force reset of dwgctl on G400 (eliminates clip disable bit) */ + if (dev_priv->chipset == MGA_CARD_TYPE_G400) { #if 0 - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DWGSYNC, 0); - PRIMOUTREG(MGAREG_DWGSYNC, 0); - PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DWGSYNC, 0); + PRIMOUTREG(MGAREG_DWGSYNC, 0); + PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); #else - PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); - PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000); - PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); - PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000); + PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000); + PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000); #endif - + } PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_CXBNDRY, ((box->x2) << 16) | (box->x1)); PRIMOUTREG(MGAREG_YTOP, box->y1 * dev_priv->stride / dev_priv->cpp); @@ -88,9 +87,8 @@ static void mgaEmitContext(drm_mga_private_t * dev_priv) drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->ContextState; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); - /* This takes a max of 15 dwords */ + /* This takes a max of 20 dwords */ PRIMGETPTR(dev_priv); PRIMOUTREG(MGAREG_DSTORG, regs[MGA_CTXREG_DSTORG]); @@ -108,6 +106,11 @@ static void mgaEmitContext(drm_mga_private_t * dev_priv) PRIMOUTREG(MGAREG_TDUALSTAGE0, regs[MGA_CTXREG_TDUAL0]); PRIMOUTREG(MGAREG_TDUALSTAGE1, regs[MGA_CTXREG_TDUAL1]); PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]); + + PRIMOUTREG(MGAREG_STENCIL, regs[MGA_CTXREG_STENCIL]); + PRIMOUTREG(MGAREG_STENCILCTL, regs[MGA_CTXREG_STENCILCTL]); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); } else { PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]); PRIMOUTREG(MGAREG_DMAPAD, 0); @@ -123,7 +126,6 @@ static void mgaG200EmitTex(drm_mga_private_t * dev_priv) drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->TexState[0]; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); PRIMGETPTR(dev_priv); @@ -142,9 +144,9 @@ static void mgaG200EmitTex(drm_mga_private_t * dev_priv) PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]); PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]); PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]); - PRIMOUTREG(0x2d00 + 24 * 4, regs[MGA_TEXREG_WIDTH]); + PRIMOUTREG(MGAREG_WR24, regs[MGA_TEXREG_WIDTH]); - PRIMOUTREG(0x2d00 + 34 * 4, regs[MGA_TEXREG_HEIGHT]); + PRIMOUTREG(MGAREG_WR34, regs[MGA_TEXREG_HEIGHT]); PRIMOUTREG(MGAREG_TEXTRANS, 0xffff); PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff); PRIMOUTREG(MGAREG_DMAPAD, 0); @@ -152,17 +154,17 @@ static void mgaG200EmitTex(drm_mga_private_t * dev_priv) PRIMADVANCE(dev_priv); } +#define TMC_dualtex_enable 0x80 + static void mgaG400EmitTex0(drm_mga_private_t * dev_priv) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->TexState[0]; - int multitex = sarea_priv->WarpPipe & MGA_T2; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); PRIMGETPTR(dev_priv); - /* This takes a max of 30 dwords */ + /* This takes 30 dwords */ PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | 0x00008000); PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL]); @@ -177,22 +179,20 @@ static void mgaG400EmitTex0(drm_mga_private_t * dev_priv) PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]); PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]); PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]); - PRIMOUTREG(0x2d00 + 49 * 4, 0); + PRIMOUTREG(MGAREG_WR49, 0); - PRIMOUTREG(0x2d00 + 57 * 4, 0); - PRIMOUTREG(0x2d00 + 53 * 4, 0); - PRIMOUTREG(0x2d00 + 61 * 4, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_WR57, 0); + PRIMOUTREG(MGAREG_WR53, 0); + PRIMOUTREG(MGAREG_WR61, 0); + PRIMOUTREG(MGAREG_WR52, 0x40); - if (!multitex) { - PRIMOUTREG(0x2d00 + 52 * 4, 0x40); - PRIMOUTREG(0x2d00 + 60 * 4, 0x40); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); - } + PRIMOUTREG(MGAREG_WR60, 0x40); + PRIMOUTREG(MGAREG_WR54, regs[MGA_TEXREG_WIDTH] | 0x40); + PRIMOUTREG(MGAREG_WR62, regs[MGA_TEXREG_HEIGHT] | 0x40); + PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(0x2d00 + 54 * 4, regs[MGA_TEXREG_WIDTH] | 0x40); - PRIMOUTREG(0x2d00 + 62 * 4, regs[MGA_TEXREG_HEIGHT] | 0x40); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_TEXTRANS, 0xffff); PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff); @@ -206,7 +206,6 @@ static void mgaG400EmitTex1(drm_mga_private_t * dev_priv) drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->TexState[1]; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); PRIMGETPTR(dev_priv); @@ -226,14 +225,14 @@ static void mgaG400EmitTex1(drm_mga_private_t * dev_priv) PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]); PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]); PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]); - PRIMOUTREG(0x2d00 + 49 * 4, 0); + PRIMOUTREG(MGAREG_WR49, 0); - PRIMOUTREG(0x2d00 + 57 * 4, 0); - PRIMOUTREG(0x2d00 + 53 * 4, 0); - PRIMOUTREG(0x2d00 + 61 * 4, 0); - PRIMOUTREG(0x2d00 + 52 * 4, regs[MGA_TEXREG_WIDTH] | 0x40); + PRIMOUTREG(MGAREG_WR57, 0); + PRIMOUTREG(MGAREG_WR53, 0); + PRIMOUTREG(MGAREG_WR61, 0); + PRIMOUTREG(MGAREG_WR52, regs[MGA_TEXREG_WIDTH] | 0x40); - PRIMOUTREG(0x2d00 + 60 * 4, regs[MGA_TEXREG_HEIGHT] | 0x40); + PRIMOUTREG(MGAREG_WR60, regs[MGA_TEXREG_HEIGHT] | 0x40); PRIMOUTREG(MGAREG_TEXTRANS, 0xffff); PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff); PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | 0x00008000); @@ -241,13 +240,16 @@ static void mgaG400EmitTex1(drm_mga_private_t * dev_priv) PRIMADVANCE(dev_priv); } +#define MAGIC_FPARAM_HEX_VALUE 0x46480000 +/* This is the hex value of 12800.0f which is a magic value we must + * set in wr56. + */ + static void mgaG400EmitPipe(drm_mga_private_t * dev_priv) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int pipe = sarea_priv->WarpPipe; - float fParam = 12800.0f; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); PRIMGETPTR(dev_priv); @@ -279,14 +281,14 @@ static void mgaG400EmitPipe(drm_mga_private_t * dev_priv) PRIMOUTREG(MGAREG_DWGCTL, MGA_FLUSH_CMD); PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 1); - PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DWGSYNC, 0x7000); - PRIMOUTREG(MGAREG_DMAPAD, 0); - - PRIMOUTREG(MGAREG_TEXCTL2, 0 | 0x00008000); + PRIMOUTREG(MGAREG_TEXCTL2, 0x00008000); PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); + PRIMOUTREG(MGAREG_TEXCTL2, 0x80 | 0x00008000); PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); } PRIMOUTREG(MGAREG_WVRTXSZ, 0x00001807); @@ -302,18 +304,18 @@ static void mgaG400EmitPipe(drm_mga_private_t * dev_priv) PRIMOUTREG(MGAREG_WFLAG, 0); PRIMOUTREG(MGAREG_WFLAG1, 0); - PRIMOUTREG(0x2d00 + 56 * 4, *((u32 *) (&fParam))); + PRIMOUTREG(MGAREG_WR56, MAGIC_FPARAM_HEX_VALUE); PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(0x2d00 + 49 * 4, 0); /* Tex stage 0 */ - PRIMOUTREG(0x2d00 + 57 * 4, 0); /* Tex stage 0 */ - PRIMOUTREG(0x2d00 + 53 * 4, 0); /* Tex stage 1 */ - PRIMOUTREG(0x2d00 + 61 * 4, 0); /* Tex stage 1 */ + PRIMOUTREG(MGAREG_WR49, 0); /* Tex stage 0 */ + PRIMOUTREG(MGAREG_WR57, 0); /* Tex stage 0 */ + PRIMOUTREG(MGAREG_WR53, 0); /* Tex stage 1 */ + PRIMOUTREG(MGAREG_WR61, 0); /* Tex stage 1 */ - PRIMOUTREG(0x2d00 + 54 * 4, 0x40); /* Tex stage 0 : w */ - PRIMOUTREG(0x2d00 + 62 * 4, 0x40); /* Tex stage 0 : h */ - PRIMOUTREG(0x2d00 + 52 * 4, 0x40); /* Tex stage 1 : w */ - PRIMOUTREG(0x2d00 + 60 * 4, 0x40); /* Tex stage 1 : h */ + PRIMOUTREG(MGAREG_WR54, 0x40); /* Tex stage 0 : w */ + PRIMOUTREG(MGAREG_WR62, 0x40); /* Tex stage 0 : h */ + PRIMOUTREG(MGAREG_WR52, 0x40); /* Tex stage 1 : w */ + PRIMOUTREG(MGAREG_WR60, 0x40); /* Tex stage 1 : h */ /* Dma pading required due to hw bug */ PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); @@ -330,7 +332,6 @@ static void mgaG200EmitPipe(drm_mga_private_t * dev_priv) drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int pipe = sarea_priv->WarpPipe; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); PRIMGETPTR(dev_priv); @@ -339,12 +340,12 @@ static void mgaG200EmitPipe(drm_mga_private_t * dev_priv) PRIMOUTREG(MGAREG_WIADDR, WIA_wmode_suspend); PRIMOUTREG(MGAREG_WVRTXSZ, 7); PRIMOUTREG(MGAREG_WFLAG, 0); - PRIMOUTREG(0x2d00 + 24 * 4, 0); /* tex w/h */ + PRIMOUTREG(MGAREG_WR24, 0); /* tex w/h */ - PRIMOUTREG(0x2d00 + 25 * 4, 0x100); - PRIMOUTREG(0x2d00 + 34 * 4, 0); /* tex w/h */ - PRIMOUTREG(0x2d00 + 42 * 4, 0xFFFF); - PRIMOUTREG(0x2d00 + 60 * 4, 0xFFFF); + PRIMOUTREG(MGAREG_WR25, 0x100); + PRIMOUTREG(MGAREG_WR34, 0); /* tex w/h */ + PRIMOUTREG(MGAREG_WR42, 0xFFFF); + PRIMOUTREG(MGAREG_WR60, 0xFFFF); /* Dma pading required due to hw bug */ PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); @@ -361,7 +362,6 @@ static void mgaEmitState(drm_mga_private_t * dev_priv) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int dirty = sarea_priv->dirty; - DRM_DEBUG("%s\n", __FUNCTION__); if (dev_priv->chipset == MGA_CARD_TYPE_G400) { int multitex = sarea_priv->WarpPipe & MGA_T2; @@ -403,7 +403,6 @@ static void mgaEmitState(drm_mga_private_t * dev_priv) } } - /* Disallow all write destinations except the front and backbuffer. */ static int mgaVerifyContext(drm_mga_private_t * dev_priv) @@ -411,8 +410,6 @@ static int mgaVerifyContext(drm_mga_private_t * dev_priv) drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->ContextState; - DRM_DEBUG("%s\n", __FUNCTION__); - if (regs[MGA_CTXREG_DSTORG] != dev_priv->frontOffset && regs[MGA_CTXREG_DSTORG] != dev_priv->backOffset) { DRM_DEBUG("BAD DSTORG: %x (front %x, back %x)\n\n", @@ -431,8 +428,6 @@ static int mgaVerifyTex(drm_mga_private_t * dev_priv, int unit) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; - DRM_DEBUG("%s\n", __FUNCTION__); - if ((sarea_priv->TexState[unit][MGA_TEXREG_ORG] & 0x3) == 0x1) { DRM_DEBUG("BAD TEXREG_ORG: %x, unit %d\n", sarea_priv->TexState[unit][MGA_TEXREG_ORG], @@ -450,8 +445,6 @@ static int mgaVerifyState(drm_mga_private_t * dev_priv) unsigned int dirty = sarea_priv->dirty; int rv = 0; - DRM_DEBUG("%s\n", __FUNCTION__); - if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS) sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS; @@ -479,8 +472,6 @@ static int mgaVerifyIload(drm_mga_private_t * dev_priv, unsigned long bus_address, unsigned int dstOrg, int length) { - DRM_DEBUG("%s\n", __FUNCTION__); - if (dstOrg < dev_priv->textureOffset || dstOrg + length > (dev_priv->textureOffset + dev_priv->textureSize)) { @@ -503,7 +494,6 @@ static void mga_dma_dispatch_tex_blit(drm_device_t * dev, int use_agp = PDEA_pagpxfer_enable | 0x00000001; u16 y2; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); y2 = length / 64; @@ -511,7 +501,6 @@ static void mga_dma_dispatch_tex_blit(drm_device_t * dev, PRIMOUTREG(MGAREG_DSTORG, destOrg); PRIMOUTREG(MGAREG_MACCESS, 0x00000000); - DRM_DEBUG("srcorg : %lx\n", bus_address | use_agp); PRIMOUTREG(MGAREG_SRCORG, (u32) bus_address | use_agp); PRIMOUTREG(MGAREG_AR5, 64); @@ -525,10 +514,10 @@ static void mga_dma_dispatch_tex_blit(drm_device_t * dev, PRIMOUTREG(MGAREG_FXBNDRY, (63 << 16)); PRIMOUTREG(MGAREG_YDSTLEN + MGAREG_MGA_EXEC, y2); + PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_SRCORG, 0); PRIMOUTREG(MGAREG_PITCH, dev_priv->stride / dev_priv->cpp); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DWGSYNC, 0x7000); PRIMADVANCE(dev_priv); } @@ -542,34 +531,22 @@ static void mga_dma_dispatch_vertex(drm_device_t * dev, drm_buf_t * buf) int use_agp = PDEA_pagpxfer_enable; int i = 0; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); - - DRM_DEBUG("dispatch vertex %d addr 0x%lx, " - "length 0x%x nbox %d dirty %x\n", - buf->idx, address, length, - sarea_priv->nbox, sarea_priv->dirty); - - DRM_DEBUG("used : %d, total : %d\n", buf->used, buf->total); if (buf->used) { /* WARNING: if you change any of the state functions verify - * these numbers (Overestimating this doesn't hurt). + * these numbers (Overestimating this doesn't hurt). */ buf_priv->dispatched = 1; PRIM_OVERFLOW(dev, dev_priv, (MAX_STATE_SIZE + (5 * MGA_NR_SAREA_CLIPRECTS))); mgaEmitState(dev_priv); + +#if 0 + length = dev_priv->vertexsize * 3 * 4; +#endif + do { if (i < sarea_priv->nbox) { - DRM_DEBUG("idx %d Emit box %d/%d:" - "%d,%d - %d,%d\n", - buf->idx, - i, sarea_priv->nbox, - sarea_priv->boxes[i].x1, - sarea_priv->boxes[i].y1, - sarea_priv->boxes[i].x2, - sarea_priv->boxes[i].y2); - mgaEmitClipRect(dev_priv, &sarea_priv->boxes[i]); } @@ -606,16 +583,10 @@ static void mga_dma_dispatch_indices(drm_device_t * dev, int use_agp = PDEA_pagpxfer_enable; int i = 0; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); - - DRM_DEBUG("dispatch indices %d addr 0x%x, " - "start 0x%x end 0x%x nbox %d dirty %x\n", - buf->idx, address, start, end, - sarea_priv->nbox, sarea_priv->dirty); if (start != end) { /* WARNING: if you change any of the state functions verify - * these numbers (Overestimating this doesn't hurt). + * these numbers (Overestimating this doesn't hurt). */ buf_priv->dispatched = 1; PRIM_OVERFLOW(dev, dev_priv, @@ -624,15 +595,6 @@ static void mga_dma_dispatch_indices(drm_device_t * dev, do { if (i < sarea_priv->nbox) { - DRM_DEBUG("idx %d Emit box %d/%d:" - "%d,%d - %d,%d\n", - buf->idx, - i, sarea_priv->nbox, - sarea_priv->boxes[i].x1, - sarea_priv->boxes[i].y1, - sarea_priv->boxes[i].x2, - sarea_priv->boxes[i].y2); - mgaEmitClipRect(dev_priv, &sarea_priv->boxes[i]); } @@ -645,6 +607,7 @@ static void mga_dma_dispatch_indices(drm_device_t * dev, SETADD_mode_vertlist)); PRIMOUTREG(MGAREG_SETUPEND, ((address + end) | use_agp)); +/* ((address + start + 12) | use_agp)); */ PRIMADVANCE(dev_priv); } while (++i < sarea_priv->nbox); } @@ -659,7 +622,9 @@ static void mga_dma_dispatch_indices(drm_device_t * dev, static void mga_dma_dispatch_clear(drm_device_t * dev, int flags, unsigned int clear_color, - unsigned int clear_zval) + unsigned int clear_zval, + unsigned int clear_colormask, + unsigned int clear_depthmask) { drm_mga_private_t *dev_priv = dev->dev_private; drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; @@ -669,7 +634,6 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags, unsigned int cmd; int i; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); if (dev_priv->sgram) cmd = MGA_CLEAR_CMD | DC_atype_blk; @@ -681,14 +645,9 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags, for (i = 0; i < nbox; i++) { unsigned int height = pbox[i].y2 - pbox[i].y1; - DRM_DEBUG("dispatch clear %d,%d-%d,%d flags %x!\n", - pbox[i].x1, pbox[i].y1, pbox[i].x2, - pbox[i].y2, flags); - if (flags & MGA_FRONT) { - DRM_DEBUG("clear front\n"); - PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_PLNWT, clear_colormask); PRIMOUTREG(MGAREG_YDSTLEN, (pbox[i].y1 << 16) | height); PRIMOUTREG(MGAREG_FXBNDRY, @@ -701,9 +660,8 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags, } if (flags & MGA_BACK) { - DRM_DEBUG("clear back\n"); - PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_PLNWT, clear_colormask); PRIMOUTREG(MGAREG_YDSTLEN, (pbox[i].y1 << 16) | height); PRIMOUTREG(MGAREG_FXBNDRY, @@ -716,9 +674,8 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags, } if (flags & MGA_DEPTH) { - DRM_DEBUG("clear depth\n"); - PRIMOUTREG(MGAREG_DMAPAD, 0); PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_PLNWT, clear_depthmask); PRIMOUTREG(MGAREG_YDSTLEN, (pbox[i].y1 << 16) | height); PRIMOUTREG(MGAREG_FXBNDRY, @@ -750,7 +707,6 @@ static void mga_dma_dispatch_swap(drm_device_t * dev) int pixel_stride = dev_priv->stride / dev_priv->cpp; PRIMLOCALS; - DRM_DEBUG("%s\n", __FUNCTION__); PRIM_OVERFLOW(dev, dev_priv, (MGA_NR_SAREA_CLIPRECTS * 5) + 20); @@ -773,9 +729,6 @@ static void mga_dma_dispatch_swap(drm_device_t * dev) unsigned int h = pbox[i].y2 - pbox[i].y1; unsigned int start = pbox[i].y1 * pixel_stride; - DRM_DEBUG("dispatch swap %d,%d-%d,%d!\n", - pbox[i].x1, pbox[i].y1, pbox[i].x2, pbox[i].y2); - PRIMOUTREG(MGAREG_AR0, start + pbox[i].x2 - 1); PRIMOUTREG(MGAREG_AR3, start + pbox[i].x1); PRIMOUTREG(MGAREG_FXBNDRY, @@ -803,9 +756,8 @@ int mga_clear_bufs(struct inode *inode, struct file *filp, drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; drm_mga_clear_t clear; - copy_from_user_ret(&clear, (drm_mga_clear_t *) arg, sizeof(clear), - -EFAULT); - DRM_DEBUG("%s\n", __FUNCTION__); + if (copy_from_user(&clear, (drm_mga_clear_t *) arg, sizeof(clear))) + return -EFAULT; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("mga_clear_bufs called without lock held\n"); @@ -819,7 +771,10 @@ int mga_clear_bufs(struct inode *inode, struct file *filp, */ dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CTX; mga_dma_dispatch_clear(dev, clear.flags, - clear.clear_color, clear.clear_depth); + clear.clear_color, + clear.clear_depth, + clear.clear_color_mask, + clear.clear_depth_mask); PRIMUPDATE(dev_priv); mga_flush_write_combine(); mga_dma_schedule(dev, 1); @@ -834,7 +789,6 @@ int mga_swap_bufs(struct inode *inode, struct file *filp, drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; - DRM_DEBUG("%s\n", __FUNCTION__); if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("mga_swap_bufs called without lock held\n"); @@ -869,11 +823,9 @@ int mga_iload(struct inode *inode, struct file *filp, drm_mga_buf_priv_t *buf_priv; drm_mga_iload_t iload; unsigned long bus_address; - DRM_DEBUG("%s\n", __FUNCTION__); - DRM_DEBUG("Starting Iload\n"); - copy_from_user_ret(&iload, (drm_mga_iload_t *) arg, sizeof(iload), - -EFAULT); + if (copy_from_user(&iload, (drm_mga_iload_t *) arg, sizeof(iload))) + return -EFAULT; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("mga_iload called without lock held\n"); @@ -883,8 +835,6 @@ int mga_iload(struct inode *inode, struct file *filp, buf = dma->buflist[iload.idx]; buf_priv = buf->dev_private; bus_address = buf->bus_address; - DRM_DEBUG("bus_address %lx, length %d, destorg : %x\n", - bus_address, iload.length, iload.destOrg); if (mgaVerifyIload(dev_priv, bus_address, iload.destOrg, iload.length)) { @@ -915,18 +865,15 @@ int mga_vertex(struct inode *inode, struct file *filp, drm_buf_t *buf; drm_mga_buf_priv_t *buf_priv; drm_mga_vertex_t vertex; - DRM_DEBUG("%s\n", __FUNCTION__); - copy_from_user_ret(&vertex, (drm_mga_vertex_t *) arg, - sizeof(vertex), -EFAULT); + if (copy_from_user(&vertex, (drm_mga_vertex_t *) arg, sizeof(vertex))) + return -EFAULT; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("mga_vertex called without lock held\n"); return -EINVAL; } - DRM_DEBUG("mga_vertex\n"); - buf = dma->buflist[vertex.idx]; buf_priv = buf->dev_private; @@ -940,7 +887,6 @@ int mga_vertex(struct inode *inode, struct file *filp, buf_priv->dispatched = 0; mga_freelist_put(dev, buf); } - DRM_DEBUG("bad state\n"); return -EINVAL; } @@ -964,18 +910,16 @@ int mga_indices(struct inode *inode, struct file *filp, drm_buf_t *buf; drm_mga_buf_priv_t *buf_priv; drm_mga_indices_t indices; - DRM_DEBUG("%s\n", __FUNCTION__); - copy_from_user_ret(&indices, (drm_mga_indices_t *) arg, - sizeof(indices), -EFAULT); + if (copy_from_user(&indices, + (drm_mga_indices_t *)arg, sizeof(indices))) + return -EFAULT; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("mga_indices called without lock held\n"); return -EINVAL; } - DRM_DEBUG("mga_indices\n"); - buf = dma->buflist[indices.idx]; buf_priv = buf->dev_private; @@ -1005,17 +949,18 @@ static int mga_dma_get_buffers(drm_device_t * dev, drm_dma_t * d) { int i; drm_buf_t *buf; - DRM_DEBUG("%s\n", __FUNCTION__); for (i = d->granted_count; i < d->request_count; i++) { buf = mga_freelist_get(dev); if (!buf) break; buf->pid = current->pid; - copy_to_user_ret(&d->request_indices[i], - &buf->idx, sizeof(buf->idx), -EFAULT); - copy_to_user_ret(&d->request_sizes[i], - &buf->total, sizeof(buf->total), -EFAULT); + if (copy_to_user(&d->request_indices[i], + &buf->idx, sizeof(buf->idx))) + return -EFAULT; + if (copy_to_user(&d->request_sizes[i], + &buf->total, sizeof(buf->total))) + return -EFAULT; ++d->granted_count; } return 0; @@ -1029,11 +974,9 @@ int mga_dma(struct inode *inode, struct file *filp, unsigned int cmd, drm_device_dma_t *dma = dev->dma; int retcode = 0; drm_dma_t d; - DRM_DEBUG("%s\n", __FUNCTION__); - copy_from_user_ret(&d, (drm_dma_t *) arg, sizeof(d), -EFAULT); - DRM_DEBUG("%d %d: %d send, %d req\n", - current->pid, d.context, d.send_count, d.request_count); + if (copy_from_user(&d, (drm_dma_t *) arg, sizeof(d))) + return -EFAULT; if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("mga_dma called without lock held\n"); @@ -1064,8 +1007,7 @@ int mga_dma(struct inode *inode, struct file *filp, unsigned int cmd, retcode = mga_dma_get_buffers(dev, &d); } - DRM_DEBUG("%d returning, granted = %d\n", - current->pid, d.granted_count); - copy_to_user_ret((drm_dma_t *) arg, &d, sizeof(d), -EFAULT); + if (copy_to_user((drm_dma_t *) arg, &d, sizeof(d))) + return -EFAULT; return retcode; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c index 6053a9477..77519a561 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c @@ -1,3 +1,5 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c,v 1.3 2000/09/01 02:31:40 tsi Exp $ */ + #include <linux/config.h> #include <linux/version.h> @@ -5,6 +7,10 @@ #define CONFIG_SMP 0 #endif +#ifndef CONFIG_MODULES +#define CONFIG_MODULES 0 +#endif + #ifndef CONFIG_MODVERSIONS #define CONFIG_MODVERSIONS 0 #endif @@ -22,6 +28,7 @@ #endif SMP = CONFIG_SMP +MODULES = CONFIG_MODULES MODVERSIONS = CONFIG_MODVERSIONS AGP = CONFIG_AGP AGP_MODULE = CONFIG_AGP_MODULE diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c index 94ee806ca..7ae498014 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c @@ -28,7 +28,6 @@ * Kevin E. Martin <martin@valinux.com> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c,v 1.3 2000/08/28 02:43:16 tsi Exp $ */ #include <linux/config.h> #include "drmP.h" @@ -36,7 +35,7 @@ #define R128_NAME "r128" #define R128_DESC "ATI Rage 128" -#define R128_DATE "20000719" +#define R128_DATE "20000928" #define R128_MAJOR 1 #define R128_MINOR 0 #define R128_PATCHLEVEL 0 @@ -421,17 +420,18 @@ int r128_version(struct inode *inode, struct file *filp, unsigned int cmd, drm_version_t version; int len; - copy_from_user_ret(&version, + if (copy_from_user(&version, (drm_version_t *)arg, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; #define DRM_COPY(name,value) \ len = strlen(value); \ if (len > name##_len) len = name##_len; \ name##_len = strlen(value); \ if (len && name) { \ - copy_to_user_ret(name, value, len, -EFAULT); \ + if (copy_to_user(name, value, len)) \ + return -EFAULT; \ } version.version_major = R128_MAJOR; @@ -442,10 +442,10 @@ int r128_version(struct inode *inode, struct file *filp, unsigned int cmd, DRM_COPY(version.date, R128_DATE); DRM_COPY(version.desc, R128_DESC); - copy_to_user_ret((drm_version_t *)arg, + if (copy_to_user((drm_version_t *)arg, &version, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; return 0; } @@ -467,7 +467,7 @@ int r128_open(struct inode *inode, struct file *filp) } spin_unlock(&dev->count_lock); } - + return retcode; } @@ -501,7 +501,7 @@ int r128_release(struct inode *inode, struct file *filp) } spin_unlock(&dev->count_lock); } - + unlock_kernel(); return retcode; } @@ -560,7 +560,8 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd, dev->lck_start = start = get_cycles(); #endif - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", @@ -601,6 +602,7 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd, #endif add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ ret = -EINTR; @@ -616,7 +618,6 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd, /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; #if 1 current->policy |= SCHED_YIELD; #endif @@ -657,6 +658,14 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd, #endif if (!ret) { + sigemptyset(&dev->sigmask); + sigaddset(&dev->sigmask, SIGSTOP); + sigaddset(&dev->sigmask, SIGTSTP); + sigaddset(&dev->sigmask, SIGTTIN); + sigaddset(&dev->sigmask, SIGTTOU); + dev->sigdata.context = lock.context; + dev->sigdata.lock = dev->lock.hw_lock; + block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); if (lock.flags & _DRM_LOCK_READY) { /* Wait for space in DMA/FIFO */ } @@ -691,7 +700,8 @@ int r128_unlock(struct inode *inode, struct file *filp, unsigned int cmd, drm_device_t *dev = priv->dev; drm_lock_t lock; - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", @@ -720,6 +730,6 @@ int r128_unlock(struct inode *inode, struct file *filp, unsigned int cmd, current->priority = DEF_PRIORITY; } #endif - + unblock_all_signals(); return 0; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h index da2f676d3..63b98c727 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h @@ -197,7 +197,7 @@ extern int r128_context_switch_complete(drm_device_t *dev, int new); #define R128_MAX_USEC_TIMEOUT 100000 /* 100 ms */ -#define R128_BASE(reg) ((unsigned long)(dev_priv->mmio->handle)) +#define R128_BASE(reg) ((u32)(dev_priv->mmio->handle)) #define R128_ADDR(reg) (R128_BASE(reg) + reg) #define R128_DEREF(reg) *(__volatile__ int *)R128_ADDR(reg) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c index e13bd8531..f2fdf6dd3 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c @@ -30,7 +30,6 @@ * Sung-Ching Lin <sclin@sis.com.tw> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c,v 1.3 2000/09/22 11:35:47 alanh Exp $ */ #define __NO_VERSION__ #include "drmP.h" diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drm.h new file mode 100644 index 000000000..73807f317 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drm.h @@ -0,0 +1,31 @@ + +#ifndef _sis_drm_public_h_ +#define _sis_drm_public_h_ + +typedef struct { + int context; + unsigned int offset; + unsigned int size; + unsigned int free; +} drm_sis_mem_t; + +typedef struct { + unsigned int offset, size; +} drm_sis_agp_t; + +typedef struct { + unsigned int left, right; +} drm_sis_flip_t; + +#define SIS_IOCTL_FB_ALLOC DRM_IOWR( 0x44, drm_sis_mem_t) +#define SIS_IOCTL_FB_FREE DRM_IOW( 0x45, drm_sis_mem_t) + +#define SIS_IOCTL_AGP_INIT DRM_IOWR( 0x53, drm_sis_agp_t) +#define SIS_IOCTL_AGP_ALLOC DRM_IOWR( 0x54, drm_sis_mem_t) +#define SIS_IOCTL_AGP_FREE DRM_IOW( 0x55, drm_sis_mem_t) + +#define SIS_IOCTL_FLIP DRM_IOW( 0x48, drm_sis_flip_t) +#define SIS_IOCTL_FLIP_INIT DRM_IO( 0x49) +#define SIS_IOCTL_FLIP_FINAL DRM_IO( 0x50) + +#endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c index c5103d583..2f98e3221 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c @@ -1,5 +1,4 @@ -/* sis_drv.c -- sis driver -*- linux-c -*- - * Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com +/* sis.c -- sis driver -*- linux-c -*- * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. @@ -23,18 +22,12 @@ * 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. (Rik) Faith <faith@valinux.com> - * Daryll Strauss <daryll@valinux.com> - * Sung-Ching Lin <sclin@sis.com.tw> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c,v 1.5 2000/09/22 11:35:47 alanh Exp $ */ #include <linux/config.h> #include "drmP.h" -#include "sis_drm_public.h" +#include "sis_drm.h" #include "sis_drv.h" #define SIS_NAME "sis" @@ -581,6 +574,7 @@ int sis_lock(struct inode *inode, struct file *filp, unsigned int cmd, #endif add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ ret = -EINTR; @@ -596,7 +590,6 @@ int sis_lock(struct inode *inode, struct file *filp, unsigned int cmd, /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; #if 1 current->policy |= SCHED_YIELD; #endif @@ -637,6 +630,15 @@ int sis_lock(struct inode *inode, struct file *filp, unsigned int cmd, #endif if (!ret) { + sigemptyset(&dev->sigmask); + sigaddset(&dev->sigmask, SIGSTOP); + sigaddset(&dev->sigmask, SIGTSTP); + sigaddset(&dev->sigmask, SIGTTIN); + sigaddset(&dev->sigmask, SIGTTOU); + dev->sigdata.context = lock.context; + dev->sigdata.lock = dev->lock.hw_lock; + block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); + if (lock.flags & _DRM_LOCK_READY) { /* Wait for space in DMA/FIFO */ } @@ -648,12 +650,6 @@ int sis_lock(struct inode *inode, struct file *filp, unsigned int cmd, } } -#if LINUX_VERSION_CODE < 0x020400 - if (lock.context != sis_res_ctx.handle) { - current->counter = 5; - current->priority = DEF_PRIORITY/4; - } -#endif DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); #if DRM_DMA_HISTOGRAM @@ -694,12 +690,6 @@ int sis_unlock(struct inode *inode, struct file *filp, unsigned int cmd, } } -#if LINUX_VERSION_CODE < 0x020400 - if (lock.context != sis_res_ctx.handle) { - current->counter = 5; - current->priority = DEF_PRIORITY; - } -#endif - + unblock_all_signals(); return 0; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h index 496c5655d..8c4e29108 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h @@ -1,5 +1,4 @@ /* sis_drv.h -- Private header for sis driver -*- linux-c -*- - * Created: Thu Oct 7 10:40:04 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. @@ -24,13 +23,7 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Authors: - * Rickard E. (Rik) Faith <faith@valinux.com> - * Daryll Strauss <daryll@valinux.com> - * Sung-Ching Lin <sclin@sis.com.tw> - * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h,v 1.3 2000/09/22 11:35:47 alanh Exp $ */ #ifndef _SIS_DRV_H_ #define _SIS_DRV_H_ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c index a946a41f1..6143ad83a 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c @@ -27,7 +27,6 @@ * Sung-Ching Lin <sclin@sis.com.tw> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c,v 1.2 2000/09/22 11:35:47 alanh Exp $ */ #define __NO_VERSION__ #include <linux/module.h> @@ -163,7 +162,6 @@ int setDestroy(set_t *set) * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c,v 1.2 2000/09/22 11:35:47 alanh Exp $ */ #define ISFREE(bptr) ((bptr)->free) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h index 59d58b8c6..c3367dba7 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h @@ -27,7 +27,6 @@ * Sung-Ching Lin <sclin@sis.com.tw> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h,v 1.3 2000/09/22 11:35:47 alanh Exp $ */ #ifndef _sis_ds_h_ #define _sis_ds_h_ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c index 1d909785e..e6e8ed7dd 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c @@ -27,11 +27,10 @@ * Sung-Ching Lin <sclin@sis.com.tw> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c,v 1.4 2000/09/22 11:35:47 alanh Exp $ */ #define __NO_VERSION__ #include "drmP.h" -#include "sis_drm_public.h" +#include "sis_drm.h" #include "sis_ds.h" #include "sis_drv.h" #include <linux/fb.h> diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c index 0fef5f7e2..5f2c804af 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c @@ -1,4 +1,4 @@ -/* tdfx.c -- tdfx driver -*- linux-c -*- +/* tdfx_drv.c -- tdfx driver -*- linux-c -*- * Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. @@ -11,11 +11,11 @@ * 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 @@ -23,13 +23,12 @@ * 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. (Rik) Faith <faith@valinux.com> * Daryll Strauss <daryll@valinux.com> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c,v 1.6 2000/08/28 02:43:16 tsi Exp $ */ #include <linux/config.h> #include "drmP.h" @@ -37,7 +36,7 @@ #define TDFX_NAME "tdfx" #define TDFX_DESC "3dfx Banshee/Voodoo3+" -#define TDFX_DATE "20000719" +#define TDFX_DATE "20000928" #define TDFX_MAJOR 1 #define TDFX_MINOR 0 #define TDFX_PATCHLEVEL 0 @@ -77,7 +76,7 @@ static drm_ioctl_desc_t tdfx_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 }, - + [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { tdfx_addctx, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { tdfx_rmctx, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { tdfx_modctx, 1, 1 }, @@ -129,7 +128,7 @@ __setup("tdfx=", tdfx_options); static int tdfx_setup(drm_device_t *dev) { int i; - + atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); dev->buf_use = 0; @@ -171,7 +170,7 @@ static int tdfx_setup(drm_device_t *dev) dev->ctx_start = 0; dev->lck_start = 0; - + dev->buf_rp = dev->buf; dev->buf_wp = dev->buf; dev->buf_end = dev->buf + DRM_BSZ; @@ -180,15 +179,15 @@ static int tdfx_setup(drm_device_t *dev) init_waitqueue_head(&dev->buf_writers); tdfx_res_ctx.handle=-1; - + DRM_DEBUG("\n"); - + /* The kernel's context could be created here, but is now created in drm_dma_enqueue. This is more resource-efficient for hardware that does not do DMA, but may mean that drm_select_queue fails between the time the interrupt is initialized and the time the queues are initialized. */ - + return 0; } @@ -204,12 +203,12 @@ static int tdfx_takedown(drm_device_t *dev) down(&dev->struct_sem); del_timer(&dev->timer); - + if (dev->devname) { drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); dev->devname = NULL; } - + if (dev->unique) { drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); dev->unique = NULL; @@ -228,7 +227,7 @@ static int tdfx_takedown(drm_device_t *dev) if (dev->agp) { drm_agp_mem_t *temp; drm_agp_mem_t *temp_next; - + temp = dev->agp->memory; while(temp != NULL) { temp_next = temp->next; @@ -247,7 +246,7 @@ static int tdfx_takedown(drm_device_t *dev) } dev->vmalist = NULL; } - + /* Clear map area and mtrr information */ if (dev->maplist) { for (i = 0; i < dev->map_count; i++) { @@ -285,14 +284,14 @@ static int tdfx_takedown(drm_device_t *dev) dev->maplist = NULL; dev->map_count = 0; } - + if (dev->lock.hw_lock) { dev->lock.hw_lock = NULL; /* SHM removed */ dev->lock.pid = 0; wake_up_interruptible(&dev->lock.lock_queue); } up(&dev->struct_sem); - + return 0; } @@ -309,7 +308,7 @@ static int tdfx_init(void) memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); - + #ifdef MODULE drm_parse_options(tdfx); #endif @@ -341,7 +340,7 @@ static int tdfx_init(void) TDFX_PATCHLEVEL, TDFX_DATE, tdfx_misc.minor); - + return 0; } @@ -352,7 +351,7 @@ static void tdfx_cleanup(void) drm_device_t *dev = &tdfx_device; DRM_DEBUG("\n"); - + drm_proc_cleanup(); if (misc_deregister(&tdfx_misc)) { DRM_ERROR("Cannot unload module\n"); @@ -380,17 +379,18 @@ int tdfx_version(struct inode *inode, struct file *filp, unsigned int cmd, drm_version_t version; int len; - copy_from_user_ret(&version, + if (copy_from_user(&version, (drm_version_t *)arg, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; #define DRM_COPY(name,value) \ len = strlen(value); \ if (len > name##_len) len = name##_len; \ name##_len = strlen(value); \ if (len && name) { \ - copy_to_user_ret(name, value, len, -EFAULT); \ + if (copy_to_user(name, value, len)) \ + return -EFAULT; \ } version.version_major = TDFX_MAJOR; @@ -401,10 +401,10 @@ int tdfx_version(struct inode *inode, struct file *filp, unsigned int cmd, DRM_COPY(version.date, TDFX_DATE); DRM_COPY(version.desc, TDFX_DESC); - copy_to_user_ret((drm_version_t *)arg, + if (copy_to_user((drm_version_t *)arg, &version, - sizeof(version), - -EFAULT); + sizeof(version))) + return -EFAULT; return 0; } @@ -412,7 +412,7 @@ int tdfx_open(struct inode *inode, struct file *filp) { drm_device_t *dev = &tdfx_device; int retcode = 0; - + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { #if LINUX_VERSION_CODE < 0x020333 @@ -480,7 +480,7 @@ int tdfx_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, atomic_inc(&dev->ioctl_count); atomic_inc(&dev->total_ioctl); ++priv->ioctl_count; - + DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", current->pid, cmd, nr, dev->device, priv->authenticated); @@ -500,7 +500,7 @@ int tdfx_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, retcode = (func)(inode, filp, cmd, arg); } } - + atomic_dec(&dev->ioctl_count); return retcode; } @@ -519,7 +519,8 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd, dev->lck_start = start = get_cycles(); #endif - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", @@ -537,7 +538,7 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd, if (lock.context < 0 || lock.context >= dev->queue_count) return -EINVAL; #endif - + if (!ret) { #if 0 if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) @@ -549,7 +550,7 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd, /* Can't take lock if we just had it and there is contention. */ DRM_DEBUG("%d (pid %d) delayed j=%d dev=%d jiffies=%d\n", - lock.context, current->pid, j, + lock.context, current->pid, j, dev->lock.lock_time, jiffies); current->state = TASK_INTERRUPTIBLE; current->policy |= SCHED_YIELD; @@ -560,6 +561,7 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd, #endif add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { + current->state = TASK_INTERRUPTIBLE; if (!dev->lock.hw_lock) { /* Device has been unregistered */ ret = -EINTR; @@ -572,10 +574,9 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd, atomic_inc(&dev->total_locks); break; /* Got lock */ } - + /* Contention */ atomic_inc(&dev->total_sleeps); - current->state = TASK_INTERRUPTIBLE; #if 1 current->policy |= SCHED_YIELD; #endif @@ -616,6 +617,15 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd, #endif if (!ret) { + sigemptyset(&dev->sigmask); + sigaddset(&dev->sigmask, SIGSTOP); + sigaddset(&dev->sigmask, SIGTSTP); + sigaddset(&dev->sigmask, SIGTTIN); + sigaddset(&dev->sigmask, SIGTTOU); + dev->sigdata.context = lock.context; + dev->sigdata.lock = dev->lock.hw_lock; + block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); + if (lock.flags & _DRM_LOCK_READY) { /* Wait for space in DMA/FIFO */ } @@ -638,7 +648,7 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd, #if DRM_DMA_HISTOGRAM atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]); #endif - + return ret; } @@ -650,8 +660,9 @@ int tdfx_unlock(struct inode *inode, struct file *filp, unsigned int cmd, drm_device_t *dev = priv->dev; drm_lock_t lock; - copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); - + if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock))) + return -EFAULT; + if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); @@ -679,6 +690,7 @@ int tdfx_unlock(struct inode *inode, struct file *filp, unsigned int cmd, current->priority = DEF_PRIORITY; } #endif - + + unblock_all_signals(); return 0; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c index 074e75d94..964921b46 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c @@ -28,7 +28,6 @@ * Rickard E. (Rik) Faith <faith@valinux.com> * */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c,v 1.8 2000/08/28 02:43:16 tsi Exp $ */ #define __NO_VERSION__ #include "drmP.h" @@ -68,8 +67,6 @@ struct page *drm_vm_nopage(struct vm_area_struct *vma, int write_access) #endif { - DRM_DEBUG("0x%08lx, %d\n", address, write_access); - return NOPAGE_SIGBUS; /* Disallow mremap */ } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c index b921db386..c933f5935 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c @@ -502,7 +502,8 @@ int drmAddMap(int fd, map.offset = offset; #ifdef __alpha__ - if (type != DRM_SHM) + /* Make sure we add the bus_base to all but shm */ + if (type != DRM_SHM) map.offset += BUS_BASE; #endif map.size = size; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile deleted file mode 100644 index 6b12f3c9c..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile +++ /dev/null @@ -1,35 +0,0 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile,v 3.3 2000/06/27 14:27:30 tsi Exp $ - - - - -XCOMM $XConsortium: Imakefile /main/4 1996/09/28 17:23:58 rws $ - -#include <Server.tmpl> - -#if defined(OsfArchitecture) -BIOS_MOD = bios_devmem -#else -BIOS_MOD = bios_mmap -#endif - -SRCS = mach_init.c mach_video.c mach_io.c $(BIOS_MOD).c \ - VTsw_noop.c kmod_noop.c - -OBJS = mach_init.o mach_video.o mach_io.o $(BIOS_MOD).o \ - VTsw_noop.o kmod_noop.o - -INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ - -I$(XINCLUDESRC) - -SubdirLibraryRule($(OBJS)) -NormalLibraryObjectRule() - -#if defined(OsfArchitecture) -ObjectFromSpecialSource(bios_devmem,../shared/bios_devmem,/**/) -#endif -ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/) -ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/) - -DependTarget() - diff --git a/xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile deleted file mode 100644 index aca4c717c..000000000 --- a/xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile +++ /dev/null @@ -1,29 +0,0 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile,v 3.6 2000/06/27 14:27:30 tsi Exp $ - - - - - -XCOMM $XConsortium: Imakefile /main/5 1996/09/28 17:24:04 rws $ - -#include <Server.tmpl> - -SRCS = mnx_init.c mnx_video.c mnx_io.c bios_devmem.c \ - ioperm_noop.c VTsw_noop.c std_mouse.c posix_tty.c kmod_noop.c - -OBJS = mnx_init.o mnx_video.o mnx_io.o bios_devmem.o \ - ioperm_noop.o VTsw_noop.o posix_tty.o kmod_noop.o - -INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ - -I$(XINCLUDESRC) - -SubdirLibraryRule($(OBJS)) -NormalLibraryObjectRule() -NormalAsmObjectRule() - -ObjectFromSpecialSource(ioperm_noop,../shared/ioperm_noop,/**/) -ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/) -ObjectFromSpecialSource(posix_tty,../shared/posix_tty,/**/) -ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/) - -DependTarget() diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h index d5ad7f5fb..6cc9500f1 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h @@ -35,7 +35,13 @@ #ifndef _DRM_H_ #define _DRM_H_ +#if defined(__linux__) #include <asm/ioctl.h> /* For _IO* macros */ +#define DRM_IOCTL_NR(n) _IOC_NR(n) +#elif defined(__FreeBSD__) +#include <sys/ioccom.h> +#define DRM_IOCTL_NR(n) ((n) & 0xff) +#endif #define DRM_PROC_DEVICES "/proc/devices" #define DRM_PROC_MISC "/proc/misc" @@ -290,7 +296,6 @@ typedef struct drm_agp_info { } drm_agp_info_t; #define DRM_IOCTL_BASE 'd' -#define DRM_IOCTL_NR(n) _IOC_NR(n) #define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr) #define DRM_IOR(nr,size) _IOR(DRM_IOCTL_BASE,nr,size) #define DRM_IOW(nr,size) _IOW(DRM_IOCTL_BASE,nr,size) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h index 415434839..563daff13 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h @@ -203,6 +203,31 @@ typedef struct { unsigned int a[100]; } __drm_dummy_lock_t; "r" (new)); \ } while (0) +#elif defined(__alpha__) + +#define DRM_CAS(lock, old, new, ret) \ + do { \ + int old32; \ + int cur32; \ + __asm__ __volatile__( \ + " mb\n" \ + " zap %4, 0xF0, %0\n" \ + " ldl_l %1, %2\n" \ + " zap %1, 0xF0, %1\n" \ + " cmpeq %0, %1, %1\n" \ + " beq %1, 1f\n" \ + " bis %5, %5, %1\n" \ + " stl_c %1, %2\n" \ + "1: xor %1, 1, %1\n" \ + " stl %1, %3" \ + : "+r" (old32), \ + "+&r" (cur32), \ + "=m" (__drm_dummy_lock(lock)),\ + "=m" (ret) \ + : "r" (old), \ + "r" (new)); \ + } while(0) + #elif defined(__sparc__) #define DRM_CAS(lock,old,new,__ret) \ @@ -261,9 +286,15 @@ do { register unsigned int __old __asm("o0"); \ #define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */ #endif +#ifdef __alpha__ +#define DRM_CAS_RESULT(_result) int _result +#else +#define DRM_CAS_RESULT(_result) char _result +#endif + #define DRM_LIGHT_LOCK(fd,lock,context) \ do { \ - char __ret; \ + DRM_CAS_RESULT(__ret); \ DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \ if (__ret) drmGetLock(fd,context,0); \ } while(0) @@ -272,7 +303,7 @@ do { register unsigned int __old __asm("o0"); \ benchmarking only. */ #define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count) \ do { \ - char __ret; \ + DRM_CAS_RESULT(__ret); \ DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \ if (__ret) drmGetLock(fd,context,0); \ else ++count; \ @@ -286,7 +317,7 @@ do { register unsigned int __old __asm("o0"); \ #define DRM_UNLOCK(fd,lock,context) \ do { \ - char __ret; \ + DRM_CAS_RESULT(__ret); \ DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret); \ if (__ret) drmUnlock(fd,context); \ } while(0) @@ -294,7 +325,7 @@ do { register unsigned int __old __asm("o0"); \ /* Simple spin locks */ #define DRM_SPINLOCK(spin,val) \ do { \ - char __ret; \ + DRM_CAS_RESULT(__ret); \ do { \ DRM_CAS(spin,0,val,__ret); \ if (__ret) while ((spin)->lock); \ @@ -303,7 +334,7 @@ do { register unsigned int __old __asm("o0"); \ #define DRM_SPINLOCK_TAKE(spin,val) \ do { \ - char __ret; \ + DRM_CAS_RESULT(__ret); \ int cur; \ do { \ cur = (*spin).lock; \ @@ -323,7 +354,7 @@ do { register unsigned int __old __asm("o0"); \ #define DRM_SPINUNLOCK(spin,val) \ do { \ - char __ret; \ + DRM_CAS_RESULT(__ret); \ if ((*spin).lock == val) { /* else server stole lock */ \ do { \ DRM_CAS(spin,val,0,__ret); \ diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c index 756a10c38..d5f4cd97a 100644 --- a/xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c +++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c,v 1.29 2000/09/20 02:05:41 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c,v 1.30 2000/09/24 18:28:56 keithp Exp $ */ #include "misc.h" #include "xf86.h" @@ -450,6 +450,7 @@ XAAPixmapBPP (ScreenPtr pScreen, int depth) { PixmapPtr pPix; int bpp; + DestroyPixmapProcPtr destroyPixmap; XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap); pPix = (*pScreen->CreatePixmap) (pScreen, 1, 1, depth); @@ -457,9 +458,10 @@ XAAPixmapBPP (ScreenPtr pScreen, int depth) if (!pPix) return 0; bpp = pPix->drawable.bitsPerPixel; + destroyPixmap = pScreen->DestroyPixmap; XAA_SCREEN_PROLOGUE (pScreen, DestroyPixmap); (*pScreen->DestroyPixmap) (pPix); - XAA_SCREEN_EPILOGUE (pScreen, DestroyPixmap, XAADestroyPixmap); + XAA_SCREEN_EPILOGUE (pScreen, DestroyPixmap, destroyPixmap); return bpp; } |