From patchwork Thu Jun 10 09:52:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Rydberg X-Patchwork-Id: 55179 X-Patchwork-Delegate: leann.ogasawara@canonical.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 6C3A81007D4 for ; Thu, 10 Jun 2010 19:53:21 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1OMeRp-0000uz-02; Thu, 10 Jun 2010 10:53:17 +0100 Received: from smtp-out12.han.skanova.net ([195.67.226.212]) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1OMeRn-0000tk-6F for kernel-team@lists.ubuntu.com; Thu, 10 Jun 2010 10:53:15 +0100 Received: from alnilam (90.237.163.108) by smtp-out12.han.skanova.net (8.5.114) id 4BC6CFA70118FA29; Thu, 10 Jun 2010 11:53:14 +0200 Received: by alnilam (sSMTP sendmail emulation); Thu, 10 Jun 2010 11:53:12 +0200 From: "Henrik Rydberg" To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/3] UBUNTU: (evdev) Use driver hint to compute the evdev buffer size (rev2) Date: Thu, 10 Jun 2010 11:52:59 +0200 Message-Id: <1276163579-22224-4-git-send-email-rydberg@euromail.se> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1276163579-22224-3-git-send-email-rydberg@euromail.se> References: <1276163579-22224-1-git-send-email-rydberg@euromail.se> <1276163579-22224-2-git-send-email-rydberg@euromail.se> <1276163579-22224-3-git-send-email-rydberg@euromail.se> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com 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 --- drivers/input/evdev.c | 5 ++++- include/linux/input.h | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletions(-) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 463bf1b..2cf7b3a 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 #include @@ -797,7 +798,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 20e4eac..9e024b6 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,21 @@ 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); +/** + * input_set_events_per_packet - tell handlers about the driver event rate + * @dev: the input device used by the driver + * @nev: the average number of events between calls to input_sync() + * + * If the event rate sent from a device is unusually large, use this + * function to set the expected event rate. This will allow handlers + * to set up an approriate buffer size for the event stream, in order + * to minimize information loss. + */ +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;