minigbm: Add userspace reference counting

When a dmabuf is imported multiple times, further imports after the
first one are not refcounted, i.e. the first close() will lose the
dmabuf. To avoid this, user space needs to track the number of imports
and only close() the dmabuf once the last import is closed.

BUG=None
TEST=Ran graphics_Gbm on minnie.  Still passes.

Change-Id: Iba63556ccc94ac5d49be2f827ceead85e0e22c9c
Reviewed-on: https://chromium-review.googlesource.com/366041
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
diff --git a/helpers.h b/helpers.h
index ecb49f3..de17f7f 100644
--- a/helpers.h
+++ b/helpers.h
@@ -16,5 +16,10 @@
 		       uint32_t format, uint32_t flags);
 int drv_dumb_bo_destroy(struct bo *bo);
 int drv_gem_bo_destroy(struct bo *bo);
-
+uintptr_t drv_get_reference_count(struct driver *drv, struct bo *bo,
+				  size_t plane);
+void drv_increment_reference_count(struct driver *drv, struct bo *bo,
+				   size_t plane);
+void drv_decrement_reference_count(struct driver *drv, struct bo *bo,
+				   size_t plane);
 #endif