From patchwork Mon Apr 10 09:52:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Fink X-Patchwork-Id: 9672261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2582B600CB for ; Mon, 10 Apr 2017 09:59:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1760C27D0C for ; Mon, 10 Apr 2017 09:59:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A83E28111; Mon, 10 Apr 2017 09:59:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A03427D0C for ; Mon, 10 Apr 2017 09:59:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752955AbdDJJ7T (ORCPT ); Mon, 10 Apr 2017 05:59:19 -0400 Received: from nm28-vm2.bullet.mail.ir2.yahoo.com ([212.82.97.62]:50776 "EHLO nm28-vm2.bullet.mail.ir2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752659AbdDJJ7S (ORCPT ); Mon, 10 Apr 2017 05:59:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1491818356; bh=buGJK9mABvlp+sE1tFSnbmywvk4K52pFTBkIEesaDiY=; h=From:To:Cc:Subject:Date:From:Subject; b=jsGt2wT0P5zxW/IMxS+tFGOujqcohlIQ9RQmO7FezaGkxQMinNFKmiPA3PR5jRA9A+1Pe0KYzJcm+WSdspNws9GcHD1INciNIwumayIudWQUB8Iwu7bFDrXhno/jlWCJI6OAHX4N+rnPWnUDkDLTlUZTDbQxsezUox8uE+21V5LwV4nWOarPQ2pw56Fo96blg1uYE6Nvv6QiDD7dW/h1qAHnh9tLygsecrLViVX7dhm5I9VJTV0YLjgF1K2uOgBSXVUtEaI96nQeX/WS8VHmG/kqNFg6kVD3gGuJqQita/nppA/4js6L0vdINZ+Fv6JUatKjOlb3pEdgtY5uqit0UQ== Received: from [212.82.98.51] by nm28.bullet.mail.ir2.yahoo.com with NNFMP; 10 Apr 2017 09:59:16 -0000 Received: from [46.228.39.93] by tm4.bullet.mail.ir2.yahoo.com with NNFMP; 10 Apr 2017 09:59:16 -0000 Received: from [127.0.0.1] by smtp130.mail.ir2.yahoo.com with NNFMP; 10 Apr 2017 09:59:16 -0000 X-Yahoo-Newman-Id: 862532.80098.bm@smtp130.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: QDzIIGkVM1lbzicSZOCvVOH.A9lu0ibUfZtnhNa9JCEwNDF PpJmS4YtYbOjK.HzNYzg4gkmSZZbhyM0XTHeOrbRGLHC9lREsNe.gEKPpUHp Fnmcxg3ZKSpc2c8KyoVlzOSxpQakEq_ZcHrQ7crstExFx3LBVkYLiwcARKQo 1vyaZNm3kaM8nlqTiYbzYU7GS5A_3E0JmfbMYNUHXqLRLAOeY_Kk0F2VoEMY ZDM9Ag8im1qIWUWIZGrg_xbGq0WwmYTj6CzewqJGtmkiBIRgOcpyBNVUPqGW CMtdT7Z.2ZFOphLVEaM7FXqZlQBTJkJCbIaGWbyFsd5p1zJ4aUHu1PPCFe5v GO5ghQCDsyDTeMnfLjLyyXPvPnQBK4l6A_MlFgmmXA9qby6us6a2VT37G.em dROmN3jxa.Kym1KKJA1l9dn404Z45VbLfLYOTDK7HG9gONWskFPcENLeO8Z1 xSMgavMe1bRt65_pIOgot.SyqhoHRrRU7mWC56g0E8UuRHO1ltaJh1YMwCoa WeaHOhLyqa5CGK68TyG0jedcaMZBsMjnAeVO98WKf0yTB X-Yahoo-SMTP: 0JOu9hqswBDBvO0JS6jm7B9lXdA- From: Peter Fink To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, stefan.agner@toradex.com, Peter Fink Subject: [PATCH] input: touchscreen: stmpe: check fifo_empty flag before reading x/y values Date: Mon, 10 Apr 2017 11:52:26 +0200 Message-Id: <1491817946-13926-1-git-send-email-pfink@christ-es.de> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP STMPE driver with STMPE811 reported x=0/y=0 when clicking in succession at higher speeds. In some configurations the consuming X11 input stack is able to ignore this input, but e.g. with inverted axes this is prone to fail. In these cases it might happen that even applications are closed when the close-X is located in the same corner as touch 0/0 is mapped to. This happens when touch coordinates are read from an empty fifo although the threshold interrupt indicates that new data is available. To avoid wrong touch data read and evaluate the fifo_empty bit before accessing the fifo. Signed-off-by: Peter Fink --- drivers/input/touchscreen/stmpe-ts.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c index 2a78e27..dcc9d48 100644 --- a/drivers/input/touchscreen/stmpe-ts.c +++ b/drivers/input/touchscreen/stmpe-ts.c @@ -44,6 +44,7 @@ #define OP_MOD_XYZ 0 #define STMPE_TSC_CTRL_TSC_EN (1<<0) +#define STMPE_FIFO_EMPTY (1<<5) #define STMPE_FIFO_STA_RESET (1<<0) @@ -175,17 +176,22 @@ static irqreturn_t stmpe_ts_handler(int irq, void *data) stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, STMPE_TSC_CTRL_TSC_EN, 0); - stmpe_block_read(ts->stmpe, STMPE_REG_TSC_DATA_XYZ, 4, data_set); + if (!(stmpe_reg_read(ts->stmpe, STMPE_REG_FIFO_STA) + & STMPE_FIFO_EMPTY)) { - x = (data_set[0] << 4) | (data_set[1] >> 4); - y = ((data_set[1] & 0xf) << 8) | data_set[2]; - z = data_set[3]; + stmpe_block_read(ts->stmpe, STMPE_REG_TSC_DATA_XYZ, + 4, data_set); - input_report_abs(ts->idev, ABS_X, x); - input_report_abs(ts->idev, ABS_Y, y); - input_report_abs(ts->idev, ABS_PRESSURE, z); - input_report_key(ts->idev, BTN_TOUCH, 1); - input_sync(ts->idev); + x = (data_set[0] << 4) | (data_set[1] >> 4); + y = ((data_set[1] & 0xf) << 8) | data_set[2]; + z = data_set[3]; + + input_report_abs(ts->idev, ABS_X, x); + input_report_abs(ts->idev, ABS_Y, y); + input_report_abs(ts->idev, ABS_PRESSURE, z); + input_report_key(ts->idev, BTN_TOUCH, 1); + input_sync(ts->idev); + } /* flush the FIFO after we have read out our values. */ __stmpe_reset_fifo(ts->stmpe);