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);
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",
#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}.
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;
/**
templ.format = format;
templ.bind = bind;
+ whandle.type = DRM_API_HANDLE_TYPE_SHARED;
whandle.handle = buf->name;
whandle.stride = buf->pitch;
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,
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);
}
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(
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;
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,
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;
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.