diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2013-01-15 15:47:42 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2013-02-07 22:39:08 -0500 |
commit | 89177644a7b6306e6084a89eab7e290f4bfef397 (patch) | |
tree | e8bac93d626a14df07b2d904797c5d0e86f6251a /include/drm | |
parent | 6504d0d9900a2c05ea1fbab2ec008bf442993d94 (diff) |
drm: add prime helpers
Instead of reimplementing all of the dma_buf functionality in every driver,
create helpers drm_prime_import and drm_prime_export that implement them in
terms of new, lower-level hook functions:
gem_prime_pin: callback when a buffer is created, used to pin buffers into GTT
gem_prime_get_sg_table: convert a drm_gem_object to an sg_table for export
gem_prime_import_sg_table: convert an sg_table into a drm_gem_object
gem_prime_vmap, gem_prime_vunmap: map and unmap an object
These hooks are optional; drivers can opt in by using drm_gem_prime_import and
drm_gem_prime_export as the .gem_prime_import and .gem_prime_export fields of
struct drm_driver.
v2:
- Drop .begin_cpu_access. None of the drivers this code replaces implemented
it. Having it here was a leftover from when I was trying to include i915 in
this rework.
- Use mutex_lock instead of mutex_lock_interruptible, as these three drivers
did. This patch series shouldn't change that behavior.
- Rename helpers to gem_prime_get_sg_table and gem_prime_import_sg_table.
Rename struct sg_table* variables to 'sgt' for clarity.
- Update drm.tmpl for these new hooks.
v3:
- Pass the vaddr down to the driver. This lets drivers that just call vunmap on
the pointer avoid having to store the pointer in their GEM private structures.
- Move documentation into a /** DOC */ comment in drm_prime.c and include it in
drm.tmpl with a !P line. I tried to use !F lines to include documentation of
the individual functions from drmP.h, but the docproc / kernel-doc scripts
barf on that file, so hopefully this is good enough for now.
- apply refcount fix from commit be8a42ae60addd8b6092535c11b42d099d6470ec
("drm/prime: drop reference on imported dma-buf come from gem")
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm')
-rw-r--r-- | include/drm/drmP.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 3aaa50d64451..2d94d7413d71 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -930,6 +930,14 @@ struct drm_driver { | |||
930 | /* import dmabuf -> GEM */ | 930 | /* import dmabuf -> GEM */ |
931 | struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev, | 931 | struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev, |
932 | struct dma_buf *dma_buf); | 932 | struct dma_buf *dma_buf); |
933 | /* low-level interface used by drm_gem_prime_{import,export} */ | ||
934 | int (*gem_prime_pin)(struct drm_gem_object *obj); | ||
935 | struct sg_table *(*gem_prime_get_sg_table)(struct drm_gem_object *obj); | ||
936 | struct drm_gem_object *(*gem_prime_import_sg_table)( | ||
937 | struct drm_device *dev, size_t size, | ||
938 | struct sg_table *sgt); | ||
939 | void *(*gem_prime_vmap)(struct drm_gem_object *obj); | ||
940 | void (*gem_prime_vunmap)(struct drm_gem_object *obj, void *vaddr); | ||
933 | 941 | ||
934 | /* vga arb irq handler */ | 942 | /* vga arb irq handler */ |
935 | void (*vgaarb_irq)(struct drm_device *dev, bool state); | 943 | void (*vgaarb_irq)(struct drm_device *dev, bool state); |
@@ -1562,9 +1570,13 @@ extern int drm_clients_info(struct seq_file *m, void* data); | |||
1562 | extern int drm_gem_name_info(struct seq_file *m, void *data); | 1570 | extern int drm_gem_name_info(struct seq_file *m, void *data); |
1563 | 1571 | ||
1564 | 1572 | ||
1573 | extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, | ||
1574 | struct drm_gem_object *obj, int flags); | ||
1565 | extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, | 1575 | extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, |
1566 | struct drm_file *file_priv, uint32_t handle, uint32_t flags, | 1576 | struct drm_file *file_priv, uint32_t handle, uint32_t flags, |
1567 | int *prime_fd); | 1577 | int *prime_fd); |
1578 | extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev, | ||
1579 | struct dma_buf *dma_buf); | ||
1568 | extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, | 1580 | extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, |
1569 | struct drm_file *file_priv, int prime_fd, uint32_t *handle); | 1581 | struct drm_file *file_priv, int prime_fd, uint32_t *handle); |
1570 | 1582 | ||