summaryrefslogtreecommitdiff
path: root/src/loader/loader.c
diff options
context:
space:
mode:
authorAxel Davy <axel.davy@ens.fr>2014-06-08 19:47:48 -0400
committerDave Airlie <airlied@gmail.com>2014-07-01 13:07:40 +1000
commit3ecd9e1a93817180fa5b280e5fe11c903cca38ba (patch)
treef650a9e9d722667c24625d787d7738bdf9a08bb0 /src/loader/loader.c
parent7ab925a6aafca106e7682dfc21e7c9351380809e (diff)
loader: Use drirc device_id parameter in complement to DRI_PRIME
DRI_PRIME is not very handy, because you have to launch the executable with it set, which is not always easy to do. By using drirc, the user specifies the target executable and the device to use. After that the program will be launched everytime on the target device. For example if .drirc contains: <driconf> <device driver="loader"> <application name="Glmark2" executable="glmark2"> <option name="device_id" value="pci-0000_01_00_0" /> </application> </device> </driconf> Then glmark2 will use if possible the render-node of ID_PATH_TAG pci-0000_01_00_0. v2: Fix compilation issue v3: Add "-lm" and rebase. Signed-off-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/loader/loader.c')
-rw-r--r--src/loader/loader.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/loader/loader.c b/src/loader/loader.c
index 19d99d52ef2..47e1f58746c 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -74,6 +74,10 @@
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
+#ifdef USE_DRICONF
+#include "xmlconfig.h"
+#include "xmlpool.h"
+#endif
#endif
#ifdef HAVE_SYSFS
#include <sys/stat.h>
@@ -323,9 +327,22 @@ drm_open_device(const char *device_name)
return fd;
}
+#ifdef USE_DRICONF
+const char __driConfigOptionsLoader[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_INITIALIZATION
+ DRI_CONF_DEVICE_ID_PATH_TAG()
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+#endif
+
int loader_get_user_preferred_fd(int default_fd, int *different_device)
{
struct udev *udev;
+#ifdef USE_DRICONF
+ driOptionCache defaultInitOptions;
+ driOptionCache userInitOptions;
+#endif
const char *dri_prime = getenv("DRI_PRIME");
char *prime = NULL;
int is_different_device = 0, fd = default_fd;
@@ -337,6 +354,16 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device)
if (dri_prime)
prime = strdup(dri_prime);
+#ifdef USE_DRICONF
+ else {
+ driParseOptionInfo(&defaultInitOptions, __driConfigOptionsLoader);
+ driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0, "loader");
+ if (driCheckOption(&userInitOptions, "device_id", DRI_STRING))
+ prime = strdup(driQueryOptionstr(&userInitOptions, "device_id"));
+ driDestroyOptionCache(&userInitOptions);
+ driDestroyOptionInfo(&defaultInitOptions);
+ }
+#endif
if (prime == NULL) {
*different_device = 0;