From patchwork Sun Oct 18 15:52:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karsten Merker X-Patchwork-Id: 7430631 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1A93F9F37F for ; Sun, 18 Oct 2015 15:54:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27C1F20619 for ; Sun, 18 Oct 2015 15:54:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B21620614 for ; Sun, 18 Oct 2015 15:54:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932144AbbJRPxt (ORCPT ); Sun, 18 Oct 2015 11:53:49 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:56147 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932143AbbJRPxp (ORCPT ); Sun, 18 Oct 2015 11:53:45 -0400 Received: from excalibur.cnev.de ([84.44.243.249]) by mrelayeu.kundenserver.de (mreue005) with ESMTPSA (Nemesis) id 0M0N4b-1ahTIW3H2b-00uX22; Sun, 18 Oct 2015 17:53:25 +0200 Received: from localhost ([127.0.0.1] helo=excalibur.cnev.de) by excalibur.cnev.de with esmtp (Exim 4.84) (envelope-from ) id 1ZnqGv-0007bF-JB; Sun, 18 Oct 2015 17:53:21 +0200 From: Karsten Merker To: Bastien Nocera , Dmitry Torokhov , Irina Tirdea , Aleksei Mamlin , linux-input@vger.kernel.org, Ian Campbell Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chen-Yu Tsai , Karsten Merker Subject: [PATCH RFC V3 1/3] Input: goodix - add axis swapping and axis inversion support Date: Sun, 18 Oct 2015 17:52:57 +0200 Message-Id: <1445183579-29176-2-git-send-email-merker@debian.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1445183579-29176-1-git-send-email-merker@debian.org> References: <1445183579-29176-1-git-send-email-merker@debian.org> X-Provags-ID: V03:K0:fZ/iB4WvxbyWedboBFS19PnAfzoZVUKBGn52NkrQlLTuSlHJhJk VwT9sqH4k8ONGrRIWFLHb4SRGEZl6jOye2ZFwRldmLxKax/49iZLPNpGCLxYk95pBlqpfrh lFXcEIIQLm+ZoG+Z6R7WvMn3EppjCkUr5NNznzRflMGdTmxfsKxz4tGFq5hpXDt256whq38 JhPHcSpi7lTYOSFNFXT6A== X-UI-Out-Filterresults: notjunk:1; V01:K0:X5Cn5rsSiGs=:dUD9VkW/zutB/sT1RuiBZr J3SWU0tdXiaX4+77wElwXf1LORWrOHes9+BxLintRMpDOYqvp/qntKT55x4mhUPn+kxPPr6RU qhPA/Mb1AT7khx5NRAqT5uQzCRgEh61NkT7XENamh9ri6yWrN/AZEzV1+CANYl6pw5ZA1X4Jm yaYSq9CLO1wIU+0wKkaGiEJ/KQEzBadk9V/R7xaaqfgvpw+ExLdlDecj7dG428Mf9r33B+2ux q8ltT570EpUe2ciU+TacV9FCyTZ9bEm6672HA8DBVG9aP0zQe8kmkkrrNcvXTMa2o1dHn6Qhk axgEoO4mwt3g7WeVeEWC+YaTVBwuC6xboCqCjuKgckD72Ij1s/VHYhPuYNEUGCoS/xc8QaXnW dbhbACb08ZK4l4IpY/GOUkyNv/gPIUmTm89qynTIrBhp1aKh5Kdkv7f957DshN+kvmZPpwtDB 88sMvhEwY3dyUbtJDyH2lylgkUmkhNdeKHqXeYLy36T3xJSGrCfTxEKF26LKHSZ875veqwGnp oc/REfCPjc1TAVs/4FjbjGw8LebUhTlZIY60+Lj0qnuEGvVimN+sCnTIhUY63rMGdU7g7S8Uh SJn/C1XQgi654VjLtYBnV68BWNRCQ28oB1OEyp28a2HGH2TdPnnoyNiD3wqUagx7PFzLK0JlH 80F6iVbGK5TlWnBUhpeEidP8h9kcPEQSxpPhmaE6ByqYwe5UpohnAM9zl4TcASygIlWM= 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 and ACPI 5.1 DSD 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 Tested-by: Bastien Nocera Tested-by: Irina Tirdea --- drivers/input/touchscreen/goodix.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index 22bfc4b..b585123 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: * @@ -53,6 +54,9 @@ struct goodix_ts_data { atomic_t open_count; /* Protects power management calls and access to suspended flag */ struct mutex mutex; + bool swapped_x_y; + bool inverted_x; + bool inverted_y; }; #define GOODIX_GPIO_INT_NAME "irq" @@ -271,6 +275,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); @@ -666,6 +678,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; @@ -673,6 +687,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) { @@ -680,6 +696,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; } @@ -805,6 +823,13 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) { int error; + ts->swapped_x_y = device_property_read_bool(&ts->client->dev, + "touchscreen-swapped-x-y"); + ts->inverted_x = device_property_read_bool(&ts->client->dev, + "touchscreen-inverted-x"); + ts->inverted_y = device_property_read_bool(&ts->client->dev, + "touchscreen-inverted-y"); + goodix_read_config(ts); error = goodix_request_input_dev(ts);