]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: drm/omap: initial dmabuf/prime import support
authorRob Clark <rob@ti.com>
Thu, 17 May 2012 08:37:26 +0000 (02:37 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 May 2012 15:54:09 +0000 (08:54 -0700)
This adds support to re-import omapdrm's own buffers.  Importing buffers
allocated by other drivers can be added later, but for now is not needed
(we don't yet have any other exportering drivers to test with).

Signed-off-by: Rob Clark <rob@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/omapdrm/omap_drv.c
drivers/staging/omapdrm/omap_drv.h
drivers/staging/omapdrm/omap_gem_dmabuf.c

index 1f559f445a304928104f30ded89956715f0faf46..0d2acca376ca7c971fa64178be0a622ac6070f91 100644 (file)
@@ -767,7 +767,9 @@ static struct drm_driver omap_drm_driver = {
                .debugfs_cleanup = omap_debugfs_cleanup,
 #endif
                .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+               .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
                .gem_prime_export = omap_gem_prime_export,
+               .gem_prime_import = omap_gem_prime_import,
                .gem_init_object = omap_gem_init_object,
                .gem_free_object = omap_gem_free_object,
                .gem_vm_ops = &omap_gem_vm_ops,
index 73a606e72e4ccaa305c6584dd50f6ab12800687b..f238d574da0c80546700e0d96fffca42a9c20d51 100644 (file)
@@ -162,6 +162,8 @@ size_t omap_gem_mmap_size(struct drm_gem_object *obj);
 
 struct dma_buf * omap_gem_prime_export(struct drm_device *dev,
                struct drm_gem_object *obj, int flags);
+struct drm_gem_object * omap_gem_prime_import(struct drm_device *dev,
+               struct dma_buf *buffer);
 
 static inline int align_pitch(int pitch, int width, int bpp)
 {
index aba4b3424933760ca6a78514d73c6c24266b7811..42728e0cc1945816574dd5879b8bcdc907c2bb92 100644 (file)
@@ -196,3 +196,25 @@ struct dma_buf * omap_gem_prime_export(struct drm_device *dev,
 {
        return dma_buf_export(obj, &omap_dmabuf_ops, obj->size, 0600);
 }
+
+struct drm_gem_object * omap_gem_prime_import(struct drm_device *dev,
+               struct dma_buf *buffer)
+{
+       struct drm_gem_object *obj;
+
+       /* is this one of own objects? */
+       if (buffer->ops == &omap_dmabuf_ops) {
+               obj = buffer->priv;
+               /* is it from our device? */
+               if (obj->dev == dev) {
+                       drm_gem_object_reference(obj);
+                       return obj;
+               }
+       }
+
+       /*
+        * TODO add support for importing buffers from other devices..
+        * for now we don't need this but would be nice to add eventually
+        */
+       return ERR_PTR(-EINVAL);
+}