From patchwork Tue Mar 12 08:21:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Jander X-Patchwork-Id: 10848729 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 5F601139A for ; Tue, 12 Mar 2019 08:28:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B7FE2948A for ; Tue, 12 Mar 2019 08:28:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F89129574; Tue, 12 Mar 2019 08:28:53 +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 885382948A for ; Tue, 12 Mar 2019 08:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727577AbfCLI2v (ORCPT ); Tue, 12 Mar 2019 04:28:51 -0400 Received: from protonic.xs4all.nl ([83.163.252.89]:46380 "EHLO protonic.nl" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726844AbfCLI2v (ORCPT ); Tue, 12 Mar 2019 04:28:51 -0400 X-Greylist: delayed 410 seconds by postgrey-1.27 at vger.kernel.org; Tue, 12 Mar 2019 04:28:51 EDT Received: from erd988.prtnl (erd988.prtnl [192.168.224.30]) by sparta (Postfix) with ESMTP id 53BC444A00D2; Tue, 12 Mar 2019 09:23:37 +0100 (CET) From: David Jander To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: Greg KH , Mark Brown , Imre Deak , David Jander Subject: [PATCH 1/2] input: touchscreen: ads7846.c: Add support for invert_x/y in dt Date: Tue, 12 Mar 2019 09:21:44 +0100 Message-Id: <20190312082145.8906-2-david@protonic.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190312082145.8906-1-david@protonic.nl> References: <20190312082145.8906-1-david@protonic.nl> MIME-Version: 1.0 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 Added device-tree flags "ti,invert_x" and "ti,invert_y" to specify inversion of X and/or Y axes respectively. Signed-off-by: David Jander --- .../bindings/input/touchscreen/ads7846.txt | 2 ++ drivers/input/touchscreen/ads7846.c | 12 ++++++++++++ include/linux/spi/ads7846.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt index 04413da51391..946f4fd0133e 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt @@ -33,6 +33,8 @@ Optional properties: ti,keep-vref-on set to keep vref on for differential measurements as well ti,swap-xy swap x and y axis + ti,invert_x invert x axis + ti,invert_y invert y axis ti,settle-delay-usec Settling time of the analog signals; a function of Vcc and the capacitance on the X/Y drivers. If set to non-zero, diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index a2f45aefce08..b853e889c6ec 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -111,6 +111,8 @@ struct ads7846 { u16 pressure_max; bool swap_xy; + bool invert_x; + bool invert_y; bool use_internal; struct ads7846_packet *packet; @@ -829,6 +831,12 @@ static void ads7846_report_state(struct ads7846 *ts) if (ts->swap_xy) swap(x, y); + if (ts->invert_x) + x = MAX_12BIT - x; + + if (ts->invert_y) + y = MAX_12BIT - y; + if (!ts->pendown) { input_report_key(input, BTN_TOUCH, 1); ts->pendown = true; @@ -1212,6 +1220,8 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) pdata->keep_vref_on = of_property_read_bool(node, "ti,keep-vref-on"); pdata->swap_xy = of_property_read_bool(node, "ti,swap-xy"); + pdata->invert_x = of_property_read_bool(node, "ti,invert_x"); + pdata->invert_y = of_property_read_bool(node, "ti,invert_y"); of_property_read_u16(node, "ti,settle-delay-usec", &pdata->settle_delay_usecs); @@ -1316,6 +1326,8 @@ static int ads7846_probe(struct spi_device *spi) ts->vref_mv = pdata->vref_mv; ts->swap_xy = pdata->swap_xy; + ts->invert_x = pdata->invert_x; + ts->invert_y = pdata->invert_y; if (pdata->filter != NULL) { if (pdata->filter_init != NULL) { diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h index 1a5eaef3b7f2..6b8022c625a3 100644 --- a/include/linux/spi/ads7846.h +++ b/include/linux/spi/ads7846.h @@ -20,6 +20,8 @@ struct ads7846_platform_data { bool keep_vref_on; /* set to keep vref on for differential * measurements as well */ bool swap_xy; /* swap x and y axes */ + bool invert_x; /* Invert x axis */ + bool invert_y; /* Invert y axis */ /* Settling time of the analog signals; a function of Vcc and the * capacitance on the X/Y drivers. If set to non-zero, two samples