diff options
Diffstat (limited to 'xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c')
-rw-r--r-- | xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c | 57 |
1 files changed, 53 insertions, 4 deletions
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 c6aadc144..a0d9cdf73 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c @@ -99,9 +99,43 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) mgaScreenPrivate *mgaScreen; MGADRIPtr serverInfo = (MGADRIPtr)sPriv->pDevPriv; + /* Check the DRI version */ + { + int major, minor, patch; + if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) { + if (major != 3 || minor != 0 || patch < 0) { + char msg[1000]; + sprintf(msg, "MGA DRI driver expected DRI version 3.0.x but got version %d.%d.%d", major, minor, patch); + __driMesaMessage(msg); + return GL_FALSE; + } + } + } + + /* Check that the DDX driver version is compatible */ + if (sPriv->ddxMajor != 1 || + sPriv->ddxMinor != 0 || + sPriv->ddxPatch < 0) { + char msg[1000]; + sprintf(msg, "MGA DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch); + __driMesaMessage(msg); + return GL_FALSE; + } + + /* Check that the DRM driver version is compatible */ + if (sPriv->drmMajor != 1 || + 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); + __driMesaMessage(msg); + return GL_FALSE; + } + /* Allocate the private area */ mgaScreen = (mgaScreenPrivate *)Xmalloc(sizeof(mgaScreenPrivate)); - if (!mgaScreen) return GL_FALSE; + if (!mgaScreen) + return GL_FALSE; mgaScreen->sPriv = sPriv; sPriv->private = (void *)mgaScreen; @@ -111,8 +145,12 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) */ if (serverInfo->chipset != MGA_CARD_TYPE_G200 && - serverInfo->chipset != MGA_CARD_TYPE_G400) - return GL_FALSE; + serverInfo->chipset != MGA_CARD_TYPE_G400) { + XFree(mgaScreen); + sPriv->private = NULL; + return GL_FALSE; + } + mgaScreen->chipset = serverInfo->chipset; mgaScreen->width = serverInfo->width; @@ -136,6 +174,7 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) (drmAddress *)&mgaScreen->agp.map) != 0) { Xfree(mgaScreen); + sPriv->private = NULL; return GL_FALSE; } @@ -177,6 +216,12 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) mgaScreen->Attrib = MGA_PF_565; mgaScreen->bufs = drmMapBufs(sPriv->fd); + if (!mgaScreen->bufs) { + /*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/ + XFree(mgaScreen); + sPriv->private = NULL; + return GL_FALSE; + } /* Other mgaglx stuff, too?? */ @@ -190,11 +235,15 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) return GL_TRUE; } + /* Accessed by dlsym from dri_mesa_init.c */ void XMesaResetDriver(__DRIscreenPrivate *sPriv) { - Xfree(sPriv->private); + mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *) sPriv->private; + /*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/ + Xfree(mgaScreen); + sPriv->private = NULL; } |