Commit cef67496 authored by Chad Versace's avatar Chad Versace
Browse files

gbm: Allow user to provide device path in environment



If waffle_display_connect() is passed name=NULL, then Waffle's GBM backend will
now open the device path defined by environment variable WAFFLE_GBM_DEVICE. If
WAFFLE_GBM_DEVICE is unset, then Waffle's behavior remains as before: it uses
udev to search for a sensible DRM device node.
Requested-by: Ilia Mirkin's avatarIlia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: default avatarChad Versace <chad.versace@intel.com>
parent e9c4e291
......@@ -105,10 +105,15 @@ struct waffle_display;
uses the value of the environment variable <envar>WAYLAND_DISPLAY</envar>.
</para>
<para>
On GBM, the function opens the device at the filepath <parameter>name</parameter>. If
<parameter>name</parameter> is null, then it iterates using udev through the set of card devices in the drm
subsystem, which are usually located in <filename>/dev/dri</filename>, and attempts to open each in turn
with <code>open(O_RDWR | O_CLOEXEC)</code> until successful.
On GBM, the function opens the device at the filepath <parameter>name</parameter>.
If <parameter>name</parameter> is NULL, then the function uses the value of environment variable
<envar>WAFFLE_GBM_DEVICE</envar>.
If <parameter>name</parameter> is null and <envar>WAFFLE_GBM_DEVICE</envar> is unset, then the function
iterates using udev through the set of card devices in the drm subsystem, which are usually located in
<filename>/dev/dri</filename>, and attempts to open each in turn with <code>open(O_RDWR | O_CLOEXEC)</code>
until successful.
</para>
</listitem>
</varlistentry>
......
......@@ -128,15 +128,23 @@ wgbm_display_connect(struct wcore_platform *wc_plat,
if (self == NULL)
return NULL;
if (name == NULL) {
name = getenv("WAFFLE_GBM_DEVICE");
}
if (name != NULL) {
fd = open(name, O_RDWR | O_CLOEXEC);
if (fd < 0) {
wcore_errorf(WAFFLE_ERROR_UNKNOWN,
"failed to open gbm device \"%s\"", name);
goto error;
}
} else {
fd = wgbm_get_default_fd();
}
if (fd < 0) {
wcore_errorf(WAFFLE_ERROR_UNKNOWN, "open drm file for gbm failed");
goto error;
if (fd < 0) {
wcore_errorf(WAFFLE_ERROR_UNKNOWN, "open drm file for gbm failed");
goto error;
}
}
dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment