+ hdaps-remember-keyboard-and-mouse-activity.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     hdaps: Remember keyboard and mouse activity

has been added to the -mm tree.  Its filename is

     hdaps-remember-keyboard-and-mouse-activity.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: hdaps: Remember keyboard and mouse activity
From: Shem Multinymous <multinymous@xxxxxxxxx>

When the current hdaps driver is queried for recent keyboard/mouse activity
(which is provided by the hardware for use in disk parking daemons), it simply
returns the last readout.  However, every hardware query resets the activity
flag in the hardware, and this is triggered by (almost) any hdaps sysfs
attribute read, so the flag could be reset before it is observed and is thus
nearly useless.

This patch makes the activities flags persist for 0.1sec, by remembering when
was the last time we saw them set.  This gives apps like the hdaps daemon
enough time to poll the flag.

Signed-off-by: Shem Multinymous <multinymous@xxxxxxxxx>
Signed-off-by: Pavel Machek <pavel@xxxxxxx>
Acked-by: Robert Love <rml@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 drivers/hwmon/hdaps.c |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff -puN drivers/hwmon/hdaps.c~hdaps-remember-keyboard-and-mouse-activity drivers/hwmon/hdaps.c
--- a/drivers/hwmon/hdaps.c~hdaps-remember-keyboard-and-mouse-activity
+++ a/drivers/hwmon/hdaps.c
@@ -53,8 +53,6 @@ static const struct thinkpad_ec_row ec_a
 
 #define KEYBD_MASK		0x20	/* set if keyboard activity */
 #define MOUSE_MASK		0x40	/* set if mouse activity */
-#define KEYBD_ISSET(n)		(!! (n & KEYBD_MASK))	/* keyboard used? */
-#define MOUSE_ISSET(n)		(!! (n & MOUSE_MASK))	/* mouse used? */
 
 #define READ_TIMEOUT_MSECS	100	/* wait this long for device read */
 #define RETRY_MSECS		3	/* retry delay */
@@ -62,6 +60,7 @@ static const struct thinkpad_ec_row ec_a
 #define HDAPS_POLL_PERIOD	(HZ/20)	/* poll for input every 1/20s */
 #define HDAPS_INPUT_FUZZ	4	/* input event threshold */
 #define HDAPS_INPUT_FLAT	4
+#define KMACT_REMEMBER_PERIOD   (HZ/10) /* keyboard/mouse persistance */
 
 static struct timer_list hdaps_timer;
 static struct platform_device *pdev;
@@ -71,9 +70,12 @@ static unsigned int hdaps_invert;
 /* Latest state readout */
 static int pos_x, pos_y;   /* position */
 static int temperature;    /* temperature */
-static u8 km_activity;
 static int rest_x, rest_y; /* calibrated rest position */
 
+/* Last time we saw keyboard and mouse activity: */
+static u64 last_keyboard_jiffies = INITIAL_JIFFIES;
+static u64 last_mouse_jiffies = INITIAL_JIFFIES;
+
 /* Some models require an axis transformation to the standard reprsentation */
 void transform_axes(int *x, int *y)
 {
@@ -122,7 +124,14 @@ static int __hdaps_update(int fast)
 	pos_y = *(s16*)(data.val+EC_ACCEL_IDX_YPOS1);
 	transform_axes(&pos_x, &pos_y);
 
-	km_activity = data.val[EC_ACCEL_IDX_KMACT];
+	/* Keyboard and mouse activity status is cleared as soon as it's read,
+	 * so applications will eat each other's events. Thus we remember any
+	 * event for KMACT_REMEMBER_PERIOD jiffies.
+	 */
+	if (data.val[EC_ACCEL_IDX_KMACT] & KEYBD_MASK)
+		last_keyboard_jiffies = get_jiffies_64();
+	if (data.val[EC_ACCEL_IDX_KMACT] & MOUSE_MASK)
+		last_mouse_jiffies = get_jiffies_64();
 
 	temperature = data.val[EC_ACCEL_IDX_TEMP1];
 
@@ -332,14 +341,22 @@ static ssize_t hdaps_keyboard_activity_s
 					    struct device_attribute *attr,
 					    char *buf)
 {
-	return sprintf(buf, "%u\n", KEYBD_ISSET(km_activity));
+	int ret = hdaps_update();
+	if (ret)
+		return ret;
+	return sprintf(buf, "%u\n",
+	   get_jiffies_64() < last_keyboard_jiffies + KMACT_REMEMBER_PERIOD);
 }
 
 static ssize_t hdaps_mouse_activity_show(struct device *dev,
 					 struct device_attribute *attr,
 					 char *buf)
 {
-	return sprintf(buf, "%u\n", MOUSE_ISSET(km_activity));
+	int ret = hdaps_update();
+	if (ret)
+		return ret;
+	return sprintf(buf, "%u\n",
+	   get_jiffies_64() < last_mouse_jiffies + KMACT_REMEMBER_PERIOD);
 }
 
 static ssize_t hdaps_calibrate_show(struct device *dev,
_

Patches currently in -mm which might be from multinymous@xxxxxxxxx are

dmi-decode-and-save-oem-string-information.patch
thinkpad_ec-new-driver-for-thinkpad-embedded-controller-access.patch
hdaps-use-thinkpad_ec-instead-of-direct-port-access.patch
hdaps-unify-and-cache-hdaps-readouts.patch
hdaps-correct-readout-and-remove-nonsensical-attributes.patch
hdaps-remember-keyboard-and-mouse-activity.patch
hdaps-limit-hardware-query-rate.patch
hdaps-delay-calibration-to-first-hardware-query.patch
hdaps-add-explicit-hardware-configuration-functions.patch
hdaps-add-new-sysfs-attributes.patch
hdaps-power-off-accelerometer-on-suspend-and-unload.patch
hdaps-stop-polling-timer-when-suspended.patch
hdaps-simplify-whitelist.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux