clients/simple-dmabuf-drm: add freedreno support alongside intel

abstract drm specific bits to struct drm_device and support running on
freedreno. introduce 'modifier' event.

v2: rebase to master, deprecate 'format' event.

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
diff --git a/configure.ac b/configure.ac
index bb33753..14c742f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -385,12 +385,21 @@
                              [do not build the simple dmabuf drm client]),,
               enable_simple_dmabuf_drm_client="auto")
 if ! test "x$enable_simple_dmabuf_drm_client" = "xno"; then
-  PKG_CHECK_MODULES(SIMPLE_DMABUF_DRM_CLIENT, [wayland-client libdrm libdrm_intel],
-		    have_simple_dmabuf_drm_client=yes, have_simple_dmabuf_drm_client=no)
-  if test "x$have_simple_dmabuf_drm_client" = "xno" -a "x$enable_simple_dmabuf_drm_client" = "xyes"; then
-    AC_MSG_ERROR([DRM dmabuf client explicitly enabled, but libdrm_intel couldn't be found])
+  PKG_CHECK_MODULES(SIMPLE_DMABUF_DRM_CLIENT, [wayland-client libdrm],
+    [PKG_CHECK_MODULES(LIBDRM_PLATFORM, [libdrm_freedreno],
+      AC_DEFINE([HAVE_LIBDRM_FREEDRENO], [1], [Build freedreno dmabuf client]) have_simple_dmabuf_drm_client=freedreno,
+    [PKG_CHECK_MODULES(LIBDRM_PLATFORM, [libdrm_intel],
+      AC_DEFINE([HAVE_LIBDRM_INTEL], [1], [Build intel dmabuf client]) have_simple_dmabuf_drm_client=intel,
+    have_simple_dmabuf_drm_client=unsupported)])],
+  have_simple_dmabuf_drm_client=unsupported)
+
+  if test "x$have_simple_dmabuf_drm_client" = "xunsupported" -a "x$enable_simple_dmabuf_drm_client" = "xyes"; then
+    AC_MSG_ERROR([DRM dmabuf client explicitly enabled, but libdrm_intel or libdrm_freedreno not found])
   fi
-  enable_simple_dmabuf_drm_client="$have_simple_dmabuf_drm_client"
+
+  if test "x$have_simple_dmabuf_drm_client" = "xfreedreno" -o "x$have_simple_dmabuf_drm_client" = "xintel"; then
+    enable_simple_dmabuf_drm_client="yes"
+  fi
 fi
 AM_CONDITIONAL(BUILD_SIMPLE_DMABUF_DRM_CLIENT, test "x$enable_simple_dmabuf_drm_client" = "xyes")