Esempio n. 1
0
/* This is actually the entrypoint to the entire driver,
 * called by the target bootstrap code.
 */
struct svga_winsys_screen *
svga_drm_winsys_screen_create(int fd)
{
   struct vmw_winsys_screen *vws;
   struct dri1_api_version drm_ver;
   drmVersionPtr ver;

   ver = drmGetVersion(fd);
   if (ver == NULL)
      return NULL;

   drm_ver.major = ver->version_major;
   drm_ver.minor = ver->version_minor;
   drm_ver.patch_level = 0; /* ??? */

   drmFreeVersion(ver);
   if (!vmw_dri1_check_version(&drm_ver, &drm_required,
			       &drm_compat, "vmwgfx drm driver"))
      return NULL;

   vws = vmw_winsys_create(fd);
   if (!vws)
      goto out_no_vws;

   /* XXX do this properly */
   vws->base.surface_from_handle = vws->base.have_gb_objects ?
      vmw_drm_gb_surface_from_handle : vmw_drm_surface_from_handle;
   vws->base.surface_get_handle = vmw_drm_surface_get_handle;

   return &vws->base;

out_no_vws:
   return NULL;
}
Esempio n. 2
0
/* This is actually the entrypoint to the entire driver, called by the
 * libGL (or EGL, or ...) code via the drm_api_hooks table at the
 * bottom of the file.
 */
static struct pipe_screen *
vmw_drm_create_screen(struct drm_api *drm_api,
                      int fd,
                      struct drm_create_screen_arg *arg)
{
   struct vmw_winsys_screen *vws;
   struct pipe_screen *screen;
   struct dri1_create_screen_arg *dri1;

   if (arg != NULL) {
      switch (arg->mode) {
      case DRM_CREATE_NORMAL:
	 break;
      case DRM_CREATE_DRI1:
	 dri1 = (struct dri1_create_screen_arg *)arg;
	 if (!vmw_dri1_check_version(&dri1->ddx_version, &ddx_required,
				     &ddx_compat, "ddx - driver api"))
	    return NULL;
	 if (!vmw_dri1_check_version(&dri1->dri_version, &dri_required,
				     &dri_compat, "dri info"))
	    return NULL;
	 if (!vmw_dri1_check_version(&dri1->drm_version, &drm_required,
				     &drm_compat, "vmwgfx drm driver"))
	    return NULL;
	 dri1->api = &dri1_api_hooks;
	 break;
      default:
	 return NULL;
      }
   }

   vws = vmw_winsys_create( fd );
   if (!vws)
      goto out_no_vws;

   screen = svga_screen_create( &vws->base );
   if (!screen)
      goto out_no_screen;

   return screen;

   /* Failure cases:
    */
out_no_screen:
   vmw_winsys_destroy( vws );

out_no_vws:
   return NULL;
}