simple-dmabuf-drm: use vfunc for drm_device_destroy

Remove ifdef clutter and makes sure it's only called for the active
backend.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Guido Günther 7 years ago committed by Pekka Paalanen
parent 512d29f828
commit 4fc3a679eb
  1. 24
      clients/simple-dmabuf-drm.c

@ -83,6 +83,7 @@ struct drm_device {
int (*export_bo_to_prime)(struct buffer *buf); int (*export_bo_to_prime)(struct buffer *buf);
int (*map_bo)(struct buffer *buf); int (*map_bo)(struct buffer *buf);
void (*unmap_bo)(struct buffer *buf); void (*unmap_bo)(struct buffer *buf);
void (*device_destroy)(struct buffer *buf);
}; };
struct buffer { struct buffer {
@ -199,6 +200,13 @@ intel_unmap_bo(struct buffer *my_buf)
{ {
drm_intel_gem_bo_unmap_gtt(my_buf->intel_bo); drm_intel_gem_bo_unmap_gtt(my_buf->intel_bo);
} }
static void
intel_device_destroy(struct buffer *my_buf)
{
drm_intel_bufmgr_destroy(my_buf->bufmgr);
}
#endif /* HAVE_LIBDRM_INTEL */ #endif /* HAVE_LIBDRM_INTEL */
#ifdef HAVE_LIBDRM_FREEDRENO #ifdef HAVE_LIBDRM_FREEDRENO
#define ALIGN(v, a) ((v + a - 1) & ~(a - 1)) #define ALIGN(v, a) ((v + a - 1) & ~(a - 1))
@ -249,6 +257,12 @@ static void
fd_unmap_bo(struct buffer *buf) fd_unmap_bo(struct buffer *buf)
{ {
} }
static void
fd_device_destroy(struct buffer *buf)
{
fd_device_del(buf->fd_dev);
}
#endif /* HAVE_LIBDRM_FREEDRENO */ #endif /* HAVE_LIBDRM_FREEDRENO */
static void static void
@ -279,13 +293,7 @@ fill_content(struct buffer *my_buf)
static void static void
drm_device_destroy(struct buffer *buf) drm_device_destroy(struct buffer *buf)
{ {
#ifdef HAVE_LIBDRM_INTEL buf->dev->device_destroy(buf);
drm_intel_bufmgr_destroy(buf->bufmgr);
#endif
#ifdef HAVE_LIBDRM_FREEDRENO
fd_device_del(buf->fd_dev);
#endif
close(buf->drm_fd); close(buf->drm_fd);
} }
@ -311,6 +319,7 @@ drm_device_init(struct buffer *buf)
dev->export_bo_to_prime = intel_bo_export_to_prime; dev->export_bo_to_prime = intel_bo_export_to_prime;
dev->map_bo = intel_map_bo; dev->map_bo = intel_map_bo;
dev->unmap_bo = intel_unmap_bo; dev->unmap_bo = intel_unmap_bo;
dev->device_destroy = intel_device_destroy;
} }
#endif #endif
#ifdef HAVE_LIBDRM_FREEDRENO #ifdef HAVE_LIBDRM_FREEDRENO
@ -320,6 +329,7 @@ drm_device_init(struct buffer *buf)
dev->export_bo_to_prime = fd_bo_export_to_prime; dev->export_bo_to_prime = fd_bo_export_to_prime;
dev->map_bo = fd_map_bo; dev->map_bo = fd_map_bo;
dev->unmap_bo = fd_unmap_bo; dev->unmap_bo = fd_unmap_bo;
dev->device_destroy = fd_device_destroy;
} }
#endif #endif
else { else {

Loading…
Cancel
Save