aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Piel <eric.piel@tremplin-utc.net>2007-05-21 00:46:22 -0400
committerDmitry Torokhov <dtor@insightbb.com>2007-07-10 00:35:17 -0400
commita4da16d3838669d7fb096ea5d1e4917e5ca4dc16 (patch)
tree75fd6ff661a4adb402d3663fb433938a34ea5aaf
parent5035522d1a6b55f95e7e01c209b57f5d89f88b16 (diff)
Input: wriston - reduce polling frequency
Reduces the polling frequency from 10 Hz to 2 Hz, which should be less a burden for laptops wrt energy saving. As it is multimedia keys, 500ms (maximum) of latency should be still fine for the user. In order to keep fluent the feeling when the user is pressing several keys in a raw (such as changing the volume), the frequency is increased for a short duration after a key is pressed. Signed-off-by: Eric Piel <eric.piel@tremplin-utc.net> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/misc/wistron_btns.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 961aad7a0476..320262aa4c17 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -22,6 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/input.h> 23#include <linux/input.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/jiffies.h>
25#include <linux/kernel.h> 26#include <linux/kernel.h>
26#include <linux/mc146818rtc.h> 27#include <linux/mc146818rtc.h>
27#include <linux/module.h> 28#include <linux/module.h>
@@ -37,9 +38,10 @@
37 */ 38 */
38#define MAX_POLL_ITERATIONS 64 39#define MAX_POLL_ITERATIONS 64
39 40
40#define POLL_FREQUENCY 10 /* Number of polls per second */ 41#define POLL_FREQUENCY 2 /* Number of polls per second when idle */
42#define POLL_FREQUENCY_BURST 10 /* Polls per second when a key was recently pressed */
41 43
42#if POLL_FREQUENCY > HZ 44#if POLL_FREQUENCY_BURST > HZ
43#error "POLL_FREQUENCY too high" 45#error "POLL_FREQUENCY too high"
44#endif 46#endif
45 47
@@ -1079,6 +1081,8 @@ static void handle_key(u8 code)
1079 1081
1080static void poll_bios(unsigned long discard) 1082static void poll_bios(unsigned long discard)
1081{ 1083{
1084 static unsigned long jiffies_last_press;
1085 unsigned long jiffies_now = jiffies;
1082 u8 qlen; 1086 u8 qlen;
1083 u16 val; 1087 u16 val;
1084 1088
@@ -1087,11 +1091,17 @@ static void poll_bios(unsigned long discard)
1087 if (qlen == 0) 1091 if (qlen == 0)
1088 break; 1092 break;
1089 val = bios_pop_queue(); 1093 val = bios_pop_queue();
1090 if (val != 0 && !discard) 1094 if (val != 0 && !discard) {
1091 handle_key((u8)val); 1095 handle_key((u8)val);
1096 jiffies_last_press = jiffies_now;
1097 }
1092 } 1098 }
1093 1099
1094 mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY); 1100 /* Increase precision if user is currently pressing keys (< 2s ago) */
1101 if (time_after(jiffies_last_press, jiffies_now - (HZ * 2)))
1102 mod_timer(&poll_timer, jiffies_now + HZ / POLL_FREQUENCY_BURST);
1103 else
1104 mod_timer(&poll_timer, jiffies_now + HZ / POLL_FREQUENCY);
1095} 1105}
1096 1106
1097static int __devinit wistron_probe(struct platform_device *dev) 1107static int __devinit wistron_probe(struct platform_device *dev)