From patchwork Sun Jun 17 11:46:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10468827 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 75AB36028E for ; Sun, 17 Jun 2018 11:47:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65AE3286FD for ; Sun, 17 Jun 2018 11:47:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A4E928905; Sun, 17 Jun 2018 11:47:17 +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 E475B28899 for ; Sun, 17 Jun 2018 11:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936678AbeFQLrN (ORCPT ); Sun, 17 Jun 2018 07:47:13 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:60984 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936541AbeFQLrM (ORCPT ); Sun, 17 Jun 2018 07:47:12 -0400 Received: from localhost.localdomain (pD95EF0E3.dip0.t-ipconnect.de [217.94.240.227]) by mail.bugwerft.de (Postfix) with ESMTPSA id 3F1FD289831; Sun, 17 Jun 2018 11:44:08 +0000 (UTC) From: Daniel Mack To: dmitry.torokhov@gmail.com, robh+dt@kernel.org Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, Daniel Mack Subject: [PATCH 3/5] input: touchscreen: eeti: add support for DT properties to flip screen Date: Sun, 17 Jun 2018 13:46:57 +0200 Message-Id: <20180617114659.367-3-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180617114659.367-1-daniel@zonque.org> References: <20180617114659.367-1-daniel@zonque.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 Use touchscreen_parse_properties() to automatically set some of the common touchscreen properties. Also make flip_x and flip_y members of the private device context and allow setting them through both the module parameters and devicetree properties. Signed-off-by: Daniel Mack --- drivers/input/touchscreen/eeti_ts.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c index cc4fd33f9d6d..e7fade1a895c 100644 --- a/drivers/input/touchscreen/eeti_ts.c +++ b/drivers/input/touchscreen/eeti_ts.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ struct eeti_ts { struct i2c_client *client; struct input_dev *input; struct gpio_desc *attn_gpio; + bool flip_x, flip_y; bool running; }; @@ -74,10 +76,10 @@ static void eeti_ts_report_event(struct eeti_ts *eeti, u8 *buf) x >>= res - EETI_TS_BITDEPTH; y >>= res - EETI_TS_BITDEPTH; - if (flip_x) + if (eeti->flip_x) x = EETI_MAXVAL - x; - if (flip_y) + if (eeti->flip_y) y = EETI_MAXVAL - y; if (buf[0] & REPORT_BIT_HAS_PRESSURE) @@ -149,6 +151,7 @@ static void eeti_ts_close(struct input_dev *dev) static int eeti_ts_probe(struct i2c_client *client, const struct i2c_device_id *idp) { + struct touchscreen_properties props; struct device *dev = &client->dev; struct eeti_ts *eeti; struct input_dev *input; @@ -179,6 +182,8 @@ static int eeti_ts_probe(struct i2c_client *client, input_set_abs_params(input, ABS_Y, 0, EETI_MAXVAL, 0, 0); input_set_abs_params(input, ABS_PRESSURE, 0, 0xff, 0, 0); + touchscreen_parse_properties(input, false, &props); + input->name = client->name; input->id.bustype = BUS_I2C; input->open = eeti_ts_open; @@ -187,6 +192,9 @@ static int eeti_ts_probe(struct i2c_client *client, eeti->client = client; eeti->input = input; + eeti->flip_x = flip_x || props.invert_x; + eeti->flip_y = flip_y || props.invert_y; + eeti->attn_gpio = devm_gpiod_get_optional(dev, "attn", GPIOD_IN); if (IS_ERR(eeti->attn_gpio)) return PTR_ERR(eeti->attn_gpio);