From 5fb641a29bfb4a33da964e1e9af523f3472015c6 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 13 Jan 2014 12:03:46 +0100 Subject: [PATCH] hotplug: Extend OdevAttributes for server-managed fd support With systemd-logind support, the xserver, rather than the drivers will be responsible for opening/closing the fd for drm nodes. This commit adds a fd member to OdevAttributes to store the fd to pass it along to the driver. systemd-logind tracks devices by their chardev major + minor numbers, so also add OdevAttributes to store the major and minor. Signed-off-by: Hans de Goede Reviewed-by: Dave Airlie --- hw/xfree86/common/xf86platformBus.c | 14 ++++++++++++++ hw/xfree86/common/xf86platformBus.h | 1 + include/hotplug.h | 10 ++++++++++ 3 files changed, 25 insertions(+) diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c index 97d606a46..e1d7bd048 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c @@ -128,6 +128,20 @@ xf86_get_platform_device_unowned(int index) TRUE : FALSE; } +struct xf86_platform_device * +xf86_find_platform_device_by_devnum(int major, int minor) +{ + int i, attr_major, attr_minor; + + for (i = 0; i < xf86_num_platform_devices; i++) { + attr_major = xf86_get_platform_int_attrib(i, ODEV_ATTRIB_MAJOR, 0); + attr_minor = xf86_get_platform_int_attrib(i, ODEV_ATTRIB_MINOR, 0); + if (attr_major == major && attr_minor == minor) + return &xf86_platform_devices[i]; + } + return NULL; +} + /* * xf86IsPrimaryPlatform() -- return TRUE if primary device * is a platform device and it matches this one. diff --git a/hw/xfree86/common/xf86platformBus.h b/hw/xfree86/common/xf86platformBus.h index 9a492609a..3e27d3483 100644 --- a/hw/xfree86/common/xf86platformBus.h +++ b/hw/xfree86/common/xf86platformBus.h @@ -35,6 +35,7 @@ struct xf86_platform_device { /* xf86_platform_device flags */ #define XF86_PDEV_UNOWNED 0x01 +#define XF86_PDEV_SERVER_FD 0x02 #ifdef XSERVER_PLATFORM_BUS int xf86platformProbe(void); diff --git a/include/hotplug.h b/include/hotplug.h index 0e78721b0..1d9364eee 100644 --- a/include/hotplug.h +++ b/include/hotplug.h @@ -78,6 +78,12 @@ config_odev_free_attributes(struct OdevAttributes *attribs); #define ODEV_ATTRIB_SYSPATH 2 /* DRI-style bus id */ #define ODEV_ATTRIB_BUSID 3 +/* Server managed FD */ +#define ODEV_ATTRIB_FD 4 +/* Major number of the device node pointed to by ODEV_ATTRIB_PATH */ +#define ODEV_ATTRIB_MAJOR 5 +/* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */ +#define ODEV_ATTRIB_MINOR 6 typedef void (*config_odev_probe_proc_ptr)(struct OdevAttributes *attribs); void config_odev_probe(config_odev_probe_proc_ptr probe_callback); @@ -88,4 +94,8 @@ void DeleteGPUDeviceRequest(struct OdevAttributes *attribs); #endif #define ServerIsNotSeat0() (SeatId && strcmp(SeatId, "seat0")) + +struct xf86_platform_device * +xf86_find_platform_device_by_devnum(int major, int minor); + #endif /* HOTPLUG_H */