From 0e34e4b7d1fdf0f37f7b6c73f130fdeb4f3b21c3 Mon Sep 17 00:00:00 2001 From: Eric Piel Date: Mon, 21 May 2007 00:46:22 -0400 Subject: [PATCH] --- yaml --- r: 58483 b: refs/heads/master c: a4da16d3838669d7fb096ea5d1e4917e5ca4dc16 h: refs/heads/master i: 58481: 5cb5f8e7f4d81be2a9778d67d695bf496d71274d 58479: b87e9ffecc058de63032619b394a7cb8c14f01bb v: v3 --- [refs] | 2 +- trunk/drivers/input/misc/wistron_btns.c | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 52281d57921e..dd4578c9f922 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 5035522d1a6b55f95e7e01c209b57f5d89f88b16 +refs/heads/master: a4da16d3838669d7fb096ea5d1e4917e5ca4dc16 diff --git a/trunk/drivers/input/misc/wistron_btns.c b/trunk/drivers/input/misc/wistron_btns.c index 961aad7a0476..320262aa4c17 100644 --- a/trunk/drivers/input/misc/wistron_btns.c +++ b/trunk/drivers/input/misc/wistron_btns.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -37,9 +38,10 @@ */ #define MAX_POLL_ITERATIONS 64 -#define POLL_FREQUENCY 10 /* Number of polls per second */ +#define POLL_FREQUENCY 2 /* Number of polls per second when idle */ +#define POLL_FREQUENCY_BURST 10 /* Polls per second when a key was recently pressed */ -#if POLL_FREQUENCY > HZ +#if POLL_FREQUENCY_BURST > HZ #error "POLL_FREQUENCY too high" #endif @@ -1079,6 +1081,8 @@ static void handle_key(u8 code) static void poll_bios(unsigned long discard) { + static unsigned long jiffies_last_press; + unsigned long jiffies_now = jiffies; u8 qlen; u16 val; @@ -1087,11 +1091,17 @@ static void poll_bios(unsigned long discard) if (qlen == 0) break; val = bios_pop_queue(); - if (val != 0 && !discard) + if (val != 0 && !discard) { handle_key((u8)val); + jiffies_last_press = jiffies_now; + } } - mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY); + /* Increase precision if user is currently pressing keys (< 2s ago) */ + if (time_after(jiffies_last_press, jiffies_now - (HZ * 2))) + mod_timer(&poll_timer, jiffies_now + HZ / POLL_FREQUENCY_BURST); + else + mod_timer(&poll_timer, jiffies_now + HZ / POLL_FREQUENCY); } static int __devinit wistron_probe(struct platform_device *dev)