drm: Support gem_open_object() and gem_close_object() callbacks

... in struct drm_driver_info.
This commit is contained in:
Jean-Sébastien Pédron 2013-08-25 09:58:31 +00:00
parent b5185a8933
commit 1eeccc8f4c
2 changed files with 22 additions and 4 deletions

View File

@ -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;

View File

@ -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);
}