Merge branch 'nouveau-import'
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_screen.c
1 /* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c,v 1.7 2003/03/26 20:43:51 tsi Exp $ */
2 /**************************************************************************
3
4 Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
5 VA Linux Systems Inc., Fremont, California.
6
7 All Rights Reserved.
8
9 Permission is hereby granted, free of charge, to any person obtaining
10 a copy of this software and associated documentation files (the
11 "Software"), to deal in the Software without restriction, including
12 without limitation the rights to use, copy, modify, merge, publish,
13 distribute, sublicense, and/or sell copies of the Software, and to
14 permit persons to whom the Software is furnished to do so, subject to
15 the following conditions:
16
17 The above copyright notice and this permission notice (including the
18 next paragraph) shall be included in all copies or substantial
19 portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
25 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29 **************************************************************************/
30
31 /**
32 * \file radeon_screen.c
33 * Screen initialization functions for the Radeon driver.
34 *
35 * \author Kevin E. Martin <martin@valinux.com>
36 * \author Gareth Hughes <gareth@valinux.com>
37 */
38
39 #include "glheader.h"
40 #include "imports.h"
41 #include "mtypes.h"
42 #include "framebuffer.h"
43 #include "renderbuffer.h"
44
45 #define STANDALONE_MMIO
46 #include "radeon_chipset.h"
47 #include "radeon_macros.h"
48 #include "radeon_screen.h"
49 #if !RADEON_COMMON
50 #include "radeon_context.h"
51 #include "radeon_span.h"
52 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
53 #include "r200_context.h"
54 #include "r200_ioctl.h"
55 #include "r200_span.h"
56 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
57 #include "r300_context.h"
58 #include "radeon_span.h"
59 #endif
60
61 #include "utils.h"
62 #include "context.h"
63 #include "vblank.h"
64 #include "drirenderbuffer.h"
65
66 #include "GL/internal/dri_interface.h"
67
68 /* Radeon configuration
69 */
70 #include "xmlpool.h"
71
72 #if !RADEON_COMMON /* R100 */
73 PUBLIC const char __driConfigOptions[] =
74 DRI_CONF_BEGIN
75 DRI_CONF_SECTION_PERFORMANCE
76 DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
77 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
78 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
79 DRI_CONF_MAX_TEXTURE_UNITS(3,2,3)
80 DRI_CONF_HYPERZ(false)
81 DRI_CONF_SECTION_END
82 DRI_CONF_SECTION_QUALITY
83 DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
84 DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0")
85 DRI_CONF_NO_NEG_LOD_BIAS(false)
86 DRI_CONF_FORCE_S3TC_ENABLE(false)
87 DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
88 DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
89 DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
90 DRI_CONF_ALLOW_LARGE_TEXTURES(1)
91 DRI_CONF_SECTION_END
92 DRI_CONF_SECTION_DEBUG
93 DRI_CONF_NO_RAST(false)
94 DRI_CONF_SECTION_END
95 DRI_CONF_END;
96 static const GLuint __driNConfigOptions = 14;
97
98 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
99
100 PUBLIC const char __driConfigOptions[] =
101 DRI_CONF_BEGIN
102 DRI_CONF_SECTION_PERFORMANCE
103 DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
104 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
105 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
106 DRI_CONF_MAX_TEXTURE_UNITS(6,2,6)
107 DRI_CONF_HYPERZ(false)
108 DRI_CONF_SECTION_END
109 DRI_CONF_SECTION_QUALITY
110 DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
111 DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0")
112 DRI_CONF_NO_NEG_LOD_BIAS(false)
113 DRI_CONF_FORCE_S3TC_ENABLE(false)
114 DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
115 DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
116 DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
117 DRI_CONF_ALLOW_LARGE_TEXTURES(1)
118 DRI_CONF_TEXTURE_BLEND_QUALITY(1.0,"0.0:1.0")
119 DRI_CONF_SECTION_END
120 DRI_CONF_SECTION_DEBUG
121 DRI_CONF_NO_RAST(false)
122 DRI_CONF_SECTION_END
123 DRI_CONF_SECTION_SOFTWARE
124 DRI_CONF_NV_VERTEX_PROGRAM(false)
125 DRI_CONF_SECTION_END
126 DRI_CONF_END;
127 static const GLuint __driNConfigOptions = 16;
128
129 extern const struct dri_extension blend_extensions[];
130 extern const struct dri_extension ARB_vp_extension[];
131 extern const struct dri_extension NV_vp_extension[];
132 extern const struct dri_extension ATI_fs_extension[];
133 extern const struct dri_extension point_extensions[];
134
135 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
136
137 /* TODO: integrate these into xmlpool.h! */
138 #define DRI_CONF_MAX_TEXTURE_IMAGE_UNITS(def,min,max) \
139 DRI_CONF_OPT_BEGIN_V(texture_image_units,int,def, # min ":" # max ) \
140 DRI_CONF_DESC(en,"Number of texture image units") \
141 DRI_CONF_DESC(de,"Anzahl der Textureinheiten") \
142 DRI_CONF_OPT_END
143
144 #define DRI_CONF_MAX_TEXTURE_COORD_UNITS(def,min,max) \
145 DRI_CONF_OPT_BEGIN_V(texture_coord_units,int,def, # min ":" # max ) \
146 DRI_CONF_DESC(en,"Number of texture coordinate units") \
147 DRI_CONF_DESC(de,"Anzahl der Texturkoordinateneinheiten") \
148 DRI_CONF_OPT_END
149
150 #define DRI_CONF_COMMAND_BUFFER_SIZE(def,min,max) \
151 DRI_CONF_OPT_BEGIN_V(command_buffer_size,int,def, # min ":" # max ) \
152 DRI_CONF_DESC(en,"Size of command buffer (in KB)") \
153 DRI_CONF_DESC(de,"Grösse des Befehlspuffers (in KB)") \
154 DRI_CONF_OPT_END
155
156 #define DRI_CONF_DISABLE_S3TC(def) \
157 DRI_CONF_OPT_BEGIN(disable_s3tc,bool,def) \
158 DRI_CONF_DESC(en,"Disable S3TC compression") \
159 DRI_CONF_OPT_END
160
161 #define DRI_CONF_DISABLE_FALLBACK(def) \
162 DRI_CONF_OPT_BEGIN(disable_lowimpact_fallback,bool,def) \
163 DRI_CONF_DESC(en,"Disable Low-impact fallback") \
164 DRI_CONF_OPT_END
165
166
167 const char __driConfigOptions[] =
168 DRI_CONF_BEGIN
169 DRI_CONF_SECTION_PERFORMANCE
170 DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
171 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
172 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
173 DRI_CONF_MAX_TEXTURE_IMAGE_UNITS(8, 2, 8)
174 DRI_CONF_MAX_TEXTURE_COORD_UNITS(8, 2, 8)
175 DRI_CONF_COMMAND_BUFFER_SIZE(8, 8, 32)
176 DRI_CONF_DISABLE_FALLBACK(false)
177 DRI_CONF_SECTION_END
178 DRI_CONF_SECTION_QUALITY
179 DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
180 DRI_CONF_DEF_MAX_ANISOTROPY(1.0, "1.0,2.0,4.0,8.0,16.0")
181 DRI_CONF_NO_NEG_LOD_BIAS(false)
182 DRI_CONF_FORCE_S3TC_ENABLE(false)
183 DRI_CONF_DISABLE_S3TC(false)
184 DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
185 DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
186 DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
187 DRI_CONF_SECTION_END
188 DRI_CONF_SECTION_DEBUG
189 DRI_CONF_NO_RAST(false)
190 DRI_CONF_SECTION_END
191 DRI_CONF_END;
192 static const GLuint __driNConfigOptions = 16;
193
194 #ifndef RADEON_DEBUG
195 int RADEON_DEBUG = 0;
196
197 static const struct dri_debug_control debug_control[] = {
198 {"fall", DEBUG_FALLBACKS},
199 {"tex", DEBUG_TEXTURE},
200 {"ioctl", DEBUG_IOCTL},
201 {"prim", DEBUG_PRIMS},
202 {"vert", DEBUG_VERTS},
203 {"state", DEBUG_STATE},
204 {"code", DEBUG_CODEGEN},
205 {"vfmt", DEBUG_VFMT},
206 {"vtxf", DEBUG_VFMT},
207 {"verb", DEBUG_VERBOSE},
208 {"dri", DEBUG_DRI},
209 {"dma", DEBUG_DMA},
210 {"san", DEBUG_SANITY},
211 {"sync", DEBUG_SYNC},
212 {"pix", DEBUG_PIXEL},
213 {"mem", DEBUG_MEMORY},
214 {"allmsg", ~DEBUG_SYNC}, /* avoid the term "sync" because the parser uses strstr */
215 {NULL, 0}
216 };
217 #endif /* RADEON_DEBUG */
218
219 #endif /* RADEON_COMMON && defined(RADEON_COMMON_FOR_R300) */
220
221 extern const struct dri_extension card_extensions[];
222
223 static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
224
225 static int
226 radeonGetParam(int fd, int param, void *value)
227 {
228 int ret;
229 drm_radeon_getparam_t gp;
230
231 gp.param = param;
232 gp.value = value;
233
234 ret = drmCommandWriteRead( fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp));
235 return ret;
236 }
237
238 static __GLcontextModes *
239 radeonFillInModes( unsigned pixel_bits, unsigned depth_bits,
240 unsigned stencil_bits, GLboolean have_back_buffer )
241 {
242 __GLcontextModes * modes;
243 __GLcontextModes * m;
244 unsigned num_modes;
245 unsigned depth_buffer_factor;
246 unsigned back_buffer_factor;
247 GLenum fb_format;
248 GLenum fb_type;
249
250 /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
251 * enough to add support. Basically, if a context is created with an
252 * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
253 * will never be used.
254 */
255 static const GLenum back_buffer_modes[] = {
256 GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
257 };
258
259 u_int8_t depth_bits_array[2];
260 u_int8_t stencil_bits_array[2];
261
262
263 depth_bits_array[0] = depth_bits;
264 depth_bits_array[1] = depth_bits;
265
266 /* Just like with the accumulation buffer, always provide some modes
267 * with a stencil buffer. It will be a sw fallback, but some apps won't
268 * care about that.
269 */
270 stencil_bits_array[0] = 0;
271 stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
272
273 depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
274 back_buffer_factor = (have_back_buffer) ? 2 : 1;
275
276 num_modes = depth_buffer_factor * back_buffer_factor * 4;
277
278 if ( pixel_bits == 16 ) {
279 fb_format = GL_RGB;
280 fb_type = GL_UNSIGNED_SHORT_5_6_5;
281 }
282 else {
283 fb_format = GL_BGRA;
284 fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
285 }
286
287 modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
288 m = modes;
289 if ( ! driFillInModes( & m, fb_format, fb_type,
290 depth_bits_array, stencil_bits_array, depth_buffer_factor,
291 back_buffer_modes, back_buffer_factor,
292 GLX_TRUE_COLOR ) ) {
293 fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
294 __func__, __LINE__ );
295 return NULL;
296 }
297
298 if ( ! driFillInModes( & m, fb_format, fb_type,
299 depth_bits_array, stencil_bits_array, depth_buffer_factor,
300 back_buffer_modes, back_buffer_factor,
301 GLX_DIRECT_COLOR ) ) {
302 fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
303 __func__, __LINE__ );
304 return NULL;
305 }
306
307 /* Mark the visual as slow if there are "fake" stencil bits.
308 */
309 for ( m = modes ; m != NULL ; m = m->next ) {
310 if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
311 m->visualRating = GLX_SLOW_CONFIG;
312 }
313 }
314
315 return modes;
316 }
317
318
319 /* Create the device specific screen private data struct.
320 */
321 static radeonScreenPtr
322 radeonCreateScreen( __DRIscreenPrivate *sPriv )
323 {
324 radeonScreenPtr screen;
325 RADEONDRIPtr dri_priv = (RADEONDRIPtr)sPriv->pDevPriv;
326 unsigned char *RADEONMMIO;
327 PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
328 (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
329 void * const psc = sPriv->psc->screenConfigs;
330
331 if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) {
332 fprintf(stderr,"\nERROR! sizeof(RADEONDRIRec) does not match passed size from device driver\n");
333 return GL_FALSE;
334 }
335
336 /* Allocate the private area */
337 screen = (radeonScreenPtr) CALLOC( sizeof(*screen) );
338 if ( !screen ) {
339 __driUtilMessage("%s: Could not allocate memory for screen structure",
340 __FUNCTION__);
341 return NULL;
342 }
343
344 #if DO_DEBUG && RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
345 RADEON_DEBUG = driParseDebugString(getenv("RADEON_DEBUG"), debug_control);
346 #endif
347
348 /* parse information in __driConfigOptions */
349 driParseOptionInfo (&screen->optionCache,
350 __driConfigOptions, __driNConfigOptions);
351
352 /* This is first since which regions we map depends on whether or
353 * not we are using a PCI card.
354 */
355 screen->card_type = (dri_priv->IsPCI ? RADEON_CARD_PCI : RADEON_CARD_AGP);
356 {
357 int ret;
358 ret = radeonGetParam( sPriv->fd, RADEON_PARAM_GART_BUFFER_OFFSET,
359 &screen->gart_buffer_offset);
360
361 if (ret) {
362 FREE( screen );
363 fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_GART_BUFFER_OFFSET): %d\n", ret);
364 return NULL;
365 }
366
367 ret = radeonGetParam( sPriv->fd, RADEON_PARAM_GART_BASE,
368 &screen->gart_base);
369 if (ret) {
370 FREE( screen );
371 fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_GART_BASE): %d\n", ret);
372 return NULL;
373 }
374
375 ret = radeonGetParam( sPriv->fd, RADEON_PARAM_IRQ_NR,
376 &screen->irq);
377 if (ret) {
378 FREE( screen );
379 fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_IRQ_NR): %d\n", ret);
380 return NULL;
381 }
382 screen->drmSupportsCubeMapsR200 = (sPriv->drmMinor >= 7);
383 screen->drmSupportsBlendColor = (sPriv->drmMinor >= 11);
384 screen->drmSupportsTriPerf = (sPriv->drmMinor >= 16);
385 screen->drmSupportsFragShader = (sPriv->drmMinor >= 18);
386 screen->drmSupportsPointSprites = (sPriv->drmMinor >= 13);
387 screen->drmSupportsCubeMapsR100 = (sPriv->drmMinor >= 15);
388 screen->drmSupportsVertexProgram = (sPriv->drmMinor >= 25);
389 }
390
391 screen->mmio.handle = dri_priv->registerHandle;
392 screen->mmio.size = dri_priv->registerSize;
393 if ( drmMap( sPriv->fd,
394 screen->mmio.handle,
395 screen->mmio.size,
396 &screen->mmio.map ) ) {
397 FREE( screen );
398 __driUtilMessage("%s: drmMap failed\n", __FUNCTION__ );
399 return NULL;
400 }
401
402 RADEONMMIO = screen->mmio.map;
403
404 screen->status.handle = dri_priv->statusHandle;
405 screen->status.size = dri_priv->statusSize;
406 if ( drmMap( sPriv->fd,
407 screen->status.handle,
408 screen->status.size,
409 &screen->status.map ) ) {
410 drmUnmap( screen->mmio.map, screen->mmio.size );
411 FREE( screen );
412 __driUtilMessage("%s: drmMap (2) failed\n", __FUNCTION__ );
413 return NULL;
414 }
415 screen->scratch = (__volatile__ u_int32_t *)
416 ((GLubyte *)screen->status.map + RADEON_SCRATCH_REG_OFFSET);
417
418 screen->buffers = drmMapBufs( sPriv->fd );
419 if ( !screen->buffers ) {
420 drmUnmap( screen->status.map, screen->status.size );
421 drmUnmap( screen->mmio.map, screen->mmio.size );
422 FREE( screen );
423 __driUtilMessage("%s: drmMapBufs failed\n", __FUNCTION__ );
424 return NULL;
425 }
426
427 if ( dri_priv->gartTexHandle && dri_priv->gartTexMapSize ) {
428 screen->gartTextures.handle = dri_priv->gartTexHandle;
429 screen->gartTextures.size = dri_priv->gartTexMapSize;
430 if ( drmMap( sPriv->fd,
431 screen->gartTextures.handle,
432 screen->gartTextures.size,
433 (drmAddressPtr)&screen->gartTextures.map ) ) {
434 drmUnmapBufs( screen->buffers );
435 drmUnmap( screen->status.map, screen->status.size );
436 drmUnmap( screen->mmio.map, screen->mmio.size );
437 FREE( screen );
438 __driUtilMessage("%s: drmMap failed for GART texture area\n", __FUNCTION__);
439 return NULL;
440 }
441
442 screen->gart_texture_offset = dri_priv->gartTexOffset + screen->gart_base;
443 }
444
445 screen->chip_flags = 0;
446 /* XXX: add more chipsets */
447 switch ( dri_priv->deviceID ) {
448 case PCI_CHIP_RADEON_LY:
449 case PCI_CHIP_RADEON_LZ:
450 case PCI_CHIP_RADEON_QY:
451 case PCI_CHIP_RADEON_QZ:
452 case PCI_CHIP_RN50_515E:
453 case PCI_CHIP_RN50_5969:
454 screen->chip_family = CHIP_FAMILY_RV100;
455 break;
456
457 case PCI_CHIP_RS100_4136:
458 case PCI_CHIP_RS100_4336:
459 screen->chip_family = CHIP_FAMILY_RS100;
460 break;
461
462 case PCI_CHIP_RS200_4137:
463 case PCI_CHIP_RS200_4337:
464 case PCI_CHIP_RS250_4237:
465 case PCI_CHIP_RS250_4437:
466 screen->chip_family = CHIP_FAMILY_RS200;
467 break;
468
469 case PCI_CHIP_RADEON_QD:
470 case PCI_CHIP_RADEON_QE:
471 case PCI_CHIP_RADEON_QF:
472 case PCI_CHIP_RADEON_QG:
473 /* all original radeons (7200) presumably have a stencil op bug */
474 screen->chip_family = CHIP_FAMILY_R100;
475 screen->chip_flags = RADEON_CHIPSET_TCL | RADEON_CHIPSET_BROKEN_STENCIL;
476 break;
477
478 case PCI_CHIP_RV200_QW:
479 case PCI_CHIP_RV200_QX:
480 case PCI_CHIP_RADEON_LW:
481 case PCI_CHIP_RADEON_LX:
482 screen->chip_family = CHIP_FAMILY_RV200;
483 screen->chip_flags = RADEON_CHIPSET_TCL;
484 break;
485
486 case PCI_CHIP_R200_BB:
487 case PCI_CHIP_R200_BC:
488 case PCI_CHIP_R200_QH:
489 case PCI_CHIP_R200_QL:
490 case PCI_CHIP_R200_QM:
491 screen->chip_family = CHIP_FAMILY_R200;
492 screen->chip_flags = RADEON_CHIPSET_TCL;
493 break;
494
495 case PCI_CHIP_RV250_If:
496 case PCI_CHIP_RV250_Ig:
497 case PCI_CHIP_RV250_Ld:
498 case PCI_CHIP_RV250_Lf:
499 case PCI_CHIP_RV250_Lg:
500 screen->chip_family = CHIP_FAMILY_RV250;
501 screen->chip_flags = R200_CHIPSET_YCBCR_BROKEN | RADEON_CHIPSET_TCL;
502 break;
503
504 case PCI_CHIP_RV280_5960:
505 case PCI_CHIP_RV280_5961:
506 case PCI_CHIP_RV280_5962:
507 case PCI_CHIP_RV280_5964:
508 case PCI_CHIP_RV280_5965:
509 case PCI_CHIP_RV280_5C61:
510 case PCI_CHIP_RV280_5C63:
511 screen->chip_family = CHIP_FAMILY_RV280;
512 screen->chip_flags = RADEON_CHIPSET_TCL;
513 break;
514
515 case PCI_CHIP_RS300_5834:
516 case PCI_CHIP_RS300_5835:
517 case PCI_CHIP_RS350_7834:
518 case PCI_CHIP_RS350_7835:
519 screen->chip_family = CHIP_FAMILY_RS300;
520 break;
521
522 case PCI_CHIP_R300_AD:
523 case PCI_CHIP_R300_AE:
524 case PCI_CHIP_R300_AF:
525 case PCI_CHIP_R300_AG:
526 case PCI_CHIP_R300_ND:
527 case PCI_CHIP_R300_NE:
528 case PCI_CHIP_R300_NF:
529 case PCI_CHIP_R300_NG:
530 screen->chip_family = CHIP_FAMILY_R300;
531 screen->chip_flags = RADEON_CHIPSET_TCL;
532 break;
533
534 case PCI_CHIP_RV350_AP:
535 case PCI_CHIP_RV350_AQ:
536 case PCI_CHIP_RV350_AR:
537 case PCI_CHIP_RV350_AS:
538 case PCI_CHIP_RV350_AT:
539 case PCI_CHIP_RV350_AV:
540 case PCI_CHIP_RV350_AU:
541 case PCI_CHIP_RV350_NP:
542 case PCI_CHIP_RV350_NQ:
543 case PCI_CHIP_RV350_NR:
544 case PCI_CHIP_RV350_NS:
545 case PCI_CHIP_RV350_NT:
546 case PCI_CHIP_RV350_NV:
547 screen->chip_family = CHIP_FAMILY_RV350;
548 screen->chip_flags = RADEON_CHIPSET_TCL;
549 break;
550
551 case PCI_CHIP_R350_AH:
552 case PCI_CHIP_R350_AI:
553 case PCI_CHIP_R350_AJ:
554 case PCI_CHIP_R350_AK:
555 case PCI_CHIP_R350_NH:
556 case PCI_CHIP_R350_NI:
557 case PCI_CHIP_R360_NJ:
558 case PCI_CHIP_R350_NK:
559 screen->chip_family = CHIP_FAMILY_R350;
560 screen->chip_flags = RADEON_CHIPSET_TCL;
561 break;
562
563 case PCI_CHIP_RV370_5460:
564 case PCI_CHIP_RV370_5462:
565 case PCI_CHIP_RV370_5464:
566 case PCI_CHIP_RV370_5B60:
567 case PCI_CHIP_RV370_5B62:
568 case PCI_CHIP_RV370_5B63:
569 case PCI_CHIP_RV370_5B64:
570 case PCI_CHIP_RV370_5B65:
571 case PCI_CHIP_RV380_3150:
572 case PCI_CHIP_RV380_3152:
573 case PCI_CHIP_RV380_3154:
574 case PCI_CHIP_RV380_3E50:
575 case PCI_CHIP_RV380_3E54:
576 screen->chip_family = CHIP_FAMILY_RV380;
577 screen->chip_flags = RADEON_CHIPSET_TCL;
578 break;
579
580 case PCI_CHIP_R420_JN:
581 case PCI_CHIP_R420_JH:
582 case PCI_CHIP_R420_JI:
583 case PCI_CHIP_R420_JJ:
584 case PCI_CHIP_R420_JK:
585 case PCI_CHIP_R420_JL:
586 case PCI_CHIP_R420_JM:
587 case PCI_CHIP_R420_JO:
588 case PCI_CHIP_R420_JP:
589 case PCI_CHIP_R420_JT:
590 case PCI_CHIP_R481_4B49:
591 case PCI_CHIP_R481_4B4A:
592 case PCI_CHIP_R481_4B4B:
593 case PCI_CHIP_R481_4B4C:
594 case PCI_CHIP_R423_UH:
595 case PCI_CHIP_R423_UI:
596 case PCI_CHIP_R423_UJ:
597 case PCI_CHIP_R423_UK:
598 case PCI_CHIP_R430_554C:
599 case PCI_CHIP_R430_554D:
600 case PCI_CHIP_R430_554E:
601 case PCI_CHIP_R430_554F:
602 case PCI_CHIP_R423_5550:
603 case PCI_CHIP_R423_UQ:
604 case PCI_CHIP_R423_UR:
605 case PCI_CHIP_R423_UT:
606 case PCI_CHIP_R430_5D48:
607 case PCI_CHIP_R430_5D49:
608 case PCI_CHIP_R430_5D4A:
609 case PCI_CHIP_R480_5D4C:
610 case PCI_CHIP_R480_5D4D:
611 case PCI_CHIP_R480_5D4E:
612 case PCI_CHIP_R480_5D4F:
613 case PCI_CHIP_R480_5D50:
614 case PCI_CHIP_R480_5D52:
615 case PCI_CHIP_R423_5D57:
616 screen->chip_family = CHIP_FAMILY_R420;
617 screen->chip_flags = RADEON_CHIPSET_TCL;
618 break;
619
620 case PCI_CHIP_RV410_564A:
621 case PCI_CHIP_RV410_564B:
622 case PCI_CHIP_RV410_564F:
623 case PCI_CHIP_RV410_5652:
624 case PCI_CHIP_RV410_5653:
625 case PCI_CHIP_RV410_5E48:
626 case PCI_CHIP_RV410_5E4A:
627 case PCI_CHIP_RV410_5E4B:
628 case PCI_CHIP_RV410_5E4C:
629 case PCI_CHIP_RV410_5E4D:
630 case PCI_CHIP_RV410_5E4F:
631 screen->chip_family = CHIP_FAMILY_RV410;
632 screen->chip_flags = RADEON_CHIPSET_TCL;
633 break;
634
635 case PCI_CHIP_RS480_5954:
636 case PCI_CHIP_RS480_5955:
637 case PCI_CHIP_RS482_5974:
638 case PCI_CHIP_RS482_5975:
639 case PCI_CHIP_RS400_5A41:
640 case PCI_CHIP_RS400_5A42:
641 case PCI_CHIP_RC410_5A61:
642 case PCI_CHIP_RC410_5A62:
643 screen->chip_family = CHIP_FAMILY_RS400;
644 fprintf(stderr, "Warning, xpress200 detected. Probably won't work.\n");
645 break;
646
647 default:
648 fprintf(stderr, "unknown chip id 0x%x, can't guess.\n",
649 dri_priv->deviceID);
650 return NULL;
651 }
652 if ((screen->chip_family == CHIP_FAMILY_R350 || screen->chip_family == CHIP_FAMILY_R300) &&
653 sPriv->ddxMinor < 2) {
654 fprintf(stderr, "xf86-video-ati-6.6.2 or newer needed for Radeon 9500/9700/9800 cards.\n");
655 return NULL;
656 }
657
658 if (screen->chip_family <= CHIP_FAMILY_RS200)
659 screen->chip_flags |= RADEON_CLASS_R100;
660 else if (screen->chip_family <= CHIP_FAMILY_RV280)
661 screen->chip_flags |= RADEON_CLASS_R200;
662 else
663 screen->chip_flags |= RADEON_CLASS_R300;
664
665 screen->cpp = dri_priv->bpp / 8;
666 screen->AGPMode = dri_priv->AGPMode;
667
668 screen->fbLocation = ( INREG( RADEON_MC_FB_LOCATION ) & 0xffff ) << 16;
669
670 if ( sPriv->drmMinor >= 10 ) {
671 drm_radeon_setparam_t sp;
672
673 sp.param = RADEON_SETPARAM_FB_LOCATION;
674 sp.value = screen->fbLocation;
675
676 drmCommandWrite( sPriv->fd, DRM_RADEON_SETPARAM,
677 &sp, sizeof( sp ) );
678 }
679
680 screen->frontOffset = dri_priv->frontOffset;
681 screen->frontPitch = dri_priv->frontPitch;
682 screen->backOffset = dri_priv->backOffset;
683 screen->backPitch = dri_priv->backPitch;
684 screen->depthOffset = dri_priv->depthOffset;
685 screen->depthPitch = dri_priv->depthPitch;
686
687 /* Check if ddx has set up a surface reg to cover depth buffer */
688 screen->depthHasSurface = ((sPriv->ddxMajor > 4) &&
689 (screen->chip_flags & RADEON_CHIPSET_TCL));
690
691 if ( dri_priv->textureSize == 0 ) {
692 screen->texOffset[RADEON_LOCAL_TEX_HEAP] = screen->gart_texture_offset;
693 screen->texSize[RADEON_LOCAL_TEX_HEAP] = dri_priv->gartTexMapSize;
694 screen->logTexGranularity[RADEON_LOCAL_TEX_HEAP] =
695 dri_priv->log2GARTTexGran;
696 } else {
697 screen->texOffset[RADEON_LOCAL_TEX_HEAP] = dri_priv->textureOffset
698 + screen->fbLocation;
699 screen->texSize[RADEON_LOCAL_TEX_HEAP] = dri_priv->textureSize;
700 screen->logTexGranularity[RADEON_LOCAL_TEX_HEAP] =
701 dri_priv->log2TexGran;
702 }
703
704 if ( !screen->gartTextures.map || dri_priv->textureSize == 0
705 || getenv( "RADEON_GARTTEXTURING_FORCE_DISABLE" ) ) {
706 screen->numTexHeaps = RADEON_NR_TEX_HEAPS - 1;
707 screen->texOffset[RADEON_GART_TEX_HEAP] = 0;
708 screen->texSize[RADEON_GART_TEX_HEAP] = 0;
709 screen->logTexGranularity[RADEON_GART_TEX_HEAP] = 0;
710 } else {
711 screen->numTexHeaps = RADEON_NR_TEX_HEAPS;
712 screen->texOffset[RADEON_GART_TEX_HEAP] = screen->gart_texture_offset;
713 screen->texSize[RADEON_GART_TEX_HEAP] = dri_priv->gartTexMapSize;
714 screen->logTexGranularity[RADEON_GART_TEX_HEAP] =
715 dri_priv->log2GARTTexGran;
716 }
717
718 if ( glx_enable_extension != NULL ) {
719 if ( screen->irq != 0 ) {
720 (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
721 (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
722 (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
723 }
724
725 (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
726 if (IS_R200_CLASS(screen))
727 (*glx_enable_extension)( psc, "GLX_MESA_allocate_memory" );
728
729 (*glx_enable_extension)( psc, "GLX_MESA_copy_sub_buffer" );
730 (*glx_enable_extension)( psc, "GLX_SGI_make_current_read" );
731 }
732
733 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
734 if (IS_R200_CLASS(screen)) {
735 sPriv->psc->allocateMemory = (void *) r200AllocateMemoryMESA;
736 sPriv->psc->freeMemory = (void *) r200FreeMemoryMESA;
737 sPriv->psc->memoryOffset = (void *) r200GetMemoryOffsetMESA;
738 }
739 #endif
740
741 screen->driScreen = sPriv;
742 screen->sarea_priv_offset = dri_priv->sarea_priv_offset;
743 return screen;
744 }
745
746 /* Destroy the device specific screen private data struct.
747 */
748 static void
749 radeonDestroyScreen( __DRIscreenPrivate *sPriv )
750 {
751 radeonScreenPtr screen = (radeonScreenPtr)sPriv->private;
752
753 if (!screen)
754 return;
755
756 if ( screen->gartTextures.map ) {
757 drmUnmap( screen->gartTextures.map, screen->gartTextures.size );
758 }
759 drmUnmapBufs( screen->buffers );
760 drmUnmap( screen->status.map, screen->status.size );
761 drmUnmap( screen->mmio.map, screen->mmio.size );
762
763 /* free all option information */
764 driDestroyOptionInfo (&screen->optionCache);
765
766 FREE( screen );
767 sPriv->private = NULL;
768 }
769
770
771 /* Initialize the driver specific screen private data.
772 */
773 static GLboolean
774 radeonInitDriver( __DRIscreenPrivate *sPriv )
775 {
776 sPriv->private = (void *) radeonCreateScreen( sPriv );
777 if ( !sPriv->private ) {
778 radeonDestroyScreen( sPriv );
779 return GL_FALSE;
780 }
781
782 return GL_TRUE;
783 }
784
785
786 /**
787 * Create the Mesa framebuffer and renderbuffers for a given window/drawable.
788 *
789 * \todo This function (and its interface) will need to be updated to support
790 * pbuffers.
791 */
792 static GLboolean
793 radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
794 __DRIdrawablePrivate *driDrawPriv,
795 const __GLcontextModes *mesaVis,
796 GLboolean isPixmap )
797 {
798 radeonScreenPtr screen = (radeonScreenPtr) driScrnPriv->private;
799
800 if (isPixmap) {
801 return GL_FALSE; /* not implemented */
802 }
803 else {
804 const GLboolean swDepth = GL_FALSE;
805 const GLboolean swAlpha = GL_FALSE;
806 const GLboolean swAccum = mesaVis->accumRedBits > 0;
807 const GLboolean swStencil = mesaVis->stencilBits > 0 &&
808 mesaVis->depthBits != 24;
809 struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
810
811 /* front color renderbuffer */
812 {
813 driRenderbuffer *frontRb
814 = driNewRenderbuffer(GL_RGBA,
815 driScrnPriv->pFB + screen->frontOffset,
816 screen->cpp,
817 screen->frontOffset, screen->frontPitch,
818 driDrawPriv);
819 radeonSetSpanFunctions(frontRb, mesaVis);
820 _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
821 }
822
823 /* back color renderbuffer */
824 if (mesaVis->doubleBufferMode) {
825 driRenderbuffer *backRb
826 = driNewRenderbuffer(GL_RGBA,
827 driScrnPriv->pFB + screen->backOffset,
828 screen->cpp,
829 screen->backOffset, screen->backPitch,
830 driDrawPriv);
831 radeonSetSpanFunctions(backRb, mesaVis);
832 _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
833 }
834
835 /* depth renderbuffer */
836 if (mesaVis->depthBits == 16) {
837 driRenderbuffer *depthRb
838 = driNewRenderbuffer(GL_DEPTH_COMPONENT16,
839 driScrnPriv->pFB + screen->depthOffset,
840 screen->cpp,
841 screen->depthOffset, screen->depthPitch,
842 driDrawPriv);
843 radeonSetSpanFunctions(depthRb, mesaVis);
844 _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
845 depthRb->depthHasSurface = screen->depthHasSurface;
846 }
847 else if (mesaVis->depthBits == 24) {
848 driRenderbuffer *depthRb
849 = driNewRenderbuffer(GL_DEPTH_COMPONENT24,
850 driScrnPriv->pFB + screen->depthOffset,
851 screen->cpp,
852 screen->depthOffset, screen->depthPitch,
853 driDrawPriv);
854 radeonSetSpanFunctions(depthRb, mesaVis);
855 _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
856 depthRb->depthHasSurface = screen->depthHasSurface;
857 }
858
859 /* stencil renderbuffer */
860 if (mesaVis->stencilBits > 0 && !swStencil) {
861 driRenderbuffer *stencilRb
862 = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT,
863 driScrnPriv->pFB + screen->depthOffset,
864 screen->cpp,
865 screen->depthOffset, screen->depthPitch,
866 driDrawPriv);
867 radeonSetSpanFunctions(stencilRb, mesaVis);
868 _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
869 stencilRb->depthHasSurface = screen->depthHasSurface;
870 }
871
872 _mesa_add_soft_renderbuffers(fb,
873 GL_FALSE, /* color */
874 swDepth,
875 swStencil,
876 swAccum,
877 swAlpha,
878 GL_FALSE /* aux */);
879 driDrawPriv->driverPrivate = (void *) fb;
880
881 return (driDrawPriv->driverPrivate != NULL);
882 }
883 }
884
885
886 static void
887 radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
888 {
889 _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
890 }
891
892 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
893 /**
894 * Choose the appropriate CreateContext function based on the chipset.
895 * Eventually, all drivers will go through this process.
896 */
897 static GLboolean radeonCreateContext(const __GLcontextModes * glVisual,
898 __DRIcontextPrivate * driContextPriv,
899 void *sharedContextPriv)
900 {
901 __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
902 radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
903
904 if (IS_R300_CLASS(screen))
905 return r300CreateContext(glVisual, driContextPriv, sharedContextPriv);
906 return GL_FALSE;
907 }
908
909 /**
910 * Choose the appropriate DestroyContext function based on the chipset.
911 */
912 static void radeonDestroyContext(__DRIcontextPrivate * driContextPriv)
913 {
914 radeonContextPtr radeon = (radeonContextPtr) driContextPriv->driverPrivate;
915
916 if (IS_R300_CLASS(radeon->radeonScreen))
917 return r300DestroyContext(driContextPriv);
918 }
919
920
921 #endif
922
923 #if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))
924 static struct __DriverAPIRec radeonAPI = {
925 .InitDriver = radeonInitDriver,
926 .DestroyScreen = radeonDestroyScreen,
927 .CreateContext = radeonCreateContext,
928 .DestroyContext = radeonDestroyContext,
929 .CreateBuffer = radeonCreateBuffer,
930 .DestroyBuffer = radeonDestroyBuffer,
931 .SwapBuffers = radeonSwapBuffers,
932 .MakeCurrent = radeonMakeCurrent,
933 .UnbindContext = radeonUnbindContext,
934 .GetSwapInfo = getSwapInfo,
935 .GetMSC = driGetMSC32,
936 .WaitForMSC = driWaitForMSC32,
937 .WaitForSBC = NULL,
938 .SwapBuffersMSC = NULL,
939 .CopySubBuffer = radeonCopySubBuffer,
940 };
941 #else
942 static const struct __DriverAPIRec r200API = {
943 .InitDriver = radeonInitDriver,
944 .DestroyScreen = radeonDestroyScreen,
945 .CreateContext = r200CreateContext,
946 .DestroyContext = r200DestroyContext,
947 .CreateBuffer = radeonCreateBuffer,
948 .DestroyBuffer = radeonDestroyBuffer,
949 .SwapBuffers = r200SwapBuffers,
950 .MakeCurrent = r200MakeCurrent,
951 .UnbindContext = r200UnbindContext,
952 .GetSwapInfo = getSwapInfo,
953 .GetMSC = driGetMSC32,
954 .WaitForMSC = driWaitForMSC32,
955 .WaitForSBC = NULL,
956 .SwapBuffersMSC = NULL,
957 .CopySubBuffer = r200CopySubBuffer
958 };
959 #endif
960
961 /**
962 * This is the bootstrap function for the driver. libGL supplies all of the
963 * requisite information about the system, and the driver initializes itself.
964 * This routine also fills in the linked list pointed to by \c driver_modes
965 * with the \c __GLcontextModes that the driver can support for windows or
966 * pbuffers.
967 *
968 * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
969 * failure.
970 */
971 PUBLIC void *
972 __driCreateNewScreen_20050727( __DRInativeDisplay *dpy,
973 int scrn, __DRIscreen *psc,
974 const __GLcontextModes * modes,
975 const __DRIversion * ddx_version,
976 const __DRIversion * dri_version,
977 const __DRIversion * drm_version,
978 const __DRIframebuffer * frame_buffer,
979 drmAddress pSAREA, int fd,
980 int internal_api_version,
981 const __DRIinterfaceMethods * interface,
982 __GLcontextModes ** driver_modes )
983 {
984 __DRIscreenPrivate *psp;
985 #if !RADEON_COMMON
986 static const char *driver_name = "Radeon";
987 static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 };
988 static const __DRIversion dri_expected = { 4, 0, 0 };
989 static const __DRIversion drm_expected = { 1, 6, 0 };
990 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
991 static const char *driver_name = "R200";
992 static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 };
993 static const __DRIversion dri_expected = { 4, 0, 0 };
994 static const __DRIversion drm_expected = { 1, 6, 0 };
995 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
996 static const char *driver_name = "R300";
997 static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 };
998 static const __DRIversion dri_expected = { 4, 0, 0 };
999 static const __DRIversion drm_expected = { 1, 24, 0 };
1000 #endif
1001
1002 dri_interface = interface;
1003
1004 if ( ! driCheckDriDdxDrmVersions3( driver_name,
1005 dri_version, & dri_expected,
1006 ddx_version, & ddx_expected,
1007 drm_version, & drm_expected ) ) {
1008 return NULL;
1009 }
1010 #if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))
1011 psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
1012 ddx_version, dri_version, drm_version,
1013 frame_buffer, pSAREA, fd,
1014 internal_api_version, &radeonAPI);
1015 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
1016 psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
1017 ddx_version, dri_version, drm_version,
1018 frame_buffer, pSAREA, fd,
1019 internal_api_version, &r200API);
1020 #endif
1021
1022 if ( psp != NULL ) {
1023 RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
1024 if (driver_modes) {
1025 *driver_modes = radeonFillInModes( dri_priv->bpp,
1026 (dri_priv->bpp == 16) ? 16 : 24,
1027 (dri_priv->bpp == 16) ? 0 : 8,
1028 (dri_priv->backOffset != dri_priv->depthOffset) );
1029 }
1030
1031 /* Calling driInitExtensions here, with a NULL context pointer,
1032 * does not actually enable the extensions. It just makes sure
1033 * that all the dispatch offsets for all the extensions that
1034 * *might* be enables are known. This is needed because the
1035 * dispatch offsets need to be known when _mesa_context_create
1036 * is called, but we can't enable the extensions until we have a
1037 * context pointer.
1038 *
1039 * Hello chicken. Hello egg. How are you two today?
1040 */
1041 driInitExtensions( NULL, card_extensions, GL_FALSE );
1042 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
1043 driInitExtensions( NULL, blend_extensions, GL_FALSE );
1044 driInitSingleExtension( NULL, ARB_vp_extension );
1045 driInitSingleExtension( NULL, NV_vp_extension );
1046 driInitSingleExtension( NULL, ATI_fs_extension );
1047 driInitExtensions( NULL, point_extensions, GL_FALSE );
1048 #endif
1049 }
1050
1051 return (void *) psp;
1052 }
1053
1054
1055 /**
1056 * Get information about previous buffer swaps.
1057 */
1058 static int
1059 getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
1060 {
1061 #if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))
1062 radeonContextPtr rmesa;
1063 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
1064 r200ContextPtr rmesa;
1065 #endif
1066
1067 if ( (dPriv == NULL) || (dPriv->driContextPriv == NULL)
1068 || (dPriv->driContextPriv->driverPrivate == NULL)
1069 || (sInfo == NULL) ) {
1070 return -1;
1071 }
1072
1073 rmesa = dPriv->driContextPriv->driverPrivate;
1074 sInfo->swap_count = rmesa->swap_count;
1075 sInfo->swap_ust = rmesa->swap_ust;
1076 sInfo->swap_missed_count = rmesa->swap_missed_count;
1077
1078 sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0)
1079 ? driCalculateSwapUsage( dPriv, 0, rmesa->swap_missed_ust )
1080 : 0.0;
1081
1082 return 0;
1083 }