svga: remove open-coded vmw_ioctl_surface_req()

Submitted by Emil Velikov on June 3, 2019, 5:32 p.m.

Details

Message ID 20190603173225.19146-1-emil.l.velikov@gmail.com
State New
Headers show
Series "svga: remove open-coded vmw_ioctl_surface_req()" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Emil Velikov June 3, 2019, 5:32 p.m.
From: Emil Velikov <emil.velikov@collabora.com>

Cc: Brian Paul <brianp@vmware.com>
Cc: Jose Fonseca <jfonseca@vmware.com>
Cc: Roland Scheidegger <sroland@vmware.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
 src/gallium/winsys/svga/drm/vmw_screen_dri.c | 29 ++++----------------
 1 file changed, 6 insertions(+), 23 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/winsys/svga/drm/vmw_screen_dri.c b/src/gallium/winsys/svga/drm/vmw_screen_dri.c
index a85ee18e45b..264c61a5f69 100644
--- a/src/gallium/winsys/svga/drm/vmw_screen_dri.c
+++ b/src/gallium/winsys/svga/drm/vmw_screen_dri.c
@@ -221,7 +221,7 @@  vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
     union drm_vmw_surface_reference_arg arg;
     struct drm_vmw_surface_arg *req = &arg.req;
     struct drm_vmw_surface_create_req *rep = &arg.rep;
-    uint32_t handle = 0;
+    boolean needs_unref = FALSE;
     struct drm_vmw_size size;
     SVGA3dSize base_size;
     int ret;
@@ -233,28 +233,11 @@  vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
        return NULL;
     }
 
-    switch (whandle->type) {
-    case WINSYS_HANDLE_TYPE_SHARED:
-    case WINSYS_HANDLE_TYPE_KMS:
-       handle = whandle->handle;
-       break;
-    case WINSYS_HANDLE_TYPE_FD:
-       ret = drmPrimeFDToHandle(vws->ioctl.drm_fd, whandle->handle,
-                                &handle);
-       if (ret) {
-	  vmw_error("Failed to get handle from prime fd %d.\n",
-		    (int) whandle->handle);
-	  return NULL;
-       }
-       break;
-    default:
-       vmw_error("Attempt to import unsupported handle type %d.\n",
-                 whandle->type);
-       return NULL;
-    }
-
     memset(&arg, 0, sizeof(arg));
-    req->sid = handle;
+    ret = vmw_ioctl_surface_req(vws, whandle, req, &needs_unref);
+    if (ret)
+        return NULL;
+
     rep->size_addr = (unsigned long)&size;
 
     ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_REF_SURFACE,
@@ -263,7 +246,7 @@  vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
     /*
      * Need to close the handle we got from prime.
      */
-    if (whandle->type == WINSYS_HANDLE_TYPE_FD)
+    if (needs_unref)
        vmw_ioctl_surface_destroy(vws, handle);
 
     if (ret) {