From patchwork Thu Oct 20 19:59:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin Cooper X-Patchwork-Id: 9387503 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 6EF3060487 for ; Thu, 20 Oct 2016 20:01:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BF1129A58 for ; Thu, 20 Oct 2016 20:01:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 507FD29B73; Thu, 20 Oct 2016 20:01:03 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 1A27329BA0 for ; Thu, 20 Oct 2016 20:01:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936553AbcJTUAj (ORCPT ); Thu, 20 Oct 2016 16:00:39 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:43957 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938192AbcJTUAX (ORCPT ); Thu, 20 Oct 2016 16:00:23 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id u9KK05ms018405; Thu, 20 Oct 2016 15:00:05 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id u9KK048K019277; Thu, 20 Oct 2016 15:00:05 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Thu, 20 Oct 2016 15:00:03 -0500 Received: from dbdmail01.india.ti.com (dbdmail01.india.ti.com [172.24.162.206]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u9KK02fS009330; Thu, 20 Oct 2016 15:00:03 -0500 Received: from udb0273011.am.dhcp.ti.com (udb0273011.am.dhcp.ti.com [128.247.83.33]) by dbdmail01.india.ti.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id u9KJxfb2011145; Fri, 21 Oct 2016 01:29:58 +0530 From: Franklin S Cooper Jr To: , , , , , , , , , , CC: Franklin S Cooper Jr Subject: [PATCH 4/4] Input: goodix - Support interchanging x and y coordinates in hardware Date: Thu, 20 Oct 2016 14:59:17 -0500 Message-ID: <20161020195917.20051-5-fcooper@ti.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161020195917.20051-1-fcooper@ti.com> References: <20161020195917.20051-1-fcooper@ti.com> 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 On systems with a fixed display/touchscreen orientation it is important to pass in the "correct" x and y coordinates based on the orientation. Currently, to support landscape and portrait touchscreen-swapped-x-y simply does the following: Assuming touchscreen is as follows: X: 1280 Y:800 programmed in touchscreen controller and also interchange bit cleared. Assuming ts mounted in portrait mode. 1280 (X) ------ | | | | 800 (Y) | | | | ------ 800 (Y) ------ | | | | 1280 (X) | | | | ------ However, the above isn't really what we want especially in distros that assumes a fixed orientation. In this case what we really want is to interchange the x and y coordinates so the Y coordinate can return a max value of 1280 and X can return a max value of 800. 800 (X) ------ | | | | 1280 (Y) | | | | ------ Since the driver is limited to the value reported by the touchscreen controller this issue can't be fixed purely in the driver. Therefore, add a new DT property that supports interchanging X and Y coordinates internally within the hardware. Signed-off-by: Franklin S Cooper Jr --- .../devicetree/bindings/input/touchscreen/goodix.txt | 2 ++ drivers/input/touchscreen/goodix.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt index ebc7cb7..b8be2ab 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt @@ -25,6 +25,8 @@ Optional properties: - touchscreen-inverted-y : Y axis is inverted (boolean) - touchscreen-swapped-x-y : X and Y axis are swapped (boolean) (swapping is done after inverting the axis) + - touchscreen-inter-x-y : X and Y maximum values programmed in the device + are interchanged internally in hardware. (boolean) Example: diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index c2428e1..3f93375 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -39,6 +39,7 @@ struct goodix_ts_data { bool swapped_x_y; bool inverted_x; bool inverted_y; + bool interchange_x_y; unsigned int max_touch_num; unsigned int int_trigger_type; int cfg_len; @@ -76,6 +77,9 @@ struct goodix_ts_data { #define MAX_CONTACTS_LOC 5 #define TRIGGER_LOC 6 +/* Register Bits */ +#define XY_COORD_INTER 3 + static const unsigned long goodix_irq_flags[] = { IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, @@ -500,6 +504,10 @@ static void goodix_tweak_config(struct goodix_ts_data *ts) put_unaligned_le16(ts->abs_x_max, &config[RESOLUTION_LOC]); put_unaligned_le16(ts->abs_y_max, &config[RESOLUTION_LOC + 2]); + if (ts->interchange_x_y) + config[TRIGGER_LOC] = config[TRIGGER_LOC] | + (1 << XY_COORD_INTER); + check_sum = goodix_calculate_checksum(ts->cfg_len, config); config[raw_cfg_len] = check_sum; @@ -700,6 +708,11 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) } } + ts->interchange_x_y = device_property_read_bool(&ts->client->dev, + "touchscreen-inter-x-y"); + if (ts->interchange_x_y) + alter_config = true; + if (alter_config) goodix_tweak_config(ts);