aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/input/ati_remote.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index 5d3ddb916668..471aab206443 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -120,6 +120,7 @@
120 * behaviour. 120 * behaviour.
121 */ 121 */
122#define FILTER_TIME 60 /* msec */ 122#define FILTER_TIME 60 /* msec */
123#define REPEAT_DELAY 500 /* msec */
123 124
124static unsigned long channel_mask; 125static unsigned long channel_mask;
125module_param(channel_mask, ulong, 0644); 126module_param(channel_mask, ulong, 0644);
@@ -133,6 +134,10 @@ static int repeat_filter = FILTER_TIME;
133module_param(repeat_filter, int, 0644); 134module_param(repeat_filter, int, 0644);
134MODULE_PARM_DESC(repeat_filter, "Repeat filter time, default = 60 msec"); 135MODULE_PARM_DESC(repeat_filter, "Repeat filter time, default = 60 msec");
135 136
137static int repeat_delay = REPEAT_DELAY;
138module_param(repeat_delay, int, 0644);
139MODULE_PARM_DESC(repeat_delay, "Delay before sending repeats, default = 500 msec");
140
136#define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0) 141#define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0)
137#undef err 142#undef err
138#define err(format, arg...) printk(KERN_ERR format , ## arg) 143#define err(format, arg...) printk(KERN_ERR format , ## arg)
@@ -174,6 +179,8 @@ struct ati_remote {
174 unsigned char old_data[2]; /* Detect duplicate events */ 179 unsigned char old_data[2]; /* Detect duplicate events */
175 unsigned long old_jiffies; 180 unsigned long old_jiffies;
176 unsigned long acc_jiffies; /* handle acceleration */ 181 unsigned long acc_jiffies; /* handle acceleration */
182 unsigned long first_jiffies;
183
177 unsigned int repeat_count; 184 unsigned int repeat_count;
178 185
179 char name[NAME_BUFSIZE]; 186 char name[NAME_BUFSIZE];
@@ -501,21 +508,31 @@ static void ati_remote_input_report(struct urb *urb)
501 } 508 }
502 509
503 if (ati_remote_tbl[index].kind == KIND_FILTERED) { 510 if (ati_remote_tbl[index].kind == KIND_FILTERED) {
511 unsigned long now = jiffies;
512
504 /* Filter duplicate events which happen "too close" together. */ 513 /* Filter duplicate events which happen "too close" together. */
505 if (ati_remote->old_data[0] == data[1] && 514 if (ati_remote->old_data[0] == data[1] &&
506 ati_remote->old_data[1] == data[2] && 515 ati_remote->old_data[1] == data[2] &&
507 time_before(jiffies, ati_remote->old_jiffies + msecs_to_jiffies(repeat_filter))) { 516 time_before(now, ati_remote->old_jiffies +
517 msecs_to_jiffies(repeat_filter))) {
508 ati_remote->repeat_count++; 518 ati_remote->repeat_count++;
509 } else { 519 } else {
510 ati_remote->repeat_count = 0; 520 ati_remote->repeat_count = 0;
521 ati_remote->first_jiffies = now;
511 } 522 }
512 523
513 ati_remote->old_data[0] = data[1]; 524 ati_remote->old_data[0] = data[1];
514 ati_remote->old_data[1] = data[2]; 525 ati_remote->old_data[1] = data[2];
515 ati_remote->old_jiffies = jiffies; 526 ati_remote->old_jiffies = now;
516 527
528 /* Ensure we skip at least the 4 first duplicate events (generated
529 * by a single keypress), and continue skipping until repeat_delay
530 * msecs have passed
531 */
517 if (ati_remote->repeat_count > 0 && 532 if (ati_remote->repeat_count > 0 &&
518 ati_remote->repeat_count < 5) 533 (ati_remote->repeat_count < 5 ||
534 time_before(now, ati_remote->first_jiffies +
535 msecs_to_jiffies(repeat_delay))))
519 return; 536 return;
520 537
521 538