From patchwork Thu Jan 25 19:08:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Niestroj X-Patchwork-Id: 10184743 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 F1D9560388 for ; Thu, 25 Jan 2018 19:36:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF66C289CB for ; Thu, 25 Jan 2018 19:35:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E439E28A09; Thu, 25 Jan 2018 19:35:59 +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=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 85D8C289CB for ; Thu, 25 Jan 2018 19:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751232AbeAYTf6 (ORCPT ); Thu, 25 Jan 2018 14:35:58 -0500 Received: from smtp.megiteam.pl ([31.186.83.105]:43425 "EHLO smtp.megiteam.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751171AbeAYTf6 (ORCPT ); Thu, 25 Jan 2018 14:35:58 -0500 Received: from [95.143.241.142] (helo=localhost.localdomain) by smtp.megiteam.pl with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eemt4-0002S9-5Y; Thu, 25 Jan 2018 20:08:38 +0100 From: Marcin Niestroj To: Dmitry Torokhov Cc: Bastien Nocera , Antonio Ospite , linux-input@vger.kernel.org, Marcin Niestroj Subject: [PATCH v3 1/3] Input: goodix - fix reported range Date: Thu, 25 Jan 2018 20:08:27 +0100 Message-Id: <20180125190829.8968-2-m.niestroj@grinn-global.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180125190829.8968-1-m.niestroj@grinn-global.com> References: <20180125190829.8968-1-m.niestroj@grinn-global.com> 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 Touchscreen coordinates are 0-indexed, so report touchscreen range as (0:size-1). Signed-off-by: Marcin Niestroj Fixes: ca96ea86eed4 ("Input: add driver for the Goodix touchpanel") Reviewed-by: Bastien Nocera --- Changes v2 -> v3: fix commit description (suggested by Bastien) Changes v1 -> v2: patch splitted off from patch 3 (suggested by Bastien) drivers/input/touchscreen/goodix.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index 69d0b8cbc71f..7896097ca69b 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -587,8 +587,8 @@ static void goodix_read_config(struct goodix_ts_data *ts) dev_warn(&ts->client->dev, "Error reading config (%d), using defaults\n", error); - ts->abs_x_max = GOODIX_MAX_WIDTH; - ts->abs_y_max = GOODIX_MAX_HEIGHT; + ts->abs_x_max = GOODIX_MAX_WIDTH - 1; + ts->abs_y_max = GOODIX_MAX_HEIGHT - 1; if (ts->swapped_x_y) swap(ts->abs_x_max, ts->abs_y_max); ts->int_trigger_type = GOODIX_INT_TRIGGER; @@ -596,8 +596,8 @@ static void goodix_read_config(struct goodix_ts_data *ts) return; } - ts->abs_x_max = get_unaligned_le16(&config[RESOLUTION_LOC]); - ts->abs_y_max = get_unaligned_le16(&config[RESOLUTION_LOC + 2]); + ts->abs_x_max = get_unaligned_le16(&config[RESOLUTION_LOC]) - 1; + ts->abs_y_max = get_unaligned_le16(&config[RESOLUTION_LOC + 2]) - 1; if (ts->swapped_x_y) swap(ts->abs_x_max, ts->abs_y_max); ts->int_trigger_type = config[TRIGGER_LOC] & 0x03; @@ -605,8 +605,8 @@ static void goodix_read_config(struct goodix_ts_data *ts) if (!ts->abs_x_max || !ts->abs_y_max || !ts->max_touch_num) { dev_err(&ts->client->dev, "Invalid config, using defaults\n"); - ts->abs_x_max = GOODIX_MAX_WIDTH; - ts->abs_y_max = GOODIX_MAX_HEIGHT; + ts->abs_x_max = GOODIX_MAX_WIDTH - 1; + ts->abs_y_max = GOODIX_MAX_HEIGHT - 1; if (ts->swapped_x_y) swap(ts->abs_x_max, ts->abs_y_max); ts->max_touch_num = GOODIX_MAX_CONTACTS;