forked from Minki/linux
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>
This commit is contained in:
parent
8b6b569eac
commit
3080b83815
@ -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,
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user