From patchwork Sat Jun 5 11:04:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Rydberg X-Patchwork-Id: 104445 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o55BCFYN018211 for ; Sat, 5 Jun 2010 11:12:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933104Ab0FELLh (ORCPT ); Sat, 5 Jun 2010 07:11:37 -0400 Received: from smtp-out11.han.skanova.net ([195.67.226.200]:34426 "EHLO smtp-out11.han.skanova.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932827Ab0FELLg (ORCPT ); Sat, 5 Jun 2010 07:11:36 -0400 Received: from alnilam (90.237.162.21) by smtp-out11.han.skanova.net (8.5.114) id 4BC6D1B3014776B0; Sat, 5 Jun 2010 13:05:00 +0200 Received: by alnilam (sSMTP sendmail emulation); Sat, 05 Jun 2010 13:04:57 +0200 From: "Henrik Rydberg" To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Kosina , Mika Kuoppala , Benjamin Tissoires , Rafi Rubin , Henrik Rydberg Subject: [PATCH 3/3] input: Use driver hint to compute the evdev buffer size (rev2) Date: Sat, 5 Jun 2010 13:04:29 +0200 Message-Id: <1275735869-2185-4-git-send-email-rydberg@euromail.se> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1275735869-2185-3-git-send-email-rydberg@euromail.se> References: <1275735869-2185-1-git-send-email-rydberg@euromail.se> <1275735869-2185-2-git-send-email-rydberg@euromail.se> <1275735869-2185-3-git-send-email-rydberg@euromail.se> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 05 Jun 2010 11:12:15 +0000 (UTC) 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 bd00786..b2a8a59 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;