From patchwork Sat Mar 9 17:05:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Pargmann X-Patchwork-Id: 2241991 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 6ABAF3FCF2 for ; Sat, 9 Mar 2013 17:08:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932844Ab3CIRIK (ORCPT ); Sat, 9 Mar 2013 12:08:10 -0500 Received: from metis.ext.pengutronix.de ([92.198.50.35]:36656 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760380Ab3CIRIJ (ORCPT ); Sat, 9 Mar 2013 12:08:09 -0500 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1UENFE-00011E-9L; Sat, 09 Mar 2013 18:07:40 +0100 Received: from mpa by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1UENFD-0004lJ-I1; Sat, 09 Mar 2013 18:07:39 +0100 From: Markus Pargmann To: Mark Brown , Liam Girdwood Cc: Dmitry Torokhov , patches@opensource.wolfsonmicro.com, linux-input@vger.kernel.org, kernel@pengutronix.de, Markus Pargmann , stable@vger.kernel.org Subject: [PATCH v2 1/4] Input: wm97xx: Drop out of range inputs Date: Sat, 9 Mar 2013 18:05:50 +0100 Message-Id: <1362848753-6725-2-git-send-email-mpa@pengutronix.de> X-Mailer: git-send-email 1.8.2.rc2 In-Reply-To: <1362848753-6725-1-git-send-email-mpa@pengutronix.de> References: <1362848753-6725-1-git-send-email-mpa@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: mpa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-input@vger.kernel.org Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org With fast movements, there occured some out of screen jumps with my touchscreen. The abs_x and abs_y module parameters should fix this by default, but the driver doesn't actively checks the x/y coordinates. Instead it seems that the input layer was supposed to drop out of range inputs, as described in the comments: "These parameters are used to help the input layer discard out of range readings and reduce jitter etc" The input layer documentation describes that values that are not in the absolute range are also accepted. So this patch adds a check within the driver. Cc: stable@vger.kernel.org Signed-off-by: Markus Pargmann Acked-by: Mark Brown --- drivers/input/touchscreen/wm97xx-core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c index 5dbe73a..17db572 100644 --- a/drivers/input/touchscreen/wm97xx-core.c +++ b/drivers/input/touchscreen/wm97xx-core.c @@ -442,6 +442,16 @@ static int wm97xx_read_samples(struct wm97xx *wm) "pen down: x=%x:%d, y=%x:%d, pressure=%x:%d\n", data.x >> 12, data.x & 0xfff, data.y >> 12, data.y & 0xfff, data.p >> 12, data.p & 0xfff); + + if (abs_x[0] > (data.x & 0xfff) || + abs_x[1] < (data.x & 0xfff) || + abs_y[0] > (data.y & 0xfff) || + abs_y[1] < (data.y & 0xfff)) { + dev_dbg(wm->dev, "Measurement out of range, dropping it\n"); + rc = RC_AGAIN; + goto out; + } + input_report_abs(wm->input_dev, ABS_X, data.x & 0xfff); input_report_abs(wm->input_dev, ABS_Y, data.y & 0xfff); input_report_abs(wm->input_dev, ABS_PRESSURE, data.p & 0xfff); @@ -455,6 +465,7 @@ static int wm97xx_read_samples(struct wm97xx *wm) wm->ts_reader_interval = wm->ts_reader_min_interval; } +out: mutex_unlock(&wm->codec_mutex); return rc; }