From 1eeccc8f4c586af7942fe9774ae9e78af9abbf02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Sun, 25 Aug 2013 09:58:31 +0000 Subject: [PATCH] drm: Support gem_open_object() and gem_close_object() callbacks ... in struct drm_driver_info. --- sys/dev/drm2/drmP.h | 2 ++ sys/dev/drm2/drm_gem.c | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/sys/dev/drm2/drmP.h b/sys/dev/drm2/drmP.h index 089f2770ac37..23e57a9a6495 100644 --- a/sys/dev/drm2/drmP.h +++ b/sys/dev/drm2/drmP.h @@ -737,6 +737,8 @@ struct drm_driver_info { int (*gem_init_object)(struct drm_gem_object *obj); void (*gem_free_object)(struct drm_gem_object *obj); + int (*gem_open_object)(struct drm_gem_object *, struct drm_file *); + void (*gem_close_object)(struct drm_gem_object *, struct drm_file *); struct cdev_pager_ops *gem_pager_ops; diff --git a/sys/dev/drm2/drm_gem.c b/sys/dev/drm2/drm_gem.c index fc977643d5b5..56045800fc9c 100644 --- a/sys/dev/drm2/drm_gem.c +++ b/sys/dev/drm2/drm_gem.c @@ -242,24 +242,40 @@ int drm_gem_handle_create(struct drm_file *file_priv, struct drm_gem_object *obj, uint32_t *handle) { - int error; + struct drm_device *dev = obj->dev; + int ret; - error = drm_gem_name_create(&file_priv->object_names, obj, handle); - if (error != 0) - return (error); + ret = drm_gem_name_create(&file_priv->object_names, obj, handle); + if (ret != 0) + return (ret); drm_gem_object_handle_reference(obj); + + if (dev->driver->gem_open_object) { + ret = dev->driver->gem_open_object(obj, file_priv); + if (ret) { + drm_gem_handle_delete(file_priv, *handle); + return ret; + } + } + return (0); } int drm_gem_handle_delete(struct drm_file *file_priv, uint32_t handle) { + struct drm_device *dev; struct drm_gem_object *obj; obj = drm_gem_names_remove(&file_priv->object_names, handle); if (obj == NULL) return (EINVAL); + + dev = obj->dev; + if (dev->driver->gem_close_object) + dev->driver->gem_close_object(obj, file_priv); drm_gem_object_handle_unreference_unlocked(obj); + return (0); }