From patchwork Wed Sep 30 22:29:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karsten Merker X-Patchwork-Id: 7303051 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 97010BF90C for ; Wed, 30 Sep 2015 22:31:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE0C52055A for ; Wed, 30 Sep 2015 22:31:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BBD562062B for ; Wed, 30 Sep 2015 22:30:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751002AbbI3Wam (ORCPT ); Wed, 30 Sep 2015 18:30:42 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:61070 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753606AbbI3Waj (ORCPT ); Wed, 30 Sep 2015 18:30:39 -0400 Received: from excalibur.cnev.de ([81.173.231.248]) by mrelayeu.kundenserver.de (mreue004) with ESMTPSA (Nemesis) id 0MAysS-1Zp5PJ1V6y-00A0kC; Thu, 01 Oct 2015 00:30:33 +0200 Received: from localhost ([127.0.0.1] helo=excalibur.cnev.de) by excalibur.cnev.de with esmtp (Exim 4.84) (envelope-from ) id 1ZhPtO-0001rM-Tu; Thu, 01 Oct 2015 00:30:31 +0200 From: Karsten Merker To: Bastien Nocera , Dmitry Torokhov , Irina Tirdea Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Chen-Yu Tsai , Karsten Merker Subject: [PATCH 1/2] Input: goodix - add dt axis swapping and axis inversion support Date: Thu, 1 Oct 2015 00:29:54 +0200 Message-Id: <1443652195-7104-2-git-send-email-merker@debian.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443652195-7104-1-git-send-email-merker@debian.org> References: <1443652195-7104-1-git-send-email-merker@debian.org> X-Provags-ID: V03:K0:/fT89byepE7XBHlRHOj3Dj+vgugT0tKdWtwDBDhiZYO7XcvmzfI 4DApaZ6TJdJv2mAGZYwfsFciT1zkzTM0Rttam5HpncELurdYMGipYbMeV66I8bF5zqQFEQi HzGUICKyCEnWWP3iv+A6cAR8DvVYpZTwVzNe8j65SUFQzA7MatGvMmRBUo+Lbw5bKiWKPvD RqB8Zdr4I2baB5KZrelOg== X-UI-Out-Filterresults: notjunk:1; V01:K0:h+KONzw6SZU=:C2g8U3i53JLkEeJCWol++R HtuBzKY/eVciA9xP/+yl/SF0B/mGkBdQmBUThNkJ8F2jj0QybbuU3KtP0JUaG8W5yXsaQkPqN +k31qWQfW2V0IYiY2SQ6A2rU0JdDjbYuFI+GStRyueeGFSboWDm05hD47U+oxXjW2prrfUo2F QxR3hDA07OxgcG7U32ods75ABLFaCvTWhJaimMUjBCSC8Mcup7d8e6D5oJdAM/RnTnrSm2rrA 7Tx3lCEQav1FvZ/bLrWY6gcKLpCNdfnEb39QuBVcWJSge8Aqszc7fou1euTmxJdfQUEfOCmNh T72KfCxCrgweHLF3H8QjtRMr8f7HBBs7tghGzR94FBUr8+L4XsxYCKfnGEOG9r49/qsS4OJhV wX2MetVAHor5IgBtNRU/W+9ssC3trixnUaiWIkBArERWquJ2P55diRpMzflxdk53CGA/9nRBM rDr8sN8UVAeFprgIY2GFPslK7LcNEh9leC6y8aNLYdn6urLyQtjyd9ELnxwulNaSEd45zLMcH tnm5zpsGs+ukG+OvkefOSE7gvT5MkGu/ZIz0WbMlim1YTiRRSkByN4I1NpgEnFLhSa/XzTU1+ svfG6G07dITdDqLMaYzwyR+ymj8+81ULJwPuZZtVyPuuq2kGnU6LwJSYLhFPPCOKxlQ0FsB91 gatDxD2/brtGcW8XETTRIRBu13GTMLcGlGsCpo6hhZtFyX4RFtzwciH3A2OIc3D7Gfxo= Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement support for the following device-tree properties in the goodix touchscreen driver: - touchscreen-inverted-x: X axis is inverted (boolean) - touchscreen-inverted-y: Y axis is inverted (boolean) - touchscreen-swapped-x-y: X and Y axis are swapped (boolean) These are necessary on tablets which have a display in portrait format while the touchscreen is in landscape format, such as e.g. the MSI Primo 81. Signed-off-by: Karsten Merker --- drivers/input/touchscreen/goodix.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index f8e5b49..f2b1590 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -2,6 +2,7 @@ * Driver for Goodix Touchscreens * * Copyright (c) 2014 Red Hat Inc. + * Copyright (c) 2015 K. Merker * * This code is based on gt9xx.c authored by andrew@goodix.com: * @@ -48,6 +49,9 @@ struct goodix_ts_data { unsigned long irq_flags; atomic_t esd_timeout; struct delayed_work esd_work; + bool swapped_x_y; + bool inverted_x; + bool inverted_y; }; #define GOODIX_DEVICE_ESD_TIMEOUT_PROPERTY "esd-recovery-timeout-ms" @@ -262,6 +266,14 @@ static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data) input_y = ts->abs_y_max - input_y; } + /* Inversions have to happen before axis swapping */ + if (ts->inverted_x) + input_x = ts->abs_x_max - input_x; + if (ts->inverted_y) + input_y = ts->abs_y_max - input_y; + if (ts->swapped_x_y) + swap(input_x, input_y); + input_mt_slot(ts->input_dev, id); input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); input_report_abs(ts->input_dev, ABS_MT_POSITION_X, input_x); @@ -670,6 +682,8 @@ static void goodix_read_config(struct goodix_ts_data *ts) error); ts->abs_x_max = GOODIX_MAX_WIDTH; ts->abs_y_max = GOODIX_MAX_HEIGHT; + if (ts->swapped_x_y) + swap(ts->abs_x_max, ts->abs_y_max); ts->int_trigger_type = GOODIX_INT_TRIGGER; ts->max_touch_num = GOODIX_MAX_CONTACTS; return; @@ -677,6 +691,8 @@ static void goodix_read_config(struct goodix_ts_data *ts) ts->abs_x_max = get_unaligned_le16(&config[RESOLUTION_LOC]); ts->abs_y_max = get_unaligned_le16(&config[RESOLUTION_LOC + 2]); + if (ts->swapped_x_y) + swap(ts->abs_x_max, ts->abs_y_max); ts->int_trigger_type = config[TRIGGER_LOC] & 0x03; ts->max_touch_num = config[MAX_CONTACTS_LOC] & 0x0f; if (!ts->abs_x_max || !ts->abs_y_max || !ts->max_touch_num) { @@ -684,6 +700,8 @@ static void goodix_read_config(struct goodix_ts_data *ts) "Invalid config, using defaults\n"); ts->abs_x_max = GOODIX_MAX_WIDTH; ts->abs_y_max = GOODIX_MAX_HEIGHT; + if (ts->swapped_x_y) + swap(ts->abs_x_max, ts->abs_y_max); ts->max_touch_num = GOODIX_MAX_CONTACTS; } @@ -913,6 +931,15 @@ static int goodix_ts_probe(struct i2c_client *client, ts->cfg_len = goodix_get_cfg_len(ts->id); +#ifdef CONFIG_OF + ts->swapped_x_y = of_property_read_bool(client->dev.of_node, + "touchscreen-swapped-x-y"); + ts->inverted_x = of_property_read_bool(client->dev.of_node, + "touchscreen-inverted-x"); + ts->inverted_y = of_property_read_bool(client->dev.of_node, + "touchscreen-inverted-y"); +#endif + goodix_read_config(ts); if (ts->gpiod_int && ts->gpiod_rst) {