From: "Henrik Rydberg" <rydberg@euromail.se>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, Jiri Kosina <jkosina@suse.cz>,
Mika Kuoppala <mika.kuoppala@nokia.com>,
Benjamin Tissoires <tissoire@cena.fr>,
Rafi Rubin <rafi@seas.upenn.edu>,
Henrik Rydberg <rydberg@euromail.se>
Subject: [PATCH 3/3] input: use driver hint to compute the evdev buffer size
Date: Sat, 29 May 2010 17:57:44 +0200 [thread overview]
Message-ID: <1275148664-6238-4-git-send-email-rydberg@euromail.se> (raw)
In-Reply-To: <1275148664-6238-3-git-send-email-rydberg@euromail.se>
Some devices, in particular MT devices, produce a lot of data.
This leads to a high frequency of lost packets in evdev, which
by default uses a fairly small event buffer. Let the drivers hint
the average number of events per packet for the device by calling
the input_set_events_per_packet(), and use that information when
computing the evdev buffer size.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
---
drivers/input/evdev.c | 5 ++++-
include/linux/input.h | 7 +++++++
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 327f821..fdddb43 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -11,6 +11,7 @@
#define EVDEV_MINOR_BASE 64
#define EVDEV_MINORS 32
#define EVDEV_MIN_BUFFER_SIZE 64
+#define EVDEV_BUF_PACKETS 8
#include <linux/poll.h>
#include <linux/sched.h>
@@ -807,7 +808,9 @@ static void evdev_cleanup(struct evdev *evdev)
static int evdev_compute_buffer_size(struct input_dev *dev)
{
- return EVDEV_MIN_BUFFER_SIZE;
+ int nev = dev->hint_events_per_packet * EVDEV_BUF_PACKETS;
+ nev = max(nev, EVDEV_MIN_BUFFER_SIZE);
+ return roundup_pow_of_two(nev);
}
/*
diff --git a/include/linux/input.h b/include/linux/input.h
index bd00786..35b015d 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -1162,6 +1162,8 @@ struct input_dev {
unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
unsigned long swbit[BITS_TO_LONGS(SW_CNT)];
+ unsigned int hint_events_per_packet;
+
unsigned int keycodemax;
unsigned int keycodesize;
void *keycode;
@@ -1439,6 +1441,11 @@ static inline void input_mt_slot(struct input_dev *dev, int slot)
void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code);
+static inline void input_set_events_per_packet(struct input_dev *dev, int nev)
+{
+ dev->hint_events_per_packet = nev;
+}
+
static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
{
dev->absmin[axis] = min;
--
1.6.3.3
next prev parent reply other threads:[~2010-05-29 15:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-29 15:57 [PATCH 0/3] input: evdev: Dynamic buffers (rev2) Henrik Rydberg
2010-05-29 15:57 ` [PATCH 1/3] input: evdev: use multi-reader buffer to save space (rev2) Henrik Rydberg
2010-05-29 15:57 ` [PATCH 2/3] input: evdev: convert to dynamic event buffer (rev2) Henrik Rydberg
2010-05-29 15:57 ` Henrik Rydberg [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-05-28 15:10 [PATCH 0/3] input: evdev: Dynamic buffers Henrik Rydberg
2010-05-28 15:10 ` [PATCH 1/3] input: evdev: use multi-reader buffer to save space Henrik Rydberg
2010-05-28 15:10 ` [PATCH 2/3] input: evdev: convert to dynamic event buffer Henrik Rydberg
2010-05-28 15:10 ` [PATCH 3/3] input: use driver hint to compute the evdev buffer size Henrik Rydberg
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=1275148664-6238-4-git-send-email-rydberg@euromail.se \
--to=rydberg@euromail.se \
--cc=dmitry.torokhov@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=mika.kuoppala@nokia.com \
--cc=rafi@seas.upenn.edu \
--cc=tissoire@cena.fr \
/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).