Pull createNewScreen entry point into dri_util.c.
authorKristian Høgsberg <krh@hinata.boston.redhat.com>
Mon, 14 May 2007 20:58:37 +0000 (16:58 -0400)
committerKristian Høgsberg <krh@redhat.com>
Wed, 10 Oct 2007 22:36:14 +0000 (18:36 -0400)
This pulls the top level createNewScreen entry point out of the drivers
and rewrites __driUtilCreateNewScreen in dri_util.c to be the new entry point.

The change moves more logic into the common/ layer and changes the
createNewScreen entry point to only be defined in one place.

17 files changed:
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/dri_util.h
src/mesa/drivers/dri/ffb/ffb_xmesa.c
src/mesa/drivers/dri/i810/i810screen.c
src/mesa/drivers/dri/i915/intel_screen.c
src/mesa/drivers/dri/i965/intel_screen.c
src/mesa/drivers/dri/mach64/mach64_screen.c
src/mesa/drivers/dri/mga/mga_xmesa.c
src/mesa/drivers/dri/nouveau/nouveau_screen.c
src/mesa/drivers/dri/r128/r128_screen.c
src/mesa/drivers/dri/radeon/radeon_screen.c
src/mesa/drivers/dri/s3v/s3v_xmesa.c
src/mesa/drivers/dri/savage/savage_xmesa.c
src/mesa/drivers/dri/sis/sis_screen.c
src/mesa/drivers/dri/tdfx/tdfx_screen.c
src/mesa/drivers/dri/trident/trident_context.c
src/mesa/drivers/dri/unichrome/via_screen.c

index 09fc223..9c96392 100644 (file)
@@ -667,9 +667,12 @@ static void driDestroyScreen(__DRIscreen *screen)
 
 
 /**
- * Utility function used to create a new driver-private screen structure.
+ * This is the bootstrap function for the driver.  libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
  * 
- * \param dpy   Display pointer
  * \param scrn  Index of the screen
  * \param psc   DRI screen data (not driver private)
  * \param modes Linked list of known display modes.  This list is, at a
@@ -690,35 +693,34 @@ static void driDestroyScreen(__DRIscreen *screen)
  *                              driver and libGL.
  * \param driverAPI Driver API functions used by other routines in dri_util.c.
  * 
- * \note
- * There is no need to check the minimum API version in this function.  Since
- * the \c __driCreateNewScreen function is versioned, it is impossible for a
- * loader that is too old to even load this driver.
+ * \note There is no need to check the minimum API version in this
+ * function.  Since the name of this function is versioned, it is
+ * impossible for a loader that is too old to even load this driver.
  */
-__DRIscreenPrivate *
-__driUtilCreateNewScreen(int scr, __DRIscreen *psc,
-                        __GLcontextModes * modes,
-                        const __DRIversion * ddx_version,
-                        const __DRIversion * dri_version,
-                        const __DRIversion * drm_version,
-                        const __DRIframebuffer * frame_buffer,
-                        drm_sarea_t *pSAREA,
-                        int fd,
-                        int internal_api_version,
-                        const struct __DriverAPIRec *driverAPI)
+PUBLIC
+void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc,
+                               const __GLcontextModes * modes,
+                               const __DRIversion * ddx_version,
+                               const __DRIversion * dri_version,
+                               const __DRIversion * drm_version,
+                               const __DRIframebuffer * frame_buffer,
+                               drmAddress pSAREA, int fd, 
+                               int internal_api_version,
+                               const __DRIinterfaceMethods * interface,
+                               __GLcontextModes ** driver_modes )
+                            
 {
     __DRIscreenPrivate *psp;
 
-
+    dri_interface = interface;
     api_ver = internal_api_version;
 
-    psp = (__DRIscreenPrivate *)_mesa_malloc(sizeof(__DRIscreenPrivate));
-    if (!psp) {
+    psp = _mesa_malloc(sizeof(*psp));
+    if (!psp)
        return NULL;
-    }
 
     psp->psc = psc;
-    psp->modes = modes;
+    psp->modes = NULL;
 
     /*
     ** NOT_DONE: This is used by the X server to detect when the client
@@ -731,9 +733,6 @@ __driUtilCreateNewScreen(int scr, __DRIscreen *psc,
     psp->ddx_version = *ddx_version;
     psp->dri_version = *dri_version;
 
-    /* install driver's callback functions */
-    memcpy( &psp->DriverAPI, driverAPI, sizeof(struct __DriverAPIRec) );
-
     psp->pSAREA = pSAREA;
 
     psp->pFB = frame_buffer->base;
@@ -746,7 +745,7 @@ __driUtilCreateNewScreen(int scr, __DRIscreen *psc,
     psp->fbBPP = psp->fbStride * 8 / frame_buffer->width;
 
     psp->fd = fd;
-    psp->myNum = scr;
+    psp->myNum = scrn;
 
     /*
     ** Do not init dummy context here; actual initialization will be
@@ -763,17 +762,15 @@ __driUtilCreateNewScreen(int scr, __DRIscreen *psc,
     if (internal_api_version >= 20070121)
        psc->setTexOffset  = psp->DriverAPI.setTexOffset;
 
-    if ( (psp->DriverAPI.InitDriver != NULL)
-        && !(*psp->DriverAPI.InitDriver)(psp) ) {
-       _mesa_free( psp );
+    *driver_modes = __driDriverInitScreen(psp);
+    if (*driver_modes == NULL) {
+       _mesa_free(psp);
        return NULL;
     }
 
-
     return psp;
 }
 
-
 /**
  * Compare the current GLX API version with a driver supplied required version.
  * 
index 7a70bc7..f56f1fa 100644 (file)
@@ -67,6 +67,13 @@ typedef struct __DRIutilversionRec2    __DRIutilversion2;
 
 
 /**
+ * Driver specific entry point.  Implemented by the driver.  Called
+ * from the top level createNewScreen entry point to initialize the
+ * __DRIscreenPrivate struct.
+ */
+extern __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp);
+
+/**
  * Used by DRI_VALIDATE_DRAWABLE_INFO
  */
 #define DRI_VALIDATE_DRAWABLE_INFO_ONCE(pDrawPriv)              \
@@ -109,11 +116,6 @@ do {                                                                    \
  * this structure.
  */
 struct __DriverAPIRec {
-    /** 
-     * Driver initialization callback
-     */
-    GLboolean (*InitDriver)(__DRIscreenPrivate *driScrnPriv);
-    
     /**
      * Screen destruction callback
      */
index 4cd5b9a..3a5551e 100644 (file)
@@ -605,7 +605,6 @@ void ffbXMesaUpdateState(ffbContextPtr fmesa)
 }
 
 static const struct __DriverAPIRec ffbAPI = {
-   .InitDriver      = ffbInitDriver,
    .DestroyScreen   = ffbDestroyScreen,
    .CreateContext   = ffbCreateContext,
    .DestroyContext  = ffbDestroyContext,
@@ -704,49 +703,28 @@ ffbFillInModes( unsigned pixel_bits, unsigned depth_bits,
 
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC
-void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                              const __GLcontextModes * modes,
-                              const __DRIversion * ddx_version,
-                              const __DRIversion * dri_version,
-                              const __DRIversion * drm_version,
-                              const __DRIframebuffer * frame_buffer,
-                              drmAddress pSAREA, int fd, 
-                              int internal_api_version,
-                              const __DRIinterfaceMethods * interface,
-                              __GLcontextModes ** driver_modes)
-                            
+__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = { 0, 1, 1 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 0, 0, 1 };
 
-   dri_interface = interface;
-
    if ( ! driCheckDriDdxDrmVersions2( "ffb",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->drm_version, & drm_expected ) )
       return NULL;
-   }
 
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &ffbAPI);
-   if ( psp != NULL ) {
-      *driver_modes = ffbFillInModes( 32, 16, 0, GL_TRUE );
-   }
+   psp->DriverAPI = ffbAPI;
+
+   if (!ffbInitDriver(psp))
+       return NULL;
 
-   return (void *) psp;
+   return ffbFillInModes( 32, 16, 0, GL_TRUE );
 }
index b04bc38..3c7ec96 100644 (file)
@@ -403,7 +403,6 @@ i810DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
 
 
 static const struct __DriverAPIRec i810API = {
-   .InitDriver      = i810InitDriver,
    .DestroyScreen   = i810DestroyScreen,
    .CreateContext   = i810CreateContext,
    .DestroyContext  = i810DestroyContext,
@@ -421,51 +420,30 @@ static const struct __DriverAPIRec i810API = {
 
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
+ * 
+ * \todo maybe fold this into intelInitDriver
  *
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC
-void *__DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                             const __GLcontextModes * modes,
-                             const __DRIversion * ddx_version,
-                             const __DRIversion * dri_version,
-                             const __DRIversion * drm_version,
-                             const __DRIframebuffer * frame_buffer,
-                             drmAddress pSAREA, int fd,
-                             int internal_api_version,
-                             const __DRIinterfaceMethods * interface,
-                             __GLcontextModes ** driver_modes)
+PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = { 1, 0, 0 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 1, 2, 0 };
 
-   dri_interface = interface;
-
    if ( ! driCheckDriDdxDrmVersions2( "i810",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->drm_version, & drm_expected ) ) {
       return NULL;
    }
 
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &i810API);
-   if ( psp != NULL ) {
-      *driver_modes = i810FillInModes( 16,
-                                      16, 0,
-                                      1);
-      driInitExtensions( NULL, card_extensions, GL_TRUE );
-   }
+   psp->DriverAPI = i810API;
+   driInitExtensions( NULL, card_extensions, GL_TRUE );
+
+   if (!i810InitDriver(psp))
+       return NULL;
 
-   return (void *) psp;
+   return i810FillInModes(16, 16, 0, 1);
 }
index 58dc02e..a75133e 100644 (file)
@@ -771,7 +771,6 @@ intelCreateContext(const __GLcontextModes * mesaVis,
 
 
 static const struct __DriverAPIRec intelAPI = {
-   .InitDriver = intelInitDriver,
    .DestroyScreen = intelDestroyScreen,
    .CreateContext = intelCreateContext,
    .DestroyContext = intelDestroyContext,
@@ -876,64 +875,46 @@ intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
 
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC
-void * __DRI_CREATE_NEW_SCREEN(int scrn,
-                              __DRIscreen * psc,
-                              const __GLcontextModes * modes,
-                              const __DRIversion * ddx_version,
-                              const __DRIversion * dri_version,
-                              const __DRIversion * drm_version,
-                              const __DRIframebuffer * frame_buffer,
-                              drmAddress pSAREA, int fd,
-                              int internal_api_version,
-                              const __DRIinterfaceMethods * interface,
-                              __GLcontextModes ** driver_modes)
+PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = { 1, 5, 0 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 1, 5, 0 };
+   I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
 
-   dri_interface = interface;
+   psp->DriverAPI = intelAPI;
 
    if (!driCheckDriDdxDrmVersions2("i915",
-                                   dri_version, &dri_expected,
-                                   ddx_version, &ddx_expected,
-                                   drm_version, &drm_expected)) {
+                                   &psp->dri_version, &dri_expected,
+                                   &psp->ddx_version, &ddx_expected,
+                                   &psp->drm_version, &drm_expected)) {
       return NULL;
    }
 
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &intelAPI);
-   if (psp != NULL) {
-      I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
-      *driver_modes = intelFillInModes(dri_priv->cpp * 8,
-                                       (dri_priv->cpp == 2) ? 16 : 24,
-                                       (dri_priv->cpp == 2) ? 0 : 8, 1);
-
-      /* Calling driInitExtensions here, with a NULL context pointer, does not actually
-       * enable the extensions.  It just makes sure that all the dispatch offsets for all
-       * the extensions that *might* be enables are known.  This is needed because the
-       * dispatch offsets need to be known when _mesa_context_create is called, but we can't
-       * enable the extensions until we have a context pointer.
-       *
-       * Hello chicken.  Hello egg.  How are you two today?
-       */
-      driInitExtensions(NULL, card_extensions, GL_FALSE);
-   }
+   /* Calling driInitExtensions here, with a NULL context pointer,
+    * does not actually enable the extensions.  It just makes sure
+    * that all the dispatch offsets for all the extensions that
+    * *might* be enables are known.  This is needed because the
+    * dispatch offsets need to be known when _mesa_context_create is
+    * called, but we can't enable the extensions until we have a
+    * context pointer.
+    *
+    * Hello chicken.  Hello egg.  How are you two today?
+    */
+   driInitExtensions(NULL, card_extensions, GL_FALSE);
+
+   if (!intelInitDriver(psp))
+       return NULL;
 
-   return (void *) psp;
+   return intelFillInModes(dri_priv->cpp * 8,
+                          (dri_priv->cpp == 2) ? 16 : 24,
+                          (dri_priv->cpp == 2) ? 0  : 8, 1);
 }
 
 struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
index cb6824b..f0bce14 100644 (file)
@@ -540,7 +540,6 @@ static GLboolean intelCreateContext( const __GLcontextModes *mesaVis,
 
 
 static const struct __DriverAPIRec intelAPI = {
-   .InitDriver      = intelInitDriver,
    .DestroyScreen   = intelDestroyScreen,
    .CreateContext   = intelCreateContext,
    .DestroyContext  = intelDestroyContext,
@@ -639,62 +638,44 @@ intelFillInModes( unsigned pixel_bits, unsigned depth_bits,
 
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC
-void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc,
-                               const __GLcontextModes * modes,
-                               const __DRIversion * ddx_version,
-                               const __DRIversion * dri_version,
-                               const __DRIversion * drm_version,
-                               const __DRIframebuffer * frame_buffer,
-                               drmAddress pSAREA, int fd, 
-                               int internal_api_version,
-                               const __DRIinterfaceMethods * interface,
-                               __GLcontextModes ** driver_modes )
-                            
+__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = { 1, 6, 0 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 1, 3, 0 };
+   I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
 
-   dri_interface = interface;
-
+   psp->DriverAPI = intelAPI;
    if ( ! driCheckDriDdxDrmVersions2( "i915",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
-      return NULL;
+                                     &psp->dri_version, &dri_expected,
+                                     &psp->ddx_version, &ddx_expected,
+                                     &psp->drm_version, &drm_expected ) ) {
+       return NULL;
    }
 
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &intelAPI);
-   if ( psp != NULL ) {
-      I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
-      *driver_modes = intelFillInModes( dri_priv->cpp * 8,
-                                       (dri_priv->cpp == 2) ? 16 : 24,
-                                       (dri_priv->cpp == 2) ? 0  : 8,
-                                       GL_TRUE );
-      /* Calling driInitExtensions here, with a NULL context pointer, does not actually
-       * enable the extensions.  It just makes sure that all the dispatch offsets for all
-       * the extensions that *might* be enables are known.  This is needed because the
-       * dispatch offsets need to be known when _mesa_context_create is called, but we can't
-       * enable the extensions until we have a context pointer.
-       *
-       * Hello chicken.  Hello egg.  How are you two today?
-       */
-      intelInitExtensions(NULL, GL_FALSE);
-   }
+   /* Calling driInitExtensions here, with a NULL context pointer,
+    * does not actually enable the extensions.  It just makes sure
+    * that all the dispatch offsets for all the extensions that
+    * *might* be enables are known.  This is needed because the
+    * dispatch offsets need to be known when _mesa_context_create is
+    * called, but we can't enable the extensions until we have a
+    * context pointer.
+    *
+    * Hello chicken.  Hello egg.  How are you two today?
+    */
+   intelInitExtensions(NULL, GL_FALSE);
+
+   if (!intelInitDriver(psp))
+       return NULL;
 
-   return (void *) psp;
+   return intelFillInModes( dri_priv->cpp * 8,
+                           (dri_priv->cpp == 2) ? 16 : 24,
+                           (dri_priv->cpp == 2) ? 0  : 8,
+                           GL_TRUE );
 }
index 733a16b..ff261c8 100644 (file)
@@ -476,7 +476,6 @@ mach64InitDriver( __DRIscreenPrivate *driScreen )
 
 
 static struct __DriverAPIRec mach64API = {
-   .InitDriver      = mach64InitDriver,
    .DestroyScreen   = mach64DestroyScreen,
    .CreateContext   = mach64CreateContext,
    .DestroyContext  = mach64DestroyContext,
@@ -494,63 +493,41 @@ static struct __DriverAPIRec mach64API = {
 
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC
-void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                              const __GLcontextModes * modes,
-                              const __DRIversion * ddx_version,
-                              const __DRIversion * dri_version,
-                              const __DRIversion * drm_version,
-                              const __DRIframebuffer * frame_buffer,
-                              drmAddress pSAREA, int fd, 
-                              int internal_api_version,
-                              const __DRIinterfaceMethods * interface,
-                              __GLcontextModes ** driver_modes)
-                            
+__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = { 6, 4, 0 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 2, 0, 0 };
+   ATIDRIPtr dri_priv = (ATIDRIPtr) psp->pDevPriv;
 
-   dri_interface = interface;
-
+   psp->DriverAPI = mach64API;
    if ( ! driCheckDriDdxDrmVersions2( "Mach64",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->drm_version, & drm_expected ) ) {
       return NULL;
    }
+   
+   /* Calling driInitExtensions here, with a NULL context pointer,
+    * does not actually enable the extensions.  It just makes sure
+    * that all the dispatch offsets for all the extensions that
+    * *might* be enables are known.  This is needed because the
+    * dispatch offsets need to be known when _mesa_context_create is
+    * called, but we can't enable the extensions until we have a
+    * context pointer.
+    *
+    * Hello chicken.  Hello egg.  How are you two today?
+    */
+   driInitExtensions( NULL, card_extensions, GL_FALSE );
+
+   if (!mach64InitDriver(psp))
+      return NULL;
 
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &mach64API);
-   if ( psp != NULL ) {
-      ATIDRIPtr dri_priv = (ATIDRIPtr) psp->pDevPriv;
-      *driver_modes = mach64FillInModes( dri_priv->cpp * 8,
-                                        16,
-                                        0,
-                                        1);
-
-      /* Calling driInitExtensions here, with a NULL context pointer, does not actually
-       * enable the extensions.  It just makes sure that all the dispatch offsets for all
-       * the extensions that *might* be enables are known.  This is needed because the
-       * dispatch offsets need to be known when _mesa_context_create is called, but we can't
-       * enable the extensions until we have a context pointer.
-       *
-       * Hello chicken.  Hello egg.  How are you two today?
-       */
-      driInitExtensions( NULL, card_extensions, GL_FALSE );
-   }
-
-   return (void *) psp;
+   return  mach64FillInModes( dri_priv->cpp * 8, 16, 0, 1);
 }
index b001f86..5b46939 100644 (file)
@@ -934,7 +934,6 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags )
 
 
 static const struct __DriverAPIRec mgaAPI = {
-   .InitDriver      = mgaInitDriver,
    .DestroyScreen   = mgaDestroyScreen,
    .CreateContext   = mgaCreateContext,
    .DestroyContext  = mgaDestroyContext,
@@ -952,69 +951,50 @@ static const struct __DriverAPIRec mgaAPI = {
 
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC
-void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                              const __GLcontextModes * modes,
-                              const __DRIversion * ddx_version,
-                              const __DRIversion * dri_version,
-                              const __DRIversion * drm_version,
-                              const __DRIframebuffer * frame_buffer,
-                              drmAddress pSAREA, int fd, 
-                              int internal_api_version,
-                              const __DRIinterfaceMethods * interface,
-                              __GLcontextModes ** driver_modes)
-                            
+__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = { 1, 2, 0 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 3, 0, 0 };
+   MGADRIPtr dri_priv = (MGADRIPtr) psp->pDevPriv;
 
-   dri_interface = interface;
-
+   psp->DriverAPI = mgaAPI;
    if ( ! driCheckDriDdxDrmVersions2( "MGA",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->drm_version, & drm_expected ) )
       return NULL;
-   }
 
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &mgaAPI);
-   if ( psp != NULL ) {
-      MGADRIPtr dri_priv = (MGADRIPtr) psp->pDevPriv;
-      *driver_modes = mgaFillInModes( dri_priv->cpp * 8,
-                                     (dri_priv->cpp == 2) ? 16 : 24,
-                                     (dri_priv->cpp == 2) ? 0  : 8,
-                                     (dri_priv->backOffset != dri_priv->depthOffset) );
-
-      /* Calling driInitExtensions here, with a NULL context pointer, does not actually
-       * enable the extensions.  It just makes sure that all the dispatch offsets for all
-       * the extensions that *might* be enables are known.  This is needed because the
-       * dispatch offsets need to be known when _mesa_context_create is called, but we can't
-       * enable the extensions until we have a context pointer.
-       *
-       * Hello chicken.  Hello egg.  How are you two today?
-       */
-      driInitExtensions( NULL, card_extensions, GL_FALSE );
-      driInitExtensions( NULL, g400_extensions, GL_FALSE );
-      driInitSingleExtension( NULL, ARB_vp_extension );
-      driInitExtensions( NULL, NV_vp_extensions, GL_FALSE );
 
-   }
+   /* Calling driInitExtensions here, with a NULL context pointer,
+    * does not actually enable the extensions.  It just makes sure
+    * that all the dispatch offsets for all the extensions that
+    * *might* be enables are known.  This is needed because the
+    * dispatch offsets need to be known when _mesa_context_create is
+    * called, but we can't enable the extensions until we have a
+    * context pointer.
+    *
+    * Hello chicken.  Hello egg.  How are you two today?
+    */
+
+   driInitExtensions( NULL, card_extensions, GL_FALSE );
+   driInitExtensions( NULL, g400_extensions, GL_FALSE );
+   driInitSingleExtension( NULL, ARB_vp_extension );
+   driInitExtensions( NULL, NV_vp_extensions, GL_FALSE );
+
+   if (!mgaInitDriver(psp))
+       return NULL;
 
-   return (void *) psp;
+   return mgaFillInModes( dri_priv->cpp * 8,
+                         (dri_priv->cpp == 2) ? 16 : 24,
+                         (dri_priv->cpp == 2) ? 0  : 8,
+                         (dri_priv->backOffset != dri_priv->depthOffset) );
 }
 
 
index cab53f4..3e7bab6 100644 (file)
@@ -195,7 +195,6 @@ nouveauGetSwapInfo(__DRIdrawablePrivate *dpriv, __DRIswapInfo *sInfo)
 }
 
 static const struct __DriverAPIRec nouveauAPI = {
-       .InitDriver      = nouveauInitDriver,
        .DestroyScreen   = nouveauDestroyScreen,
        .CreateContext   = nouveauCreateContext,
        .DestroyContext  = nouveauDestroyContext,
@@ -285,81 +284,62 @@ nouveauFillInModes( unsigned pixel_bits, unsigned depth_bits,
 
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC
-void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                              const __GLcontextModes * modes,
-                              const __DRIversion * ddx_version,
-                              const __DRIversion * dri_version,
-                              const __DRIversion * drm_version,
-                              const __DRIframebuffer * frame_buffer,
-                              drmAddress pSAREA, int fd, 
-                              int internal_api_version,
-                              const __DRIinterfaceMethods * interface,
-                              __GLcontextModes ** driver_modes)
-                            
+__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-       __DRIscreenPrivate *psp;
        static const __DRIversion ddx_expected = { 1, 2, 0 };
        static const __DRIversion dri_expected = { 4, 0, 0 };
        static const __DRIversion drm_expected = { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL };
+       NOUVEAUDRIPtr dri_priv = (NOUVEAUDRIPtr)psp->pDevPriv;
+
 #if NOUVEAU_DRM_HEADER_PATCHLEVEL != 10
 #error nouveau_drm.h version doesn't match expected version
 #endif
-       dri_interface = interface;
 
        if (!driCheckDriDdxDrmVersions2("nouveau",
-                                       dri_version, & dri_expected,
-                                       ddx_version, & ddx_expected,
-                                       drm_version, & drm_expected)) {
+                                       &psp->dri_version, & dri_expected,
+                                       &psp->ddx_version, & ddx_expected,
+                                       &psp->drm_version, & drm_expected))
                return NULL;
-       }
 
        // temporary lock step versioning
-       if (drm_expected.patch!=drm_version->patch) {
+       if (drm_expected.patch != psp->drm_version.patch) {
                __driUtilMessage("%s: wrong DRM version, expected %d, got %d\n",
-                               __func__,
-                               drm_expected.patch, drm_version->patch);
+                                __func__,
+                                drm_expected.patch, psp->drm_version.patch);
                return NULL;
        }
 
-       psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                      ddx_version, dri_version, drm_version,
-                                      frame_buffer, pSAREA, fd,
-                                      internal_api_version, &nouveauAPI);
-       if ( psp != NULL ) {
-               NOUVEAUDRIPtr dri_priv = (NOUVEAUDRIPtr)psp->pDevPriv;
-
-               *driver_modes = nouveauFillInModes(dri_priv->bpp,
-                                                  (dri_priv->bpp == 16) ? 16 : 24,
-                                                  (dri_priv->bpp == 16) ? 0  : 8,
-                                                  1
-                                                  );
-
-               /* Calling driInitExtensions here, with a NULL context pointer, does not actually
-                * enable the extensions.  It just makes sure that all the dispatch offsets for all
-                * the extensions that *might* be enables are known.  This is needed because the
-                * dispatch offsets need to be known when _mesa_context_create is called, but we can't
-                * enable the extensions until we have a context pointer.
-                * 
-                * Hello chicken.  Hello egg.  How are you two today?
-                */
-               driInitExtensions( NULL, common_extensions, GL_FALSE );
-               driInitExtensions( NULL,   nv10_extensions, GL_FALSE );
-               driInitExtensions( NULL,   nv10_extensions, GL_FALSE );
-               driInitExtensions( NULL,   nv30_extensions, GL_FALSE );
-               driInitExtensions( NULL,   nv40_extensions, GL_FALSE );
-               driInitExtensions( NULL,   nv50_extensions, GL_FALSE );
-       }
+       psp->DriverAPI = nouveauAPI;
+
+       /* Calling driInitExtensions here, with a NULL context
+        * pointer, does not actually enable the extensions.  It just
+        * makes sure that all the dispatch offsets for all the
+        * extensions that *might* be enables are known.  This is
+        * needed because the dispatch offsets need to be known when
+        * _mesa_context_create is called, but we can't enable the
+        * extensions until we have a context pointer.
+        * 
+        * Hello chicken.  Hello egg.  How are you two today?
+        */
+       driInitExtensions( NULL, common_extensions, GL_FALSE );
+       driInitExtensions( NULL,   nv10_extensions, GL_FALSE );
+       driInitExtensions( NULL,   nv10_extensions, GL_FALSE );
+       driInitExtensions( NULL,   nv30_extensions, GL_FALSE );
+       driInitExtensions( NULL,   nv40_extensions, GL_FALSE );
+       driInitExtensions( NULL,   nv50_extensions, GL_FALSE );
+
+       if (!nouveauInitDriver(psp))
+               return NULL;
 
-       return (void *) psp;
+       return nouveauFillInModes(dri_priv->bpp,
+                                 (dri_priv->bpp == 16) ? 16 : 24,
+                                 (dri_priv->bpp == 16) ? 0  : 8,
+                                 1);
 }
 
index 01b33d6..446280c 100644 (file)
@@ -403,7 +403,6 @@ r128InitDriver( __DRIscreenPrivate *sPriv )
 
 
 static struct __DriverAPIRec r128API = {
-   .InitDriver      = r128InitDriver,
    .DestroyScreen   = r128DestroyScreen,
    .CreateContext   = r128CreateContext,
    .DestroyContext  = r128DestroyContext,
@@ -503,64 +502,43 @@ r128FillInModes( unsigned pixel_bits, unsigned depth_bits,
 
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC
-void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                              const __GLcontextModes * modes,
-                              const __DRIversion * ddx_version,
-                              const __DRIversion * dri_version,
-                              const __DRIversion * drm_version,
-                              const __DRIframebuffer * frame_buffer,
-                              drmAddress pSAREA, int fd, 
-                              int internal_api_version,
-                              const __DRIinterfaceMethods * interface,
-                              __GLcontextModes ** driver_modes)
-                            
+__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = { 4, 0, 0 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 2, 2, 0 };
+   R128DRIPtr dri_priv = (R128DRIPtr) psp->pDevPriv;
 
-
-   dri_interface = interface;
-
+   psp->DriverAPI = r128API;
    if ( ! driCheckDriDdxDrmVersions2( "Rage128",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->drm_version, & drm_expected ) )
       return NULL;
-   }
-      
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &r128API);
-   if ( psp != NULL ) {
-      R128DRIPtr dri_priv = (R128DRIPtr) psp->pDevPriv;
-      *driver_modes = r128FillInModes( dri_priv->bpp,
-                                      (dri_priv->bpp == 16) ? 16 : 24,
-                                      (dri_priv->bpp == 16) ? 0  : 8,
-                                      (dri_priv->backOffset != dri_priv->depthOffset) );
-
-      /* Calling driInitExtensions here, with a NULL context pointer, does not actually
-       * enable the extensions.  It just makes sure that all the dispatch offsets for all
-       * the extensions that *might* be enables are known.  This is needed because the
-       * dispatch offsets need to be known when _mesa_context_create is called, but we can't
-       * enable the extensions until we have a context pointer.
-       *
-       * Hello chicken.  Hello egg.  How are you two today?
-       */
-      driInitExtensions( NULL, card_extensions, GL_FALSE );
-   }
 
-   return (void *) psp;
+   /* Calling driInitExtensions here, with a NULL context pointer,
+    * does not actually enable the extensions.  It just makes sure
+    * that all the dispatch offsets for all the extensions that
+    * *might* be enables are known.  This is needed because the
+    * dispatch offsets need to be known when _mesa_context_create is
+    * called, but we can't enable the extensions until we have a
+    * context pointer.
+    *
+    * Hello chicken.  Hello egg.  How are you two today?
+    */
+   driInitExtensions( NULL, card_extensions, GL_FALSE );
+
+   if (!r128InitDriver(psp))
+       return NULL;
+
+   return r128FillInModes( dri_priv->bpp,
+                          (dri_priv->bpp == 16) ? 16 : 24,
+                          (dri_priv->bpp == 16) ? 0  : 8,
+                          (dri_priv->backOffset != dri_priv->depthOffset) );
 }
index 9801322..b7e0b5a 100644 (file)
@@ -938,7 +938,6 @@ static void radeonDestroyContext(__DRIcontextPrivate * driContextPriv)
 
 #if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))
 static struct __DriverAPIRec radeonAPI = {
-   .InitDriver      = radeonInitDriver,
    .DestroyScreen   = radeonDestroyScreen,
    .CreateContext   = radeonCreateContext,
    .DestroyContext  = radeonDestroyContext,
@@ -959,7 +958,6 @@ static struct __DriverAPIRec radeonAPI = {
 };
 #else
 static const struct __DriverAPIRec r200API = {
-   .InitDriver      = radeonInitDriver,
    .DestroyScreen   = radeonDestroyScreen,
    .CreateContext   = r200CreateContext,
    .DestroyContext  = r200DestroyContext,
@@ -978,29 +976,16 @@ static const struct __DriverAPIRec r200API = {
 };
 #endif
 
+
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
+ * 
+ * \todo maybe fold this into intelInitDriver
  *
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC void *
-__DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                       const __GLcontextModes * modes,
-                       const __DRIversion * ddx_version,
-                       const __DRIversion * dri_version,
-                       const __DRIversion * drm_version,
-                       const __DRIframebuffer * frame_buffer,
-                       drmAddress pSAREA, int fd,
-                       int internal_api_version,
-                       const __DRIinterfaceMethods * interface,
-                       __GLcontextModes ** driver_modes)
+__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
 #if !RADEON_COMMON
    static const char *driver_name = "Radeon";
    static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 };
@@ -1017,57 +1002,46 @@ __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 1, 24, 0 };
 #endif
-
-   dri_interface = interface;
+   RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
 
    if ( ! driCheckDriDdxDrmVersions3( driver_name,
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->drm_version, & drm_expected ) ) {
       return NULL;
    }
 #if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &radeonAPI);
+   psp->DriverAPI = radeonAPI;
 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &r200API);
+   psp->DriverAPI = r200API;
 #endif
 
-   if ( psp != NULL ) {
-      RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
-      if (driver_modes) {
-         *driver_modes = radeonFillInModes( dri_priv->bpp,
-                                            (dri_priv->bpp == 16) ? 16 : 24,
-                                            (dri_priv->bpp == 16) ? 0  : 8,
-                                            (dri_priv->backOffset != dri_priv->depthOffset) );
-      }
-
-      /* Calling driInitExtensions here, with a NULL context pointer,
-       * does not actually enable the extensions.  It just makes sure
-       * that all the dispatch offsets for all the extensions that
-       * *might* be enables are known.  This is needed because the
-       * dispatch offsets need to be known when _mesa_context_create
-       * is called, but we can't enable the extensions until we have a
-       * context pointer.
-       *
-       * Hello chicken.  Hello egg.  How are you two today?
-       */
-      driInitExtensions( NULL, card_extensions, GL_FALSE );
+   /* Calling driInitExtensions here, with a NULL context pointer,
+    * does not actually enable the extensions.  It just makes sure
+    * that all the dispatch offsets for all the extensions that
+    * *might* be enables are known.  This is needed because the
+    * dispatch offsets need to be known when _mesa_context_create
+    * is called, but we can't enable the extensions until we have a
+    * context pointer.
+    *
+    * Hello chicken.  Hello egg.  How are you two today?
+    */
+   driInitExtensions( NULL, card_extensions, GL_FALSE );
 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
-      driInitExtensions( NULL, blend_extensions, GL_FALSE );
-      driInitSingleExtension( NULL, ARB_vp_extension );
-      driInitSingleExtension( NULL, NV_vp_extension );
-      driInitSingleExtension( NULL, ATI_fs_extension );
-      driInitExtensions( NULL, point_extensions, GL_FALSE );
+   driInitExtensions( NULL, blend_extensions, GL_FALSE );
+   driInitSingleExtension( NULL, ARB_vp_extension );
+   driInitSingleExtension( NULL, NV_vp_extension );
+   driInitSingleExtension( NULL, ATI_fs_extension );
+   driInitExtensions( NULL, point_extensions, GL_FALSE );
 #endif
-   }
 
-   return (void *) psp;
+   if (!radeonInitDriver(psp))
+       return NULL;
+
+   return radeonFillInModes( dri_priv->bpp,
+                            (dri_priv->bpp == 16) ? 16 : 24,
+                            (dri_priv->bpp == 16) ? 0  : 8,
+                            (dri_priv->backOffset != dri_priv->depthOffset) );
 }
 
 
index c66fd6d..7b0b006 100644 (file)
@@ -329,7 +329,6 @@ s3vUnbindContext( __DRIcontextPrivate *driContextPriv )
 
 
 static struct __DriverAPIRec s3vAPI = {
-   s3vInitDriver,
    s3vDestroyScreen,
    s3vCreateContext,
    s3vDestroyContext,
@@ -355,6 +354,9 @@ void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
    DEBUG(("__driCreateScreen: psp = %p\n", psp));
    psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &s3vAPI);
    DEBUG(("__driCreateScreen: psp = %p\n", psp));
+   if (!s3vInitDriver(psp))
+       return NULLL
+
    return (void *) psp;
 }
 #endif
index b2764f3..3750c89 100644 (file)
@@ -919,7 +919,6 @@ void savageGetLock( savageContextPtr imesa, GLuint flags )
 
 
 static const struct __DriverAPIRec savageAPI = {
-   savageInitDriver,
    savageDestroyScreen,
    savageCreateContext,
    savageDestroyContext,
@@ -1016,63 +1015,44 @@ savageFillInModes( unsigned pixel_bits, unsigned depth_bits,
 
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC
-void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                              const __GLcontextModes * modes,
-                              const __DRIversion * ddx_version,
-                              const __DRIversion * dri_version,
-                              const __DRIversion * drm_version,
-                              const __DRIframebuffer * frame_buffer,
-                              drmAddress pSAREA, int fd, 
-                              int internal_api_version,
-                              const __DRIinterfaceMethods * interface,
-                              __GLcontextModes ** driver_modes )
-                            
+__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = { 2, 0, 0 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 2, 1, 0 };
-
-   dri_interface = interface;
+   SAVAGEDRIPtr dri_priv = (SAVAGEDRIPtr)psp->pDevPriv;
 
    if ( ! driCheckDriDdxDrmVersions2( "Savage",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->drm_version, & drm_expected ) )
       return NULL;
-   }
-      
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &savageAPI);
-   if ( psp != NULL ) {
-      SAVAGEDRIPtr dri_priv = (SAVAGEDRIPtr)psp->pDevPriv;
-      *driver_modes = savageFillInModes( dri_priv->cpp*8,
-                                        (dri_priv->cpp == 2) ? 16 : 24,
-                                        (dri_priv->cpp == 2) ? 0  : 8,
-                                        (dri_priv->backOffset != dri_priv->depthOffset) );
-
-      /* Calling driInitExtensions here, with a NULL context pointer, does not actually
-       * enable the extensions.  It just makes sure that all the dispatch offsets for all
-       * the extensions that *might* be enables are known.  This is needed because the
-       * dispatch offsets need to be known when _mesa_context_create is called, but we can't
-       * enable the extensions until we have a context pointer.
-       *
-       * Hello chicken.  Hello egg.  How are you two today?
-       */
-      driInitExtensions( NULL, card_extensions, GL_FALSE );
-   }
 
-   return (void *) psp;
+   psp->DriverAPI = savageAPI;
+
+   /* Calling driInitExtensions here, with a NULL context pointer,
+    * does not actually enable the extensions.  It just makes sure
+    * that all the dispatch offsets for all the extensions that
+    * *might* be enables are known.  This is needed because the
+    * dispatch offsets need to be known when _mesa_context_create is
+    * called, but we can't enable the extensions until we have a
+    * context pointer.
+    *
+    * Hello chicken.  Hello egg.  How are you two today?
+    */
+   driInitExtensions( NULL, card_extensions, GL_FALSE );
+
+   if (!savageInitDriver(psp))
+       return NULL;
+
+   return savageFillInModes( dri_priv->cpp*8,
+                            (dri_priv->cpp == 2) ? 16 : 24,
+                            (dri_priv->cpp == 2) ? 0  : 8,
+                            (dri_priv->backOffset != dri_priv->depthOffset) );
 }
index a1275f0..79682a7 100644 (file)
@@ -304,7 +304,6 @@ sisInitDriver( __DRIscreenPrivate *sPriv )
 }
 
 static struct __DriverAPIRec sisAPI = {
-   .InitDriver      = sisInitDriver,
    .DestroyScreen   = sisDestroyScreen,
    .CreateContext   = sisCreateContext,
    .DestroyContext  = sisDestroyContext,
@@ -323,59 +322,42 @@ static struct __DriverAPIRec sisAPI = {
 
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
+ * 
+ * \todo maybe fold this into intelInitDriver
  *
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC
-void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                              const __GLcontextModes *modes,
-                              const __DRIversion *ddx_version,
-                              const __DRIversion *dri_version,
-                              const __DRIversion *drm_version,
-                              const __DRIframebuffer *frame_buffer,
-                              drmAddress pSAREA, int fd,
-                              int internal_api_version,
-                              const __DRIinterfaceMethods * interface,
-                              __GLcontextModes **driver_modes)
-
+__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = {0, 8, 0};
    static const __DRIversion dri_expected = {4, 0, 0};
    static const __DRIversion drm_expected = {1, 0, 0};
    static const char *driver_name = "SiS";
-   dri_interface = interface;
+   SISDRIPtr dri_priv = (SISDRIPtr)psp->pDevPriv;
 
-   if (!driCheckDriDdxDrmVersions2(driver_name, dri_version, &dri_expected,
-                                  ddx_version, &ddx_expected,
-                                  drm_version, &drm_expected)) {
+   if (!driCheckDriDdxDrmVersions2(driver_name,
+                                  &psp->dri_version, &dri_expected,
+                                  &psp->ddx_version, &ddx_expected,
+                                  &psp->drm_version, &drm_expected))
       return NULL;
-   }
 
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &sisAPI);
-   if (psp != NULL) {
-      SISDRIPtr dri_priv = (SISDRIPtr)psp->pDevPriv;
-      *driver_modes = sisFillInModes(dri_priv->bytesPerPixel * 8);
-
-      /* Calling driInitExtensions here, with a NULL context pointer, does not actually
-       * enable the extensions.  It just makes sure that all the dispatch offsets for all
-       * the extensions that *might* be enables are known.  This is needed because the
-       * dispatch offsets need to be known when _mesa_context_create is called, but we can't
-       * enable the extensions until we have a context pointer.
-       *
-       * Hello chicken.  Hello egg.  How are you two today?
-       */
-      driInitExtensions( NULL, card_extensions, GL_FALSE );
-   }
+   psp->DriverAPI = sisAPI;
+
+   /* Calling driInitExtensions here, with a NULL context pointer,
+    * does not actually enable the extensions.  It just makes sure
+    * that all the dispatch offsets for all the extensions that
+    * *might* be enables are known.  This is needed because the
+    * dispatch offsets need to be known when _mesa_context_create is
+    * called, but we can't enable the extensions until we have a
+    * context pointer.
+    *
+    * Hello chicken.  Hello egg.  How are you two today?
+    */
+   driInitExtensions( NULL, card_extensions, GL_FALSE );
+
+   if (!sisInitDriver(psp))
+       return NULL;
 
-   return (void *)psp;
+   return sisFillInModes(dri_priv->bytesPerPixel * 8);
 }
index e9033c5..081a534 100644 (file)
@@ -345,7 +345,6 @@ tdfxSwapBuffers( __DRIdrawablePrivate *driDrawPriv )
 
 
 static const struct __DriverAPIRec tdfxAPI = {
-   .InitDriver      = tdfxInitDriver,
    .DestroyScreen   = tdfxDestroyScreen,
    .CreateContext   = tdfxCreateContext,
    .DestroyContext  = tdfxDestroyContext,
@@ -431,69 +430,50 @@ static __GLcontextModes *tdfxFillInModes(unsigned pixel_bits,
 }
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
+ * 
+ * \todo maybe fold this into intelInitDriver
  *
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
- *         failure.
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC
-void *__DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                             const __GLcontextModes * modes,
-                             const __DRIversion * ddx_version,
-                             const __DRIversion * dri_version,
-                             const __DRIversion * drm_version,
-                             const __DRIframebuffer * frame_buffer,
-                             drmAddress pSAREA, int fd,
-                             int internal_api_version,
-                             const __DRIinterfaceMethods * interface,
-                             __GLcontextModes ** driver_modes)
+__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = { 1, 1, 0 };
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 1, 0, 0 };
 
-   dri_interface = interface;
+   /* divined from tdfx_dri.c, sketchy */
+   TDFXDRIPtr dri_priv = (TDFXDRIPtr) psp->pDevPriv;
+
+   /* XXX i wish it was like this */
+   /* bpp = dri_priv->bpp */
+   int bpp = (dri_priv->cpp > 2) ? 24 : 16;
 
    if ( ! driCheckDriDdxDrmVersions2( "tdfx",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->drm_version, & drm_expected ) )
       return NULL;
-   }
 
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &tdfxAPI);
-
-   if (psp != NULL) {
-      /* divined from tdfx_dri.c, sketchy */
-      TDFXDRIPtr dri_priv = (TDFXDRIPtr) psp->pDevPriv;
-      int bpp = (dri_priv->cpp > 2) ? 24 : 16;
+   psp->DriverAPI = tdfxAPI;
+
+   /* Calling driInitExtensions here, with a NULL context pointer,
+    * does not actually enable the extensions.  It just makes sure
+    * that all the dispatch offsets for all the extensions that
+    * *might* be enables are known.  This is needed because the
+    * dispatch offsets need to be known when _mesa_context_create is
+    * called, but we can't enable the extensions until we have a
+    * context pointer.
+    *
+    * Hello chicken.  Hello egg.  How are you two today?
+    */
+   driInitExtensions( NULL, card_extensions, GL_FALSE );
+   driInitExtensions( NULL, napalm_extensions, GL_FALSE );
 
-      /* XXX i wish it was like this */
-      /* bpp = dri_priv->bpp */
+   if (!tdfxInitDriver(psp))
+      return NULL;
       
-      *driver_modes = tdfxFillInModes(bpp, (bpp == 16) ? 16 : 24,
-                               (bpp == 16) ? 0 : 8,
-                               (dri_priv->backOffset!=dri_priv->depthOffset));
-
-      /* Calling driInitExtensions here, with a NULL context pointer, does not actually
-       * enable the extensions.  It just makes sure that all the dispatch offsets for all
-       * the extensions that *might* be enables are known.  This is needed because the
-       * dispatch offsets need to be known when _mesa_context_create is called, but we can't
-       * enable the extensions until we have a context pointer.
-       *
-       * Hello chicken.  Hello egg.  How are you two today?
-       */
-      driInitExtensions( NULL, card_extensions, GL_FALSE );
-      driInitExtensions( NULL, napalm_extensions, GL_FALSE );
-   }
-
-   return (void *)psp;
+   return tdfxFillInModes(bpp, (bpp == 16) ? 16 : 24,
+                         (bpp == 16) ? 0 : 8,
+                         (dri_priv->backOffset!=dri_priv->depthOffset));
 }
index 1d2a49e..81098bc 100644 (file)
@@ -418,7 +418,6 @@ tridentInitDriver(__DRIscreenPrivate *sPriv)
 }
 
 static struct __DriverAPIRec tridentAPI = {
-   tridentInitDriver,
    tridentDestroyScreen,
    tridentCreateContext,
    tridentDestroyContext,
@@ -430,43 +429,36 @@ static struct __DriverAPIRec tridentAPI = {
 };
 
 
-PUBLIC void *
-__DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                       const __GLcontextModes * modes,
-                       const __DRIversion * ddx_version,
-                       const __DRIversion * dri_version,
-                       const __DRIversion * drm_version,
-                       const __DRIframebuffer * frame_buffer,
-                       drmAddress pSAREA, int fd,
-                       int internal_api_version,
-                       const __DRIinterfaceMethods * interface,
-                       __GLcontextModes ** driver_modes)
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ * 
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
+ */
+__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-    __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = { 4, 0, 0 };
    static const __DRIversion dri_expected = { 3, 1, 0 };
    static const __DRIversion drm_expected = { 1, 0, 0 };
-
-   dri_interface = interface;
-
+   
    if ( ! driCheckDriDdxDrmVersions2( "Trident",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->drm_version, & drm_expected ) )
       return NULL;
-   }
 
-    psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                   ddx_version, dri_version, drm_version,
-                                   frame_buffer, pSAREA, fd,
-                                   internal_api_version, &tridentAPI);
+   psp->DriverAPI = tridentAPI;
+
+   if (!tridentInitDriver(psp))
+       return NULL;
 
-    if ( psp != NULL ) {
+    /* Wait... what?  This driver doesn't report any modes... */
 #if 0
-       TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv;
-       *driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8,
-                                          GL_TRUE );
+   TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv;
+   *driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8,
+                                      GL_TRUE );
 #endif
-    }
-    return (void *) psp;
+
+   return NULL;
 }
index 22e4bce..53f4c5c 100644 (file)
@@ -325,7 +325,6 @@ viaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
 
 
 static struct __DriverAPIRec viaAPI = {
-   .InitDriver      = viaInitDriver,
    .DestroyScreen   = viaDestroyScreen,
    .CreateContext   = viaCreateContext,
    .DestroyContext  = viaDestroyContext,
@@ -407,66 +406,47 @@ viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
 
 
 /**
- * This is the bootstrap function for the driver.  libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-PUBLIC
-void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc,
-                              const __GLcontextModes * modes,
-                              const __DRIversion * ddx_version,
-                              const __DRIversion * dri_version,
-                              const __DRIversion * drm_version,
-                              const __DRIframebuffer * frame_buffer,
-                              drmAddress pSAREA, int fd, 
-                              int internal_api_version,
-                              const __DRIinterfaceMethods * interface,
-                              __GLcontextModes ** driver_modes)
-                            
+__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
    static const __DRIversion ddx_expected = { VIA_DRIDDX_VERSION_MAJOR,
                                               VIA_DRIDDX_VERSION_MINOR,
                                               VIA_DRIDDX_VERSION_PATCH };
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 2, 3, 0 };
    static const char *driver_name = "Unichrome";
-
-   dri_interface = interface;
+   VIADRIPtr dri_priv = (VIADRIPtr) psp->pDevPriv;
 
    if ( ! driCheckDriDdxDrmVersions2( driver_name,
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->drm_version, & drm_expected) )
       return NULL;
-   }
-      
-   psp = __driUtilCreateNewScreen(scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &viaAPI);
-   if ( psp != NULL ) {
-      VIADRIPtr dri_priv = (VIADRIPtr) psp->pDevPriv;
-      *driver_modes = viaFillInModes( dri_priv->bytesPerPixel * 8,
-                                     GL_TRUE );
-
-      /* Calling driInitExtensions here, with a NULL context pointer, does not actually
-       * enable the extensions.  It just makes sure that all the dispatch offsets for all
-       * the extensions that *might* be enables are known.  This is needed because the
-       * dispatch offsets need to be known when _mesa_context_create is called, but we can't
-       * enable the extensions until we have a context pointer.
-       *
-       * Hello chicken.  Hello egg.  How are you two today?
-       */
-      driInitExtensions( NULL, card_extensions, GL_FALSE );
-   }
 
-   return (void *) psp;
+   psp->DriverAPI = viaAPI;
+
+   /* Calling driInitExtensions here, with a NULL context pointer,
+    * does not actually enable the extensions.  It just makes sure
+    * that all the dispatch offsets for all the extensions that
+    * *might* be enables are known.  This is needed because the
+    * dispatch offsets need to be known when _mesa_context_create is
+    * called, but we can't enable the extensions until we have a
+    * context pointer.
+    *
+    * Hello chicken.  Hello egg.  How are you two today?
+    */
+   driInitExtensions( NULL, card_extensions, GL_FALSE );
+
+   if (!viaInitDriver(psp))
+       return NULL;
+
+   return viaFillInModes( dri_priv->bytesPerPixel * 8, GL_TRUE );
+
 }