diff options
-rw-r--r-- | drivers/input/misc/wistron_btns.c | 18 |
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 | ||
1080 | static void poll_bios(unsigned long discard) | 1082 | static 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 | ||
1097 | static int __devinit wistron_probe(struct platform_device *dev) | 1107 | static int __devinit wistron_probe(struct platform_device *dev) |