From patchwork Fri May 11 13:30:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10394253 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 9EF7060236 for ; Fri, 11 May 2018 13:31:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8905928F5B for ; Fri, 11 May 2018 13:31:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91FED28FB9; Fri, 11 May 2018 13:31:00 +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 37C2C28EC5 for ; Fri, 11 May 2018 13:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752897AbeEKNan (ORCPT ); Fri, 11 May 2018 09:30:43 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60352 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752507AbeEKNam (ORCPT ); Fri, 11 May 2018 09:30:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2753C402509F; Fri, 11 May 2018 13:30:42 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-194.ams2.redhat.com [10.36.117.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2EF22026DEF; Fri, 11 May 2018 13:30:40 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov , Benjamin Tissoires Cc: Hans de Goede , Gregor Riepl , linux-input@vger.kernel.org Subject: [PATCH] Input: silead - support touchscreens with non 0 minimum coordinates Date: Fri, 11 May 2018 15:30:40 +0200 Message-Id: <20180511133040.7793-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 11 May 2018 13:30:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 11 May 2018 13:30:42 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'hdegoede@redhat.com' RCPT:'' 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 Silead bases touchscreens (depending on the firmware and/or the regulator) report coordinates which never reach 0 along one or both of their axis. This commit adds support for setting a "silead,min-x" and "min-y" property which indicates the minimum x/y values reported. When enabled this fixes e.g. not being able to click things in the GNOME3 top-bar on same tablets. Signed-off-by: Hans de Goede --- .../input/touchscreen/silead_gsl1680.txt | 3 +++ drivers/input/touchscreen/silead.c | 23 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt index 84752de12412..07e19ef46c56 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt @@ -25,6 +25,9 @@ Optional properties: - silead,max-fingers : maximum number of fingers the touchscreen can detect - silead,home-button : Boolean, set to true on devices which have a capacitive home-button build into the touchscreen +- silead,min-x : minimum raw x value reported by the touchscreen, set + this for firmwares/digitizers where this is not 0 +- silead,min-y : minimum raw y value reported by the touchscreen - vddio-supply : regulator phandle for controller VDDIO - avdd-supply : regulator phandle for controller AVDD diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c index ff7043f74a3d..024d15ba6d1b 100644 --- a/drivers/input/touchscreen/silead.c +++ b/drivers/input/touchscreen/silead.c @@ -77,6 +77,8 @@ struct silead_ts_data { struct regulator_bulk_data regulators[2]; char fw_name[64]; struct touchscreen_properties prop; + int min_x; + int min_y; u32 max_fingers; u32 chip_id; struct input_mt_pos pos[SILEAD_MAX_FINGERS]; @@ -144,6 +146,7 @@ static void silead_ts_read_data(struct i2c_client *client) u8 *bufp, buf[SILEAD_TS_DATA_LEN]; int touch_nr, softbutton, error, i; bool softbutton_pressed = false; + int x, y; error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_DATA, SILEAD_TS_DATA_LEN, buf); @@ -182,9 +185,14 @@ static void silead_ts_read_data(struct i2c_client *client) */ data->id[touch_nr] = (bufp[SILEAD_POINT_X_MSB_OFF] & SILEAD_EXTRA_DATA_MASK) >> 4; - touchscreen_set_mt_pos(&data->pos[touch_nr], &data->prop, - get_unaligned_le16(&bufp[SILEAD_POINT_X_OFF]) & 0xfff, - get_unaligned_le16(&bufp[SILEAD_POINT_Y_OFF]) & 0xfff); + + x = get_unaligned_le16(&bufp[SILEAD_POINT_X_OFF]) & 0xfff; + x = max(x - data->min_x, 0); + + y = get_unaligned_le16(&bufp[SILEAD_POINT_Y_OFF]) & 0xfff; + y = max(y - data->min_y, 0); + + touchscreen_set_mt_pos(&data->pos[touch_nr], &data->prop, x, y); touch_nr++; } @@ -408,6 +416,7 @@ static void silead_ts_read_props(struct i2c_client *client) struct device *dev = &client->dev; const char *str; int error; + u32 val; error = device_property_read_u32(dev, "silead,max-fingers", &data->max_fingers); @@ -422,6 +431,14 @@ static void silead_ts_read_props(struct i2c_client *client) "silead/%s", str); else dev_dbg(dev, "Firmware file name read error. Using default."); + + error = device_property_read_u32(dev, "silead,min-x", &val); + if (!error) + data->min_x = val; + + error = device_property_read_u32(dev, "silead,min-y", &val); + if (!error) + data->min_y = val; } #ifdef CONFIG_ACPI