aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/freedreno/freedreno_screen.c5
-rw-r--r--src/gallium/drivers/nouveau/nouveau_screen.c6
-rw-r--r--src/gallium/include/state_tracker/drm_driver.h9
-rw-r--r--src/gallium/state_trackers/dri/drm/dri2.c2
-rw-r--r--src/gallium/state_trackers/egl/common/native_helper.c1
-rw-r--r--src/gallium/state_trackers/egl/x11/native_dri2.c1
-rw-r--r--src/gallium/winsys/i915/drm/i915_drm_buffer.c6
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_bo.c6
-rw-r--r--src/gallium/winsys/svga/drm/vmw_screen_dri.c6
9 files changed, 38 insertions, 4 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
index d07cc0b323e..319e29f3ada 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -361,6 +361,11 @@ fd_screen_bo_from_handle(struct pipe_screen *pscreen,
struct fd_screen *screen = fd_screen(pscreen);
struct fd_bo *bo;
+ if (whandle->type != DRM_API_HANDLE_TYPE_SHARED) {
+ DBG("Attempt to import unsupported handle type %d", whandle->type);
+ return NULL;
+ }
+
bo = fd_bo_from_name(screen->dev, whandle->handle);
if (!bo) {
DBG("ref name 0x%08x failed", whandle->handle);
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
index 5b35ee47c12..248d1641c5a 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -86,6 +86,12 @@ nouveau_screen_bo_from_handle(struct pipe_screen *pscreen,
struct nouveau_bo *bo = 0;
int ret;
+ if (whandle->type != DRM_API_HANDLE_TYPE_SHARED) {
+ debug_printf("%s: attempt to import unsupported handle type %d\n",
+ __FUNCTION__, whandle->type);
+ return NULL;
+ }
+
ret = nouveau_bo_name_ref(dev, whandle->handle, &bo);
if (ret) {
debug_printf("%s: ref name 0x%08x failed with %d\n",
diff --git a/src/gallium/include/state_tracker/drm_driver.h b/src/gallium/include/state_tracker/drm_driver.h
index f9bd2220e98..5b76d87a69f 100644
--- a/src/gallium/include/state_tracker/drm_driver.h
+++ b/src/gallium/include/state_tracker/drm_driver.h
@@ -10,6 +10,8 @@ struct pipe_resource;
#define DRM_API_HANDLE_TYPE_SHARED 0
#define DRM_API_HANDLE_TYPE_KMS 1
+#define DRM_API_HANDLE_TYPE_FD 2
+
/**
* For use with pipe_screen::{texture_from_handle|texture_get_handle}.
@@ -17,9 +19,10 @@ struct pipe_resource;
struct winsys_handle
{
/**
- * Unused for texture_from_handle, always
- * DRM_API_HANDLE_TYPE_SHARED. Input to texture_get_handle,
- * use TEXTURE_USAGE to select handle for kms or ipc.
+ * Input for texture_from_handle, valid values are
+ * DRM_API_HANDLE_TYPE_SHARED or DRM_API_HANDLE_TYPE_FD.
+ * Input to texture_get_handle,
+ * to select handle for kms, flink, or prime.
*/
unsigned type;
/**
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index 27f214780fc..2a2f8ac7498 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -265,6 +265,7 @@ dri2_drawable_process_buffers(struct dri_context *ctx,
templ.format = format;
templ.bind = bind;
+ whandle.type = DRM_API_HANDLE_TYPE_SHARED;
whandle.handle = buf->name;
whandle.stride = buf->pitch;
@@ -578,6 +579,7 @@ dri2_create_image_from_name(__DRIscreen *_screen,
memset(&whandle, 0, sizeof(whandle));
whandle.handle = name;
+ whandle.type = DRM_API_HANDLE_TYPE_SHARED;
whandle.stride = pitch * util_format_get_blocksize(pf);
img->texture = screen->base.screen->resource_from_handle(screen->base.screen,
diff --git a/src/gallium/state_trackers/egl/common/native_helper.c b/src/gallium/state_trackers/egl/common/native_helper.c
index b578a8afe96..d1e1acdab4c 100644
--- a/src/gallium/state_trackers/egl/common/native_helper.c
+++ b/src/gallium/state_trackers/egl/common/native_helper.c
@@ -427,6 +427,7 @@ drm_display_import_native_buffer(struct native_display *ndpy,
memset(&wsh, 0, sizeof(wsh));
wsh.handle = nbuf->u.drm.name;
+ wsh.type = DRM_API_HANDLE_TYPE_SHARED;
wsh.stride = nbuf->u.drm.stride;
res = screen->resource_from_handle(screen, &nbuf->u.drm.templ, &wsh);
diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
index 3c58979e295..bbd962d6962 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -173,6 +173,7 @@ dri2_surface_process_drawable_buffers(struct native_surface *nsurf,
}
memset(&whandle, 0, sizeof(whandle));
+ whandle.type = DRM_API_HANDLE_TYPE_SHARED;
whandle.stride = xbuf->pitch;
whandle.handle = xbuf->name;
dri2surf->textures[natt] = dri2dpy->base.screen->resource_from_handle(
diff --git a/src/gallium/winsys/i915/drm/i915_drm_buffer.c b/src/gallium/winsys/i915/drm/i915_drm_buffer.c
index ac66af333df..38e06193c61 100644
--- a/src/gallium/winsys/i915/drm/i915_drm_buffer.c
+++ b/src/gallium/winsys/i915/drm/i915_drm_buffer.c
@@ -95,9 +95,13 @@ i915_drm_buffer_from_handle(struct i915_winsys *iws,
unsigned *stride)
{
struct i915_drm_winsys *idws = i915_drm_winsys(iws);
- struct i915_drm_buffer *buf = CALLOC_STRUCT(i915_drm_buffer);
+ struct i915_drm_buffer *buf;
uint32_t tile = 0, swizzle = 0;
+ if (whandle->type != DRM_API_HANDLE_TYPE_SHARED)
+ return NULL;
+
+ buf = CALLOC_STRUCT(i915_drm_buffer);
if (!buf)
return NULL;
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 3019a525cf8..744df1b745e 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -877,6 +877,9 @@ static struct pb_buffer *radeon_winsys_bo_from_handle(struct radeon_winsys *rws,
memset(&open_arg, 0, sizeof(open_arg));
+ if (whandle->type != DRM_API_HANDLE_TYPE_SHARED)
+ return NULL;
+
/* We must maintain a list of pairs <handle, bo>, so that we always return
* the same BO for one particular handle. If we didn't do that and created
* more than one BO for the same handle and then relocated them in a CS,
@@ -991,6 +994,9 @@ static boolean radeon_winsys_bo_get_handle(struct pb_buffer *buffer,
whandle->handle = bo->flink;
} else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
whandle->handle = bo->handle;
+ } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) {
+ /* TODO: Implement */
+ return FALSE;
}
whandle->stride = stride;
diff --git a/src/gallium/winsys/svga/drm/vmw_screen_dri.c b/src/gallium/winsys/svga/drm/vmw_screen_dri.c
index 511cca73aea..6323a8ae2c4 100644
--- a/src/gallium/winsys/svga/drm/vmw_screen_dri.c
+++ b/src/gallium/winsys/svga/drm/vmw_screen_dri.c
@@ -163,6 +163,12 @@ vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
int ret;
int i;
+ if (whandle->type != DRM_API_HANDLE_TYPE_SHARED) {
+ vmw_error("Attempt to import unknown handle type %d\n",
+ whandle->type);
+ return NULL;
+ }
+
/**
* The vmware device specific handle is the hardware SID.
* FIXME: We probably want to move this to the ioctl implementations.