From patchwork Thu Oct 20 19:59:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin Cooper X-Patchwork-Id: 9387505 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 6BF1260487 for ; Thu, 20 Oct 2016 20:01:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58C8C29B5F for ; Thu, 20 Oct 2016 20:01:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CD2D29B8C; Thu, 20 Oct 2016 20:01:37 +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 5A7FF29B5F for ; Thu, 20 Oct 2016 20:01:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933076AbcJTUA7 (ORCPT ); Thu, 20 Oct 2016 16:00:59 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:43941 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753260AbcJTUAL (ORCPT ); Thu, 20 Oct 2016 16:00:11 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id u9KK003F018343; Thu, 20 Oct 2016 15:00:00 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u9KK00xx029178; Thu, 20 Oct 2016 15:00:00 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.294.0; Thu, 20 Oct 2016 14:59:59 -0500 Received: from dbdmail01.india.ti.com (dbdmail01.india.ti.com [172.24.162.206]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u9KJxwR8003647; Thu, 20 Oct 2016 14:59:59 -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 u9KJxfb1011145; Fri, 21 Oct 2016 01:29:54 +0530 From: Franklin S Cooper Jr To: , , , , , , , , , , CC: Franklin S Cooper Jr Subject: [PATCH 3/4] Input: goodix - Tweak configuration to use passed in touchscreen resolution Date: Thu, 20 Oct 2016 14:59:16 -0500 Message-ID: <20161020195917.20051-4-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 Some goodix touchscreen controllers aren't programed properly to match the display panel it is used on. Although the defaults may largely work it is also likely that the screen resolution will be incorrect. Therefore, add support to allow via DT for the touchscreen resolution to be set and reprogram the controller to use this updated resolution. Signed-off-by: Franklin S Cooper Jr Acked-by: Rob Herring --- .../bindings/input/touchscreen/goodix.txt | 2 ++ drivers/input/touchscreen/goodix.c | 26 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt index c98757a..ebc7cb7 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt @@ -19,6 +19,8 @@ Optional properties: interrupt gpio pin as output to reset the device. - reset-gpios : GPIO pin used for reset + - touchscreen-size-x : horizontal resolution of touchscreen (in pixels) + - touchscreen-size-y : vertical resolution of touchscreen (in pixels) - 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) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index 01e12f8..c2428e1 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -496,6 +496,10 @@ static void goodix_tweak_config(struct goodix_ts_data *ts) return; } + /* Setting X and Y Resolution */ + put_unaligned_le16(ts->abs_x_max, &config[RESOLUTION_LOC]); + put_unaligned_le16(ts->abs_y_max, &config[RESOLUTION_LOC + 2]); + check_sum = goodix_calculate_checksum(ts->cfg_len, config); config[raw_cfg_len] = check_sum; @@ -669,6 +673,8 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts) static int goodix_configure_dev(struct goodix_ts_data *ts) { int error; + bool alter_config = false; + u32 max_x, max_y; ts->swapped_x_y = device_property_read_bool(&ts->client->dev, "touchscreen-swapped-x-y"); @@ -676,9 +682,27 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) "touchscreen-inverted-x"); ts->inverted_y = device_property_read_bool(&ts->client->dev, "touchscreen-inverted-y"); - goodix_read_config(ts); + if (device_property_present(&ts->client->dev, "touchscreen-size-x") && + device_property_present(&ts->client->dev, "touchscreen-size-y")) { + + device_property_read_u32(&ts->client->dev, "touchscreen-size-x", + &max_x); + + device_property_read_u32(&ts->client->dev, "touchscreen-size-y", + &max_y); + + if (max_x > 0 && max_y > 0) { + ts->abs_x_max = max_x; + ts->abs_y_max = max_y; + alter_config = true; + } + } + + if (alter_config) + goodix_tweak_config(ts); + error = goodix_request_input_dev(ts); if (error) return error;