[PATCH 12/12] config-udev: Add delayed input device probing
Hans de Goede
hdegoede at redhat.com
Wed Jan 15 06:32:26 PST 2014
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
config/udev.c | 35 ++++++++++++++++++++++++++--
hw/xfree86/os-support/linux/systemd-logind.c | 4 ++++
include/hotplug.h | 4 ++++
3 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/config/udev.c b/config/udev.c
index 58bc3d9..3e5889e 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -59,6 +59,8 @@ struct input_device_info {
};
static struct udev_monitor *udev_monitor;
+static struct input_device_info *new_input_devices;
+static int new_input_devices_count;
#ifdef CONFIG_UDEV_KMS
static Bool
@@ -302,8 +304,17 @@ device_added(struct udev_device *udev_device)
fd = systemd_logind_get_fd(devnum, path, &paused);
- /* FIXME check paused, if paused put the device on a list for probing
- later */
+ if (paused) {
+ /* Put on new_input_devices list for delayed probe */
+ new_input_devices = xnfrealloc(new_input_devices,
+ sizeof(struct input_device_info) * (new_input_devices_count + 1));
+ new_input_devices[new_input_devices_count] = input;
+ new_input_devices_count++;
+ if (fd != -1)
+ close(fd);
+ free(config_info);
+ return;
+ }
add_input_device(&input, fd);
@@ -478,6 +489,26 @@ config_udev_fini(void)
udev_unref(udev);
}
+Bool
+config_udev_delayed_probe(dev_t devnum, int fd)
+{
+ int i, j;
+
+ for (i = 0; i < new_input_devices_count; i++) {
+ if (new_input_devices[i].devnum == devnum) {
+ add_input_device(&new_input_devices[i], fd);
+ free_input_device(&new_input_devices[i]);
+
+ for (j = i; j < new_input_devices_count - 1; j++)
+ new_input_devices[j] = new_input_devices[j + 1];
+ new_input_devices_count--;
+
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
#ifdef CONFIG_UDEV_KMS
static Bool
diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c
index f8be375..a7a598c 100644
--- a/hw/xfree86/os-support/linux/systemd-logind.c
+++ b/hw/xfree86/os-support/linux/systemd-logind.c
@@ -35,6 +35,7 @@
#include "os.h"
#include "dbus-core.h"
+#include "hotplug.h"
#include "xf86.h"
#include "xf86platformBus.h"
#include "xf86Xinput.h"
@@ -310,6 +311,9 @@ message_filter(DBusConnection * connection, DBusMessage * message, void *data)
dbus_error_free(&error);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
+
+ if (config_udev_delayed_probe(makedev(major, minor), fd))
+ return DBUS_HANDLER_RESULT_HANDLED;
} else
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
diff --git a/include/hotplug.h b/include/hotplug.h
index 567edfc..db1bf92 100644
--- a/include/hotplug.h
+++ b/include/hotplug.h
@@ -76,6 +76,10 @@ void NewGPUDeviceRequest(struct OdevAttributes *attribs);
void DeleteGPUDeviceRequest(struct OdevAttributes *attribs);
#endif
+#ifdef CONFIG_UDEV
+Bool config_udev_delayed_probe(dev_t devnum, int fd);
+#endif
+
#define ServerIsNotSeat0() (SeatId && strcmp(SeatId, "seat0"))
struct xf86_platform_device *
--
1.8.4.2
More information about the xorg-devel
mailing list