diff options
author | Chad Versace <chad.versace@intel.com> | 2015-08-21 08:57:46 -0700 |
---|---|---|
committer | Chad Versace <chad.versace@intel.com> | 2015-08-21 09:36:50 -0700 |
commit | 060ed76aacf61c4ecf4879d9a348e1a68cf8a796 (patch) | |
tree | 43e66e94faa36dadf0c9d52e48fd08bf0858f7eb | |
parent | 5c2c7e807bd8274feab872f74973ef5154d64167 (diff) | |
download | waffle-060ed76aacf61c4ecf4879d9a348e1a68cf8a796.tar.gz |
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 <imirkin@alum.mit.edu>
Signed-off-by: Chad Versace <chad.versace@intel.com>
(cherry picked from commit cef67496e379b660601f64ab2ddf7cf06307b8aa)
-rw-r--r-- | man/waffle_display.3.xml | 13 | ||||
-rw-r--r-- | src/waffle/gbm/wgbm_display.c | 18 |
2 files changed, 22 insertions, 9 deletions
diff --git a/man/waffle_display.3.xml b/man/waffle_display.3.xml index 824a01a..9896247 100644 --- a/man/waffle_display.3.xml +++ b/man/waffle_display.3.xml @@ -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> diff --git a/src/waffle/gbm/wgbm_display.c b/src/waffle/gbm/wgbm_display.c index 76e6c32..edb714f 100644 --- a/src/waffle/gbm/wgbm_display.c +++ b/src/waffle/gbm/wgbm_display.c @@ -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); |