summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2017-06-30 11:06:06 +0200
committerNicolai Hähnle <nicolai.haehnle@amd.com>2017-07-13 13:27:46 +0200
commit77c9fd956ad06876903a1f750ec9be436fb14aeb (patch)
treee8afb049e85c01e7cc587a148e615dcb5b6908fd
parentf6b715a26231bac81da6e7ce2f45f19a79642a8f (diff)
st/dri: implement v2 of DRI_ConfigOptions
-rw-r--r--src/gallium/auxiliary/pipe-loader/pipe_loader.c13
-rw-r--r--src/gallium/auxiliary/pipe-loader/pipe_loader.h16
-rw-r--r--src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c23
-rw-r--r--src/gallium/state_trackers/dri/dri_screen.c5
4 files changed, 55 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.c b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
index cb37f30c02..39d33d848a 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
@@ -34,6 +34,8 @@
#include "util/xmlconfig.h"
#include "util/xmlpool.h"
+#include <string.h>
+
#ifdef _MSC_VER
#include <stdlib.h>
#define PATH_MAX _MAX_PATH
@@ -107,6 +109,17 @@ pipe_loader_load_options(struct pipe_loader_device *dev)
dev->driver_name);
}
+char *
+pipe_loader_get_driinfo_xml(const char *driver_name)
+{
+ char *xml = pipe_loader_drm_get_driinfo_xml(driver_name);
+
+ if (!xml)
+ xml = strdup(gallium_driinfo_xml);
+
+ return xml;
+}
+
struct pipe_screen *
pipe_loader_create_screen(struct pipe_loader_device *dev,
struct pipe_screen_config *config)
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index a4502ae258..b6e81cf391 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -114,6 +114,14 @@ void
pipe_loader_load_options(struct pipe_loader_device *dev);
/**
+ * Get the driinfo XML string used by the given driver.
+ *
+ * The returned string is heap-allocated.
+ */
+char *
+pipe_loader_get_driinfo_xml(const char *driver_name);
+
+/**
* Release resources allocated for a list of devices.
*
* Should be called when the specified devices are no longer in use to
@@ -197,6 +205,14 @@ pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev);
bool
pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd);
+/**
+ * Get the driinfo XML used for the DRM driver of the given name, if any.
+ *
+ * The returned string is heap-allocated.
+ */
+char *
+pipe_loader_drm_get_driinfo_xml(const char *driver_name);
+
extern const char gallium_driinfo_xml[];
#ifdef __cplusplus
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 92b242178d..5c8c7509e0 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -32,6 +32,7 @@
#include <fcntl.h>
#include <stdio.h>
+#include <string.h>
#include <xf86drm.h>
#include <unistd.h>
@@ -299,6 +300,28 @@ pipe_loader_drm_create_screen(struct pipe_loader_device *dev,
return ddev->dd->create_screen(ddev->fd, config);
}
+char *
+pipe_loader_drm_get_driinfo_xml(const char *driver_name)
+{
+ char *xml = NULL;
+ struct util_dl_library *lib = NULL;
+ const struct drm_driver_descriptor *dd =
+ get_driver_descriptor(driver_name, &lib);
+ if (!dd)
+ goto out;
+
+ const struct drm_conf_ret *conf = dd->configuration(DRM_CONF_XML_OPTIONS);
+ if (!conf)
+ goto out;
+
+ xml = strdup((const char *)conf->val.val_pointer);
+
+out:
+ if (lib)
+ util_dl_close(lib);
+ return xml;
+}
+
static const struct pipe_loader_ops pipe_loader_drm_ops = {
.create_screen = pipe_loader_drm_create_screen,
.configuration = pipe_loader_drm_configuration,
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index c13009105a..de6feb9509 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -49,8 +49,9 @@
#undef false
const __DRIconfigOptionsExtension gallium_config_options = {
- .base = { __DRI_CONFIG_OPTIONS, 1 },
- .xml = gallium_driinfo_xml
+ .base = { __DRI_CONFIG_OPTIONS, 2 },
+ .xml = gallium_driinfo_xml,
+ .getXml = pipe_loader_get_driinfo_xml
};
#define false 0