From patchwork Tue Oct 16 09:23:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 10643261 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 C72EE17D4 for ; Tue, 16 Oct 2018 09:24:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B89C329142 for ; Tue, 16 Oct 2018 09:24:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACD7A29867; Tue, 16 Oct 2018 09:24:12 +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 4C52929142 for ; Tue, 16 Oct 2018 09:24:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727071AbeJPRNm (ORCPT ); Tue, 16 Oct 2018 13:13:42 -0400 Received: from mail1.skidata.com ([91.230.2.99]:36789 "EHLO mail1.skidata.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbeJPRNm (ORCPT ); Tue, 16 Oct 2018 13:13:42 -0400 X-IronPort-AV: E=Sophos;i="5.54,388,1534802400"; d="scan'208";a="12888081" From: Richard Leitner To: , , CC: , , , Richard Leitner Subject: [PATCH 7/7] Input: sx8654 - use common of_touchscreen functions Date: Tue, 16 Oct 2018 11:23:10 +0200 Message-ID: <20181016092310.27346-1-richard.leitner@skidata.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181016091653.26896-1-richard.leitner@skidata.com> References: <20181016091653.26896-1-richard.leitner@skidata.com> MIME-Version: 1.0 X-Originating-IP: [192.168.111.252] X-ClientProxiedBy: sdex4srv.skidata.net (192.168.111.82) To sdex5srv.skidata.net (192.168.111.83) 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 of_touchscreen.c provides a common interface for a axis invertion and swapping of touchscreens. Therefore use it in the sx8654 driver. Signed-off-by: Richard Leitner --- drivers/input/touchscreen/sx8654.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/input/touchscreen/sx8654.c b/drivers/input/touchscreen/sx8654.c index 33f7a0be4ef8..08b064f96b4e 100644 --- a/drivers/input/touchscreen/sx8654.c +++ b/drivers/input/touchscreen/sx8654.c @@ -36,6 +36,7 @@ #include #include #include +#include /* register addresses */ #define I2C_REG_TOUCH0 0x00 @@ -100,6 +101,7 @@ struct sx8654 { struct i2c_client *client; struct gpio_desc *gpio_reset; struct hrtimer timer; + struct touchscreen_properties props; const struct sx865x_data *data; }; @@ -168,8 +170,7 @@ static irqreturn_t sx8650_irq(int irq, void *handle) chdata); } - input_report_abs(ts->input, ABS_X, x); - input_report_abs(ts->input, ABS_Y, y); + touchscreen_report_pos(ts->input, &ts->props, x, y, false); input_report_key(ts->input, BTN_TOUCH, 1); input_sync(ts->input); dev_dbg(dev, "point(%4d,%4d)\n", x, y); @@ -215,8 +216,8 @@ static irqreturn_t sx8654_irq(int irq, void *handle) x = ((data[0] & 0xf) << 8) | (data[1]); y = ((data[2] & 0xf) << 8) | (data[3]); - input_report_abs(sx8654->input, ABS_X, x); - input_report_abs(sx8654->input, ABS_Y, y); + touchscreen_report_pos(sx8654->input, &sx8654->props, x, y, + false); input_report_key(sx8654->input, BTN_TOUCH, 1); input_sync(sx8654->input); @@ -355,6 +356,8 @@ static int sx8654_get_ofdata(struct sx8654 *ts) } dev_dbg(dev, "got GPIO reset pin\n"); + touchscreen_parse_properties(ts->input, false, &ts->props); + return 0; } #else /* CONFIG_OF */ @@ -380,25 +383,11 @@ static int sx8654_probe(struct i2c_client *client, sx8654 = devm_kzalloc(&client->dev, sizeof(*sx8654), GFP_KERNEL); if (!sx8654) return -ENOMEM; - sx8654->client = client; - error = sx8654_get_ofdata(sx8654); - if (error) { - dev_err(&client->dev, "get_ofdata failed: %d\n", error); - return error; - } - - if (!sx8654->data->has_irq_penrelease) { - dev_dbg(&client->dev, "use timer for penrelease\n"); - hrtimer_init(&sx8654->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - sx8654->timer.function = sx865x_penrelease_timer_handler; - } - input = devm_input_allocate_device(&client->dev); if (!input) return -ENOMEM; - sx8654->input = input; input->name = "SX8654 I2C Touchscreen"; @@ -414,6 +403,18 @@ static int sx8654_probe(struct i2c_client *client, input_set_drvdata(sx8654->input, sx8654); + error = sx8654_get_ofdata(sx8654); + if (error) { + dev_err(&client->dev, "get_ofdata failed: %d\n", error); + return error; + } + + if (!sx8654->data->has_irq_penrelease) { + dev_dbg(&client->dev, "use timer for penrelease\n"); + hrtimer_init(&sx8654->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + sx8654->timer.function = sx865x_penrelease_timer_handler; + } + error = sx8654_reset(sx8654); if (error) { dev_err(&client->dev, "reset failed");