Remove CVS keywords.
[mesa.git] / src / mesa / drivers / dri / r128 / r128_dd.c
1 /**************************************************************************
2
3 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
4 Cedar Park, Texas.
5 All Rights Reserved.
6
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 on the rights to use, copy, modify, merge, publish, distribute, sub
11 license, and/or sell copies of the Software, and to permit persons to whom
12 the Software is furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice (including the next
15 paragraph) shall be included in all copies or substantial portions of the
16 Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26 **************************************************************************/
27
28 /*
29 * Authors:
30 * Gareth Hughes <gareth@valinux.com>
31 * Kevin E. Martin <martin@valinux.com>
32 *
33 */
34
35 #include "r128_context.h"
36 #include "r128_ioctl.h"
37 #include "r128_state.h"
38 #include "r128_dd.h"
39 #include "swrast/swrast.h"
40
41 #include "context.h"
42 #include "framebuffer.h"
43
44 #include "utils.h"
45
46 #define DRIVER_DATE "20051027"
47
48
49 /* Return the width and height of the current color buffer.
50 */
51 static void r128GetBufferSize( GLframebuffer *buffer,
52 GLuint *width, GLuint *height )
53 {
54 GET_CURRENT_CONTEXT(ctx);
55 r128ContextPtr rmesa = R128_CONTEXT(ctx);
56
57 LOCK_HARDWARE( rmesa );
58 *width = rmesa->driDrawable->w;
59 *height = rmesa->driDrawable->h;
60 UNLOCK_HARDWARE( rmesa );
61 }
62
63 /* Return various strings for glGetString().
64 */
65 static const GLubyte *r128GetString( GLcontext *ctx, GLenum name )
66 {
67 r128ContextPtr rmesa = R128_CONTEXT(ctx);
68 static char buffer[128];
69 unsigned offset;
70 const char * card_name = "Rage 128";
71 GLuint agp_mode = rmesa->r128Screen->IsPCI ? 0 :
72 rmesa->r128Screen->AGPMode;
73
74 switch ( name ) {
75 case GL_VENDOR:
76 return (GLubyte *)"VA Linux Systems, Inc.";
77
78 case GL_RENDERER:
79 /* Select the spefic chipset.
80 */
81 if ( R128_IS_PRO( rmesa ) ) {
82 card_name = "Rage 128 Pro";
83 }
84 else if ( R128_IS_MOBILITY( rmesa ) ) {
85 card_name = "Rage 128 Mobility";
86 }
87
88 offset = driGetRendererString( buffer, card_name, DRIVER_DATE,
89 agp_mode );
90
91 return (GLubyte *)buffer;
92
93 default:
94 return NULL;
95 }
96 }
97
98 /* Send all commands to the hardware. If vertex buffers or indirect
99 * buffers are in use, then we need to make sure they are sent to the
100 * hardware. All commands that are normally sent to the ring are
101 * already considered `flushed'.
102 */
103 static void r128Flush( GLcontext *ctx )
104 {
105 r128ContextPtr rmesa = R128_CONTEXT(ctx);
106
107 FLUSH_BATCH( rmesa );
108
109 #if ENABLE_PERF_BOXES
110 if ( rmesa->boxes ) {
111 LOCK_HARDWARE( rmesa );
112 r128PerformanceBoxesLocked( rmesa );
113 UNLOCK_HARDWARE( rmesa );
114 }
115
116 /* Log the performance counters if necessary */
117 r128PerformanceCounters( rmesa );
118 #endif
119 }
120
121 /* Make sure all commands have been sent to the hardware and have
122 * completed processing.
123 */
124 static void r128Finish( GLcontext *ctx )
125 {
126 r128ContextPtr rmesa = R128_CONTEXT(ctx);
127
128 #if ENABLE_PERF_BOXES
129 /* Bump the performance counter */
130 rmesa->c_drawWaits++;
131 #endif
132
133 r128Flush( ctx );
134 r128WaitForIdle( rmesa );
135 }
136
137
138 /* Initialize the driver's misc functions.
139 */
140 void r128InitDriverFuncs( struct dd_function_table *functions )
141 {
142 functions->GetBufferSize = r128GetBufferSize;
143 functions->GetString = r128GetString;
144 functions->Finish = r128Finish;
145 functions->Flush = r128Flush;
146 }