Commit f0014881 authored by Noralf Trønnes's avatar Noralf Trønnes

drm/driver: Add defaults for .gem_prime_export/import callbacks

The majority of drivers use drm_gem_prime_export() and
drm_gem_prime_import() for these callbacks so let's make them the
default.
Signed-off-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181110145647.17580-2-noralf@tronnes.org
parent f577f7ea
...@@ -234,6 +234,13 @@ efficient. ...@@ -234,6 +234,13 @@ efficient.
Contact: Daniel Vetter Contact: Daniel Vetter
Defaults for .gem_prime_import and export
-----------------------------------------
Most drivers don't need to set drm_driver->gem_prime_import and
->gem_prime_export now that drm_gem_prime_import() and drm_gem_prime_export()
are the default.
Core refactorings Core refactorings
================= =================
......
...@@ -529,7 +529,10 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev, ...@@ -529,7 +529,10 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev,
return dmabuf; return dmabuf;
} }
if (dev->driver->gem_prime_export)
dmabuf = dev->driver->gem_prime_export(dev, obj, flags); dmabuf = dev->driver->gem_prime_export(dev, obj, flags);
else
dmabuf = drm_gem_prime_export(dev, obj, flags);
if (IS_ERR(dmabuf)) { if (IS_ERR(dmabuf)) {
/* normally the created dma-buf takes ownership of the ref, /* normally the created dma-buf takes ownership of the ref,
* but if that fails then drop the ref * but if that fails then drop the ref
...@@ -762,7 +765,10 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev, ...@@ -762,7 +765,10 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev,
/* never seen this one, need to import */ /* never seen this one, need to import */
mutex_lock(&dev->object_name_lock); mutex_lock(&dev->object_name_lock);
if (dev->driver->gem_prime_import)
obj = dev->driver->gem_prime_import(dev, dma_buf); obj = dev->driver->gem_prime_import(dev, dma_buf);
else
obj = drm_gem_prime_import(dev, dma_buf);
if (IS_ERR(obj)) { if (IS_ERR(obj)) {
ret = PTR_ERR(obj); ret = PTR_ERR(obj);
goto out_unlock; goto out_unlock;
......
...@@ -471,6 +471,8 @@ struct drm_driver { ...@@ -471,6 +471,8 @@ struct drm_driver {
* @gem_prime_export: * @gem_prime_export:
* *
* export GEM -> dmabuf * export GEM -> dmabuf
*
* This defaults to drm_gem_prime_export() if not set.
*/ */
struct dma_buf * (*gem_prime_export)(struct drm_device *dev, struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
struct drm_gem_object *obj, int flags); struct drm_gem_object *obj, int flags);
...@@ -478,6 +480,8 @@ struct drm_driver { ...@@ -478,6 +480,8 @@ struct drm_driver {
* @gem_prime_import: * @gem_prime_import:
* *
* import dmabuf -> GEM * import dmabuf -> GEM
*
* This defaults to drm_gem_prime_import() if not set.
*/ */
struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev, struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
struct dma_buf *dma_buf); struct dma_buf *dma_buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment