Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Aug 2013 09:58:31 +0000 (UTC)
From:      Jean-Sebastien Pedron <dumbbell@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r254836 - head/sys/dev/drm2
Message-ID:  <201308250958.r7P9wVcr087371@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dumbbell
Date: Sun Aug 25 09:58:31 2013
New Revision: 254836
URL: http://svnweb.freebsd.org/changeset/base/254836

Log:
  drm: Support gem_open_object() and gem_close_object() callbacks
  
  ... in struct drm_driver_info.

Modified:
  head/sys/dev/drm2/drmP.h
  head/sys/dev/drm2/drm_gem.c

Modified: head/sys/dev/drm2/drmP.h
==============================================================================
--- head/sys/dev/drm2/drmP.h	Sun Aug 25 09:53:00 2013	(r254835)
+++ head/sys/dev/drm2/drmP.h	Sun Aug 25 09:58:31 2013	(r254836)
@@ -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;
 

Modified: head/sys/dev/drm2/drm_gem.c
==============================================================================
--- head/sys/dev/drm2/drm_gem.c	Sun Aug 25 09:53:00 2013	(r254835)
+++ head/sys/dev/drm2/drm_gem.c	Sun Aug 25 09:58:31 2013	(r254836)
@@ -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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308250958.r7P9wVcr087371>