From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Jiri Kosina <jikos@kernel.org>, Arek Burdach <arek.burdach@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Benjamin Tissoires <benjamin.tissoires@redhat.com>
Subject: [PATCH 3/3] HID: multitouch: optimize the sticky fingers timer
Date: Thu, 15 Jun 2017 15:32:05 +0200 [thread overview]
Message-ID: <20170615133205.15441-4-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <20170615133205.15441-1-benjamin.tissoires@redhat.com>
Instead of unconditionally expiring the timer and calling a long
mt_release_contacts(), we can check if some slots are used when the
timer expires.
We can also remove the timer if we happen to receive all the releases.
The logic behind the MT_IO_FLAGS_PENDING_SLOTS could be implemented by
counting how many slots are active, but using bits feels slightly more
efficient.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
drivers/hid/hid-multitouch.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index dd73907..9481935 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -79,6 +79,8 @@ MODULE_LICENSE("GPL");
#define MT_BUTTONTYPE_CLICKPAD 0
#define MT_IO_FLAGS_RUNNING 0
+#define MT_IO_FLAGS_ACTIVE_SLOTS 1
+#define MT_IO_FLAGS_PENDING_SLOTS 2
struct mt_slot {
__s32 x, y, cx, cy, p, w, h;
@@ -689,6 +691,8 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p);
input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major);
input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor);
+
+ set_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags);
}
}
@@ -704,6 +708,11 @@ static void mt_sync_frame(struct mt_device *td, struct input_dev *input)
input_mt_sync_frame(input);
input_sync(input);
td->num_received = 0;
+ if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags))
+ set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags);
+ else
+ clear_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags);
+ clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags);
}
static int mt_touch_event(struct hid_device *hid, struct hid_field *field,
@@ -843,8 +852,13 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report)
* only affect laggish machines and the ones that have a firmware
* defect.
*/
- if (td->mtclass.quirks & MT_QUIRK_STICKY_FINGERS)
- mod_timer(&td->release_timer, jiffies + msecs_to_jiffies(100));
+ if (td->mtclass.quirks & MT_QUIRK_STICKY_FINGERS) {
+ if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags))
+ mod_timer(&td->release_timer,
+ jiffies + msecs_to_jiffies(100));
+ else
+ del_timer(&td->release_timer);
+ }
clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags);
}
@@ -1194,7 +1208,8 @@ static void mt_expired_timeout(unsigned long arg)
*/
if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags))
return;
- mt_release_contacts(hdev);
+ if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags))
+ mt_release_contacts(hdev);
clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags);
}
--
2.9.4
next prev parent reply other threads:[~2017-06-15 13:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-15 13:32 [PATCH 0/3] HID: multitouch: fix a corner case of some Win 8 devices Benjamin Tissoires
2017-06-15 13:32 ` [PATCH 1/3] HID: multitouch: use BIT macro Benjamin Tissoires
2017-06-15 13:32 ` [PATCH 2/3] HID: multitouch: fix rare Win 8 cases when the touch up event gets missing Benjamin Tissoires
2017-06-15 13:32 ` Benjamin Tissoires [this message]
2017-06-22 16:20 ` [PATCH 0/3] HID: multitouch: fix a corner case of some Win 8 devices Arek Burdach
2017-06-23 8:17 ` Jiri Kosina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170615133205.15441-4-benjamin.tissoires@redhat.com \
--to=benjamin.tissoires@redhat.com \
--cc=arek.burdach@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).