Mesa (gallium-drm-driver-descriptor): gallium: drm api compat helper

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Mon Jun 7 11:16:33 PDT 2010


Module: Mesa
Branch: gallium-drm-driver-descriptor
Commit: e72b15aa47c24b920c708e1dc47f69a070d50d51
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e72b15aa47c24b920c708e1dc47f69a070d50d51

Author: Jakob Bornecrantz <jakob at vmware.com>
Date:   Tue Jun  1 04:00:02 2010 +0100

gallium: drm api compat helper

This is temporary untill all drivers have moved
to the new drm driver descriptor interface.

---

 .../auxiliary/target-helpers/drm_api_compat.h      |   46 ++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/target-helpers/drm_api_compat.h b/src/gallium/auxiliary/target-helpers/drm_api_compat.h
new file mode 100644
index 0000000..324c6f2
--- /dev/null
+++ b/src/gallium/auxiliary/target-helpers/drm_api_compat.h
@@ -0,0 +1,46 @@
+/*
+ * This file contain a small backwards compatible shim between
+ * the old depricated drm_api and the drm_driver interface.
+ */
+
+#ifndef DRM_API_COMPAT_H
+#define DRM_API_COMPAT_H
+
+#ifdef _DRM_API_H_
+#error "Included drm_api.h before drm_api_compat.h"
+#endif
+
+#include "state_tracker/drm_driver.h"
+
+/*
+ * XXX Hack, can't include both drm_api and drm_driver. Due to name
+ * collition of winsys_handle, just use a define to rename it.
+ */
+#define winsys_handle HACK_winsys_handle
+#include "state_tracker/drm_api.h"
+#undef winsys_handle
+
+static INLINE struct pipe_screen *
+drm_api_compat_create_screen(int fd)
+{
+   static struct drm_api *api;
+   if (!api)
+      api = drm_api_create();
+
+   if (!api)
+      return NULL;
+
+   return api->create_screen(api, fd);
+}
+
+/**
+ * Instanciate a drm_driver descriptor.
+ */
+#define DRM_API_COMPAT_STRUCT(name_str, driver_name_str) \
+struct drm_driver_descriptor driver_descriptor = {       \
+   .name = name_str,                                     \
+   .driver_name = driver_name_str,                       \
+   .create_screen = drm_api_compat_create_screen,        \
+};
+
+#endif



More information about the mesa-commit mailing list