From patchwork Sun Jan 18 15:36:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 5653721 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 311F6C058D for ; Sun, 18 Jan 2015 15:36:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 388432037D for ; Sun, 18 Jan 2015 15:36:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 15DC4200D4 for ; Sun, 18 Jan 2015 15:36:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751780AbbARPgR (ORCPT ); Sun, 18 Jan 2015 10:36:17 -0500 Received: from metis.ext.pengutronix.de ([92.198.50.35]:54444 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751516AbbARPgQ (ORCPT ); Sun, 18 Jan 2015 10:36:16 -0500 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1YCrtf-000516-EK; Sun, 18 Jan 2015 16:36:15 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.84) (envelope-from ) id 1YCrte-000885-NR; Sun, 18 Jan 2015 16:36:14 +0100 From: Michael Grzeschik To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, support.opensource@diasemi.com, kernel@pengutronix.de Subject: [PATCH] Input: da9052_tsi: remove unnecessary worker Date: Sun, 18 Jan 2015 16:36:08 +0100 Message-Id: <1421595368-31203-1-git-send-email-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.1.4 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@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 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With the datardy irq we get the information if the pen got pulled from the screen. This patch changes the irq by checking this condition every time instead of triggering the worker. Signed-off-by: Michael Grzeschik --- drivers/input/touchscreen/da9052_tsi.c | 68 ++++++++++++++-------------------- 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/drivers/input/touchscreen/da9052_tsi.c b/drivers/input/touchscreen/da9052_tsi.c index 5a013bb..e6019dd 100644 --- a/drivers/input/touchscreen/da9052_tsi.c +++ b/drivers/input/touchscreen/da9052_tsi.c @@ -25,7 +25,6 @@ struct da9052_tsi { struct da9052 *da9052; struct input_dev *dev; - struct delayed_work ts_pen_work; struct mutex mutex; bool stopped; bool adc_on; @@ -47,8 +46,6 @@ static irqreturn_t da9052_ts_pendwn_irq(int irq, void *data) da9052_enable_irq(tsi->da9052, DA9052_IRQ_TSIREADY); da9052_ts_adc_toggle(tsi, true); - - schedule_delayed_work(&tsi->ts_pen_work, HZ / 50); } return IRQ_HANDLED; @@ -89,6 +86,33 @@ static void da9052_ts_read(struct da9052_tsi *tsi) y = ((y << 2) & 0x3fc) | ((v & 0xc) >> 2); z = ((z << 2) & 0x3fc) | ((v & 0x30) >> 4); + /* Check for last TSI_READY irq */ + if (!(ret & TSI_PEN_DOWN_STATUS)) { + + /* Pen UP */ + da9052_ts_adc_toggle(tsi, false); + + /* Report Pen UP */ + input_report_key(input, BTN_TOUCH, 0); + input_report_abs(input, ABS_PRESSURE, 0); + input_sync(input); + + /* + * FIXME: Fixes the unhandled irq issue when quick + * pen down and pen up events occurs + */ + ret = da9052_reg_update(tsi->da9052, + DA9052_EVENT_B_REG, 0xC0, 0xC0); + if (ret < 0) + return; + + /* Mask TSI_READY event and unmask PEN_DOWN event */ + da9052_disable_irq_nosync(tsi->da9052, DA9052_IRQ_TSIREADY); + da9052_enable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); + + return; + } + input_report_key(input, BTN_TOUCH, 1); input_report_abs(input, ABS_X, x); input_report_abs(input, ABS_Y, y); @@ -105,42 +129,6 @@ static irqreturn_t da9052_ts_datardy_irq(int irq, void *data) return IRQ_HANDLED; } -static void da9052_ts_pen_work(struct work_struct *work) -{ - struct da9052_tsi *tsi = container_of(work, struct da9052_tsi, - ts_pen_work.work); - if (!tsi->stopped) { - int ret = da9052_reg_read(tsi->da9052, DA9052_TSI_LSB_REG); - if (ret < 0 || (ret & TSI_PEN_DOWN_STATUS)) { - /* Pen is still DOWN (or read error) */ - schedule_delayed_work(&tsi->ts_pen_work, HZ / 50); - } else { - struct input_dev *input = tsi->dev; - - /* Pen UP */ - da9052_ts_adc_toggle(tsi, false); - - /* Report Pen UP */ - input_report_key(input, BTN_TOUCH, 0); - input_report_abs(input, ABS_PRESSURE, 0); - input_sync(input); - - /* - * FIXME: Fixes the unhandled irq issue when quick - * pen down and pen up events occurs - */ - ret = da9052_reg_update(tsi->da9052, - DA9052_EVENT_B_REG, 0xC0, 0xC0); - if (ret < 0) - return; - - /* Mask TSI_READY event and unmask PEN_DOWN event */ - da9052_disable_irq(tsi->da9052, DA9052_IRQ_TSIREADY); - da9052_enable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); - } - } -} - static int da9052_ts_configure_gpio(struct da9052 *da9052) { int error; @@ -209,7 +197,6 @@ static void da9052_ts_input_close(struct input_dev *input_dev) tsi->stopped = true; mb(); da9052_disable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); - cancel_delayed_work_sync(&tsi->ts_pen_work); if (tsi->adc_on) { da9052_disable_irq(tsi->da9052, DA9052_IRQ_TSIREADY); @@ -248,7 +235,6 @@ static int da9052_ts_probe(struct platform_device *pdev) tsi->da9052 = da9052; tsi->dev = input_dev; tsi->stopped = true; - INIT_DELAYED_WORK(&tsi->ts_pen_work, da9052_ts_pen_work); input_dev->id.version = 0x0101; input_dev->id.vendor = 0x15B6;