summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2018-06-19 13:41:30 +0200
committerBastien Nocera <hadess@hadess.net>2018-06-19 13:01:52 +0000
commit6ab61bac9d825849fc017e50c6311d09428ec437 (patch)
tree9e0bd58476cb2f006b2708bce7523b59ecaa1007
parent79017e432dd0cfc71aa1ada5e0574b3846ea4c52 (diff)
linux: Detect hardware that needs more polling after event
When an event happens on the power line, and we are using a particular device (in this case a MacBook or MacBookAir), we might need to poll more aggressively after the event. This adds a function to detect and export this.
-rw-r--r--src/linux/Makefile.am1
-rw-r--r--src/linux/up-backend-linux-private.h29
-rw-r--r--src/linux/up-backend.c25
3 files changed, 55 insertions, 0 deletions
diff --git a/src/linux/Makefile.am b/src/linux/Makefile.am
index 0121067..aec0b31 100644
--- a/src/linux/Makefile.am
+++ b/src/linux/Makefile.am
@@ -42,6 +42,7 @@ libupshared_la_SOURCES = \
up-input.c \
up-input.h \
up-backend.c \
+ up-backend-linux-private.h \
up-native.c \
hidpp-device.c \
hidpp-device.h \
diff --git a/src/linux/up-backend-linux-private.h b/src/linux/up-backend-linux-private.h
new file mode 100644
index 0000000..0e6e77c
--- /dev/null
+++ b/src/linux/up-backend-linux-private.h
@@ -0,0 +1,29 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2018 Bastien Nocera <hadess@hadess.net>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __UP_BACKEND_LINUX_PRIVATE_H
+#define __UP_BACKEND_LINUX_PRIVATE_H
+
+#include <glib.h>
+
+gboolean up_backend_needs_poll_after_uevent (void);
+
+#endif /* __UP_BACKEND_LINUX_PRIVATE_H */
diff --git a/src/linux/up-backend.c b/src/linux/up-backend.c
index a9981ac..bffc8fa 100644
--- a/src/linux/up-backend.c
+++ b/src/linux/up-backend.c
@@ -31,9 +31,12 @@
#include <gudev/gudev.h>
#include "up-backend.h"
+#include "up-backend-linux-private.h"
#include "up-daemon.h"
#include "up-device.h"
+#include "sysfs-utils.h"
+
#include "up-device-supply.h"
#include "up-device-csr.h"
#include "up-device-unifying.h"
@@ -277,6 +280,28 @@ up_backend_uevent_signal_handler_cb (GUdevClient *client, const gchar *action,
}
}
+static gpointer
+is_macbook (gpointer data)
+{
+ char *product;
+ gboolean ret = FALSE;
+
+ product = sysfs_get_string ("/sys/devices/virtual/dmi/id/", "product_name");
+ if (product == NULL)
+ return GINT_TO_POINTER(ret);
+ ret = g_str_has_prefix (product, "MacBook");
+ g_free (product);
+ return GINT_TO_POINTER(ret);
+}
+
+gboolean
+up_backend_needs_poll_after_uevent (void)
+{
+ static GOnce dmi_once = G_ONCE_INIT;
+ g_once (&dmi_once, is_macbook, NULL);
+ return GPOINTER_TO_INT(dmi_once.retval);
+}
+
static gboolean
is_battery_iface_proxy (GDBusProxy *interface_proxy)
{