From patchwork Tue Jun 13 15:29:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 9784235 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 5BDF560212 for ; Tue, 13 Jun 2017 15:37:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A436284F6 for ; Tue, 13 Jun 2017 15:37:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F35F28572; Tue, 13 Jun 2017 15:37:14 +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.0 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, 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 84805284F6 for ; Tue, 13 Jun 2017 15:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751768AbdFMPhM (ORCPT ); Tue, 13 Jun 2017 11:37:12 -0400 Received: from [91.227.64.183] ([91.227.64.183]:53464 "EHLO rere.qmqm.pl" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1750899AbdFMPhL (ORCPT ); Tue, 13 Jun 2017 11:37:11 -0400 X-Greylist: delayed 458 seconds by postgrey-1.27 at vger.kernel.org; Tue, 13 Jun 2017 11:37:11 EDT Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 0DDBF4A; Tue, 13 Jun 2017 17:29:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1497367772; bh=qCUB6vU/vEA2JrebAmLAPDynPcOfuXra238Y/8dekzQ=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=l0XW1Kqho3gffuaBTSHEakqgumkkUxSxM7y1FZ9JhkYM4VxZO4+FlZhjnfI0+NfHr 0JyAlrqPCSUoDFIS+Ge+rhVWZ37sM5vtT8lNQ7/Uh5x/fpB3KxoIK3LlXJUY9IYUlx qBDZLnCAuv6at8bJPxkn1FnRiOFQn8koVV86aaU1TbweoTUQYAZhss8xRWCRmPdI0/ lZK+BtFCjKfsiVj1WJq72bEQCVvrEJ0V0ecv45qBcewl4W/MY49hnh125OsUU7+TgC Yn9WJa7njc9UGd5H0oTwaaCnCxwDDONOpQUHAtd45ENTIJlnbwTanFQ3BiDa4HRaad GY3mjMdTp4cQg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.99.2 at rere Date: Tue, 13 Jun 2017 17:29:31 +0200 Message-Id: In-Reply-To: <5ef7cc1aed6127d95cf5d666e5ec84e5e8993c71.1497367336.git.mirq-linux@rere.qmqm.pl> References: <5ef7cc1aed6127d95cf5d666e5ec84e5e8993c71.1497367336.git.mirq-linux@rere.qmqm.pl> From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH 2/2] input: elants: support common touchscreen DT properties MIME-Version: 1.0 To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , Guenter Roeck , Johnny Chuang 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 This allows for axis inversion and overriding of min/max values. Signed-off-by: Michał Mirosław --- drivers/input/touchscreen/elants_i2c.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index 6509407f53e49..3d7d7d6559b0c 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -151,8 +152,7 @@ struct elants_data { u16 hw_version; unsigned int x_res; /* resolution in units/mm */ unsigned int y_res; - unsigned int x_max; - unsigned int y_max; + struct touchscreen_properties prop; enum elants_state state; enum elants_iap_mode iap_mode; @@ -502,10 +502,10 @@ static int elants_i2c_query_ts_info(struct elants_data *ts) rows, cols, osr); } else { /* translate trace number to TS resolution */ - ts->x_max = ELAN_TS_RESOLUTION(rows, osr); - ts->x_res = DIV_ROUND_CLOSEST(ts->x_max, phy_x); - ts->y_max = ELAN_TS_RESOLUTION(cols, osr); - ts->y_res = DIV_ROUND_CLOSEST(ts->y_max, phy_y); + ts->prop.max_x = ELAN_TS_RESOLUTION(rows, osr); + ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, phy_x); + ts->prop.max_y = ELAN_TS_RESOLUTION(cols, osr); + ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, phy_y); } return 0; @@ -836,8 +836,7 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf, unsigned report input_mt_slot(input, i); input_mt_report_slot_state(input, MT_TOOL_FINGER, true); - input_event(input, EV_ABS, ABS_MT_POSITION_X, x); - input_event(input, EV_ABS, ABS_MT_POSITION_Y, y); + touchscreen_report_pos(input, &ts->prop, x, y, true); input_event(input, EV_ABS, ABS_MT_PRESSURE, p); input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, w); @@ -1258,13 +1257,15 @@ static int elants_i2c_probe(struct i2c_client *client, ts->input->name = "Elan Touchscreen"; ts->input->id.bustype = BUS_I2C; + touchscreen_parse_properties(ts->input, true, &ts->prop); + __set_bit(BTN_TOUCH, ts->input->keybit); __set_bit(EV_ABS, ts->input->evbit); __set_bit(EV_KEY, ts->input->evbit); /* Single touch input params setup */ - input_set_abs_params(ts->input, ABS_X, 0, ts->x_max, 0, 0); - input_set_abs_params(ts->input, ABS_Y, 0, ts->y_max, 0, 0); + input_set_abs_params(ts->input, ABS_X, 0, ts->prop.max_x, 0, 0); + input_set_abs_params(ts->input, ABS_Y, 0, ts->prop.max_y, 0, 0); input_set_abs_params(ts->input, ABS_PRESSURE, 0, 255, 0, 0); input_abs_set_res(ts->input, ABS_X, ts->x_res); input_abs_set_res(ts->input, ABS_Y, ts->y_res); @@ -1278,8 +1279,8 @@ static int elants_i2c_probe(struct i2c_client *client, return error; } - input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0); - input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0); + input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->prop.max_x, 0, 0); + input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->prop.max_y, 0, 0); input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0); input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res);