aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/os-support/linux/lnx_platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/os-support/linux/lnx_platform.c')
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_platform.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_platform.c b/xorg-server/hw/xfree86/os-support/linux/lnx_platform.c
index 1865b31b9..109a9a774 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_platform.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_platform.c
@@ -18,16 +18,38 @@
#include "xf86Bus.h"
#include "hotplug.h"
+#include "systemd-logind.h"
static Bool
get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
{
drmSetVersion sv;
char *buf;
- int fd;
+ int major, minor, fd;
int err = 0;
+ Bool paused, server_fd = FALSE;
+
+ major = config_odev_get_int_attribute(attribs, ODEV_ATTRIB_MAJOR, 0);
+ minor = config_odev_get_int_attribute(attribs, ODEV_ATTRIB_MINOR, 0);
+
+ fd = systemd_logind_take_fd(major, minor, path, &paused);
+ if (fd != -1) {
+ if (paused) {
+ LogMessage(X_ERROR,
+ "Error systemd-logind returned paused fd for drm node\n");
+ systemd_logind_release_fd(major, minor);
+ return FALSE;
+ }
+ if (!config_odev_add_int_attribute(attribs, ODEV_ATTRIB_FD, fd)) {
+ systemd_logind_release_fd(major, minor);
+ return FALSE;
+ }
+ server_fd = TRUE;
+ }
+
+ if (fd == -1)
+ fd = open(path, O_RDWR, O_CLOEXEC);
- fd = open(path, O_RDWR, O_CLOEXEC);
if (fd == -1)
return FALSE;
@@ -44,16 +66,20 @@ get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
/* for a delayed probe we've already added the device */
if (delayed_index == -1) {
- xf86_add_platform_device(attribs);
+ xf86_add_platform_device(attribs, FALSE);
delayed_index = xf86_num_platform_devices - 1;
}
+ if (server_fd)
+ xf86_platform_devices[delayed_index].flags |= XF86_PDEV_SERVER_FD;
+
buf = drmGetBusid(fd);
xf86_add_platform_device_attrib(delayed_index,
ODEV_ATTRIB_BUSID, buf);
drmFreeBusid(buf);
out:
- close(fd);
+ if (!server_fd)
+ close(fd);
return (err == 0);
}
@@ -118,17 +144,11 @@ xf86PlatformReprobeDevice(int index, struct OdevAttributes *attribs)
void
xf86PlatformDeviceProbe(struct OdevAttributes *attribs)
{
- struct OdevAttribute *attrib;
int i;
char *path = NULL;
Bool ret;
- xorg_list_for_each_entry(attrib, &attribs->list, member) {
- if (attrib->attrib_id == ODEV_ATTRIB_PATH) {
- path = attrib->attrib_name;
- break;
- }
- }
+ path = config_odev_get_attribute(attribs, ODEV_ATTRIB_PATH);
if (!path)
goto out_free;
@@ -148,8 +168,7 @@ xf86PlatformDeviceProbe(struct OdevAttributes *attribs)
if (!xf86VTOwner()) {
/* if we don't currently own the VT then don't probe the device,
just mark it as unowned for later use */
- attribs->unowned = TRUE;
- xf86_add_platform_device(attribs);
+ xf86_add_platform_device(attribs, TRUE);
return;
}