summaryrefslogtreecommitdiff
blob: e3a3a737663fd14bc9806070bc7e6efa434d60e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Source: https://github.com/s-moch/linux-saa716x/commit/0b2276ee2e6383ad577fce5c694f8c4062d5334b.patch

From 0b2276ee2e6383ad577fce5c694f8c4062d5334b Mon Sep 17 00:00:00 2001
From: Soeren Moch <smoch@web.de>
Date: Sat, 2 Dec 2017 20:51:10 +0100
Subject: [PATCH] saa716x_ff: Remove autorepeat handling

Let the input layer handle autorepeat for the IR remote.
So no repeat_key timer is required anymore.

Signed-off-by: Soeren Moch <smoch@web.de>
---
 drivers/media/common/saa716x/saa716x_ff_ir.c | 45 ++++++++--------------------
 1 file changed, 12 insertions(+), 33 deletions(-)

diff --git a/drivers/media/common/saa716x/saa716x_ff_ir.c b/drivers/media/common/saa716x/saa716x_ff_ir.c
index 35624789aa862..ad6f38611026c 100644
--- a/linux/drivers/media/common/saa716x/saa716x_ff_ir.c
+++ b/linux/drivers/media/common/saa716x/saa716x_ff_ir.c
@@ -40,7 +40,7 @@ struct infrared {
 	u8			protocol;
 	u16			last_key;
 	u16			last_toggle;
-	bool			delay_timer_finished;
+	bool			key_pressed;
 };
 
 #define IR_RC5		0
@@ -52,11 +52,12 @@ static void ir_emit_keyup(unsigned long parm)
 {
 	struct infrared *ir = (struct infrared *) parm;
 
-	if (!ir || !test_bit(ir->last_key, ir->input_dev->key))
+	if (!ir || !ir->key_pressed)
 		return;
 
 	input_report_key(ir->input_dev, ir->last_key, 0);
 	input_sync(ir->input_dev);
+	ir->key_pressed = false;
 }
 
 
@@ -114,28 +115,18 @@ static void ir_emit_key(unsigned long parm)
 		return;
 	}
 
-	if (timer_pending(&ir->keyup_timer)) {
-		del_timer(&ir->keyup_timer);
-		if (ir->last_key != keycode || toggle != ir->last_toggle) {
-			ir->delay_timer_finished = false;
-			input_event(ir->input_dev, EV_KEY, ir->last_key, 0);
-			input_event(ir->input_dev, EV_KEY, keycode, 1);
-			input_sync(ir->input_dev);
-		} else if (ir->delay_timer_finished) {
-			input_event(ir->input_dev, EV_KEY, keycode, 2);
-			input_sync(ir->input_dev);
-		}
-	} else {
-		ir->delay_timer_finished = false;
-		input_event(ir->input_dev, EV_KEY, keycode, 1);
-		input_sync(ir->input_dev);
-	}
+	if (ir->key_pressed &&
+	    (ir->last_key != keycode || toggle != ir->last_toggle))
+		input_event(ir->input_dev, EV_KEY, ir->last_key, 0);
 
+	input_event(ir->input_dev, EV_KEY, keycode, 1);
+	input_sync(ir->input_dev);
+
+	ir->key_pressed = true;
 	ir->last_key = keycode;
 	ir->last_toggle = toggle;
 
-	ir->keyup_timer.expires = jiffies + UP_TIMEOUT;
-	add_timer(&ir->keyup_timer);
+	mod_timer(&ir->keyup_timer, jiffies + UP_TIMEOUT);
 
 }
 
@@ -166,16 +157,6 @@ static void ir_register_keys(struct infrared *ir)
 	ir->input_dev->keycodemax = ARRAY_SIZE(ir->key_map);
 }
 
-
-/* called by the input driver after rep[REP_DELAY] ms */
-static void ir_repeat_key(unsigned long parm)
-{
-	struct infrared *ir = (struct infrared *) parm;
-
-	ir->delay_timer_finished = true;
-}
-
-
 /* interrupt handler */
 void saa716x_ir_handler(struct saa716x_dev *saa716x, u32 ir_cmd)
 {
@@ -236,9 +217,7 @@ int saa716x_ir_init(struct saa716x_dev *saa716x)
 		ir->key_map[i] = i+1;
 	ir_register_keys(ir);
 
-	/* override repeat timer */
-	input_dev->timer.function = ir_repeat_key;
-	input_dev->timer.data = (unsigned long) ir;
+	input_enable_softrepeat(input_dev, 800, 200);
 
 	tasklet_init(&ir->tasklet, ir_emit_key, (unsigned long) saa716x);
 	saa716x->ir_priv = ir;