diff options
author | Rob Clark <rob@ti.com> | 2012-05-17 02:37:26 -0600 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-17 08:54:09 -0700 |
commit | 3080b838158f1b17bd806c3fd7b9086ba3054a04 (patch) | |
tree | de5bc96bd1dd934e8d689197887350f092c0858f /drivers/staging | |
parent | 8b6b569eac2e74d0b2a1822790f725a9a6abc2be (diff) | |
download | blackbird-obmc-linux-3080b838158f1b17bd806c3fd7b9086ba3054a04.tar.gz blackbird-obmc-linux-3080b838158f1b17bd806c3fd7b9086ba3054a04.zip |
staging: drm/omap: initial dmabuf/prime import support
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>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/omapdrm/omap_drv.c | 2 | ||||
-rw-r--r-- | drivers/staging/omapdrm/omap_drv.h | 2 | ||||
-rw-r--r-- | drivers/staging/omapdrm/omap_gem_dmabuf.c | 22 |
3 files changed, 26 insertions, 0 deletions
diff --git a/drivers/staging/omapdrm/omap_drv.c b/drivers/staging/omapdrm/omap_drv.c index 1f559f445a30..0d2acca376ca 100644 --- a/drivers/staging/omapdrm/omap_drv.c +++ b/drivers/staging/omapdrm/omap_drv.c @@ -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, diff --git a/drivers/staging/omapdrm/omap_drv.h b/drivers/staging/omapdrm/omap_drv.h index 73a606e72e4c..f238d574da0c 100644 --- a/drivers/staging/omapdrm/omap_drv.h +++ b/drivers/staging/omapdrm/omap_drv.h @@ -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) { diff --git a/drivers/staging/omapdrm/omap_gem_dmabuf.c b/drivers/staging/omapdrm/omap_gem_dmabuf.c index aba4b3424933..42728e0cc194 100644 --- a/drivers/staging/omapdrm/omap_gem_dmabuf.c +++ b/drivers/staging/omapdrm/omap_gem_dmabuf.c @@ -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); +} |