drm/exynos: added new funtion to get/put dma address.
authorInki Dae <inki.dae@samsung.com>
Fri, 16 Mar 2012 09:47:06 +0000 (18:47 +0900)
committerDave Airlie <airlied@redhat.com>
Tue, 20 Mar 2012 09:40:22 +0000 (09:40 +0000)
this function would be used for drm based 2d acceleration driver
to get/put dma address through gem handle.
when exynos_drm_get_dma_address is called reference count of
gem object would be increased not to be released by gem close and
when exynos_drm_put_dma_address is called the reference count of
this gem object would be decreased to be released.

Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/exynos/exynos_drm_gem.c
drivers/gpu/drm/exynos/exynos_drm_gem.h

index 730093fed51250cdec9769093296a7c1a0e29141..b5c6f3cfc698decacfb053703262ebf40b9179ea 100644 (file)
@@ -386,6 +386,64 @@ int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
        return 0;
 }
 
+void *exynos_drm_gem_get_dma_addr(struct drm_device *dev,
+                                       unsigned int gem_handle,
+                                       struct drm_file *file_priv)
+{
+       struct exynos_drm_gem_obj *exynos_gem_obj;
+       struct drm_gem_object *obj;
+
+       obj = drm_gem_object_lookup(dev, file_priv, gem_handle);
+       if (!obj) {
+               DRM_ERROR("failed to lookup gem object.\n");
+               return ERR_PTR(-EINVAL);
+       }
+
+       exynos_gem_obj = to_exynos_gem_obj(obj);
+
+       if (exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG) {
+               DRM_DEBUG_KMS("not support NONCONTIG type.\n");
+               drm_gem_object_unreference_unlocked(obj);
+
+               /* TODO */
+               return ERR_PTR(-EINVAL);
+       }
+
+       return &exynos_gem_obj->buffer->dma_addr;
+}
+
+void exynos_drm_gem_put_dma_addr(struct drm_device *dev,
+                                       unsigned int gem_handle,
+                                       struct drm_file *file_priv)
+{
+       struct exynos_drm_gem_obj *exynos_gem_obj;
+       struct drm_gem_object *obj;
+
+       obj = drm_gem_object_lookup(dev, file_priv, gem_handle);
+       if (!obj) {
+               DRM_ERROR("failed to lookup gem object.\n");
+               return;
+       }
+
+       exynos_gem_obj = to_exynos_gem_obj(obj);
+
+       if (exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG) {
+               DRM_DEBUG_KMS("not support NONCONTIG type.\n");
+               drm_gem_object_unreference_unlocked(obj);
+
+               /* TODO */
+               return;
+       }
+
+       drm_gem_object_unreference_unlocked(obj);
+
+       /*
+        * decrease obj->refcount one more time because we has already
+        * increased it at exynos_drm_gem_get_dma_addr().
+        */
+       drm_gem_object_unreference_unlocked(obj);
+}
+
 int exynos_drm_gem_map_offset_ioctl(struct drm_device *dev, void *data,
                                    struct drm_file *file_priv)
 {
index 096267d5a715f6a582b9505869be3dfa62969534..e40fbad8b70552abf83d2cf86ccd2cd4e10a5630 100644 (file)
@@ -88,6 +88,24 @@ struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
 int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
                                struct drm_file *file_priv);
 
+/*
+ * get dma address from gem handle and this function could be used for
+ * other drivers such as 2d/3d acceleration drivers.
+ * with this function call, gem object reference count would be increased.
+ */
+void *exynos_drm_gem_get_dma_addr(struct drm_device *dev,
+                                       unsigned int gem_handle,
+                                       struct drm_file *file_priv);
+
+/*
+ * put dma address from gem handle and this function could be used for
+ * other drivers such as 2d/3d acceleration drivers.
+ * with this function call, gem object reference count would be decreased.
+ */
+void exynos_drm_gem_put_dma_addr(struct drm_device *dev,
+                                       unsigned int gem_handle,
+                                       struct drm_file *file_priv);
+
 /* get buffer offset to map to user space. */
 int exynos_drm_gem_map_offset_ioctl(struct drm_device *dev, void *data,
                                    struct drm_file *file_priv);