All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Niestroj <m.niestroj@grinn-global.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Bastien Nocera <hadess@hadess.net>, Antonio Ospite <ao2@ao2.it>,
	linux-input@vger.kernel.org,
	Marcin Niestroj <m.niestroj@grinn-global.com>
Subject: [PATCH v3 1/3] Input: goodix - fix reported range
Date: Thu, 25 Jan 2018 20:08:27 +0100	[thread overview]
Message-ID: <20180125190829.8968-2-m.niestroj@grinn-global.com> (raw)
In-Reply-To: <20180125190829.8968-1-m.niestroj@grinn-global.com>

Touchscreen coordinates are 0-indexed, so report touchscreen range
as (0:size-1).

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Fixes: ca96ea86eed4 ("Input: add driver for the Goodix touchpanel")
---
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;
-- 
2.16.1


  reply	other threads:[~2018-01-25 19:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-25 19:08 [PATCH v3 0/3] Input: goodix - fixes and conversion to touchscreen_properties Marcin Niestroj
2018-01-25 19:08 ` Marcin Niestroj [this message]
2018-01-26  9:44   ` [PATCH v3 1/3] Input: goodix - fix reported range Bastien Nocera
2018-01-25 19:08 ` [PATCH v3 2/3] Input: goodix - fix simultaneous axes inversion and swap Marcin Niestroj
2018-01-26  9:44   ` Bastien Nocera
2018-01-25 19:08 ` [PATCH v3 3/3] Input: goodix - use generic touchscreen_properties Marcin Niestroj
2018-01-26  9:44   ` Bastien Nocera
2018-01-26 19:19   ` Dmitry Torokhov
2018-01-26 23:48     ` Bastien Nocera
2018-01-26 23:57       ` Dmitry Torokhov
2018-01-27  1:19         ` Bastien Nocera
2018-01-29 16:49     ` Marcin Niestroj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180125190829.8968-2-m.niestroj@grinn-global.com \
    --to=m.niestroj@grinn-global.com \
    --cc=ao2@ao2.it \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hadess@hadess.net \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.