From patchwork Thu Sep 20 14:22:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 10607823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63F2814DA for ; Thu, 20 Sep 2018 14:23:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 554862A6D9 for ; Thu, 20 Sep 2018 14:23:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 482862C71C; Thu, 20 Sep 2018 14:23:05 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 E2F9B2A8B3 for ; Thu, 20 Sep 2018 14:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732470AbeITUGr (ORCPT ); Thu, 20 Sep 2018 16:06:47 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:43197 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731135AbeITUGq (ORCPT ); Thu, 20 Sep 2018 16:06:46 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.89) (envelope-from ) id 1g2zr7-0004kr-80; Thu, 20 Sep 2018 16:22:57 +0200 From: Lucas Stach To: Dmitry Torokhov , Rob Herring Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, patchwork-lst@pengutronix.de, kernel@pengutronix.de, Chris Healy Subject: [PATCH 2/4] Input: egalax_ts - use touchscreen helpers Date: Thu, 20 Sep 2018 16:22:54 +0200 Message-Id: <20180920142256.2788-2-l.stach@pengutronix.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180920142256.2788-1-l.stach@pengutronix.de> References: <20180920142256.2788-1-l.stach@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: l.stach@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-Virus-Scanned: ClamAV using ClamSMTP Using those helpers the driver will support all the common OF touchscreen properties like rotation and axis swap. Signed-off-by: Lucas Stach --- drivers/input/touchscreen/egalax_ts.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c index 5e7a60089c3d..4c751f8f806d 100644 --- a/drivers/input/touchscreen/egalax_ts.c +++ b/drivers/input/touchscreen/egalax_ts.c @@ -25,6 +25,7 @@ #include #include #include +#include /* * Mouse Mode: some panel may configure the controller to mouse mode, @@ -52,13 +53,12 @@ #define MAX_I2C_DATA_LEN 10 -#define EGALAX_MAX_X 32760 -#define EGALAX_MAX_Y 32760 #define EGALAX_MAX_TRIES 100 struct egalax_ts { struct i2c_client *client; struct input_dev *input_dev; + struct touchscreen_properties props; }; static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id) @@ -105,8 +105,7 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id) down ? "down" : "up", id, x, y, z); if (down) { - input_report_abs(input_dev, ABS_MT_POSITION_X, x); - input_report_abs(input_dev, ABS_MT_POSITION_Y, y); + touchscreen_report_pos(input_dev, &ts->props, x, y, true); input_report_abs(input_dev, ABS_MT_PRESSURE, z); } @@ -199,10 +198,14 @@ static int egalax_ts_probe(struct i2c_client *client, input_dev->name = "EETI eGalax Touch Screen"; input_dev->id.bustype = BUS_I2C; - input_set_abs_params(input_dev, - ABS_MT_POSITION_X, 0, EGALAX_MAX_X, 0, 0); - input_set_abs_params(input_dev, - ABS_MT_POSITION_Y, 0, EGALAX_MAX_Y, 0, 0); + touchscreen_parse_properties(ts->input_dev, true, &ts->props); + if (!ts->props.max_x && !ts->props.max_y) + ts->props.max_x = ts->props.max_y = 32760; + + input_set_abs_params(input_dev, ABS_MT_POSITION_X, + 0, ts->props.max_x, 0, 0); + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, + 0, ts->props.max_y, 0, 0); input_mt_init_slots(input_dev, MAX_SUPPORT_POINTS, INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);