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 v2 2/3] Input: goodix - fix simultaneous axes inversion and swap
Date: Tue, 14 Nov 2017 13:42:16 +0100 [thread overview]
Message-ID: <20171114124217.2863-3-m.niestroj@grinn-global.com> (raw)
In-Reply-To: <20171114124217.2863-1-m.niestroj@grinn-global.com>
goodix_ts_data structure contains abs_x_max and abs_y_max members,
which contain already swapped maximum ranges. That causes reporting
touch events with invalid position (out of range values).
Take into account that abs_x_max and abs_y_max are already swapped
in goodix_ts_report_touch(), so position for inverted axes will be
calculated correctly.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Fixes: ad48cf5e9597 ("Input: goodix - add axis swapping and axis inversion support")
---
Changes v1 -> v2: patch splitted off from patch 3 (suggested by Bastien)
drivers/input/touchscreen/goodix.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index 7896097ca69b..dc832890f6d3 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -296,12 +296,18 @@ static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data)
int input_w = get_unaligned_le16(&coor_data[5]);
/* Inversions have to happen before axis swapping */
- if (ts->inverted_x)
- input_x = ts->abs_x_max - input_x;
- if (ts->inverted_y)
- input_y = ts->abs_y_max - input_y;
- if (ts->swapped_x_y)
+ if (!ts->swapped_x_y) {
+ if (ts->inverted_x)
+ input_x = ts->abs_x_max - input_x;
+ if (ts->inverted_y)
+ input_y = ts->abs_y_max - input_y;
+ } else {
+ if (ts->inverted_x)
+ input_x = ts->abs_y_max - input_x;
+ if (ts->inverted_y)
+ input_y = ts->abs_x_max - input_y;
swap(input_x, input_y);
+ }
input_mt_slot(ts->input_dev, id);
input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true);
--
2.15.0
next prev parent reply other threads:[~2017-11-14 12:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-14 12:42 [PATCH v2 0/3] Input: goodix - fixes and conversion to touchscreen_properties Marcin Niestroj
2017-11-14 12:42 ` [PATCH v2 1/3] Input: goodix - fix reported range Marcin Niestroj
2017-11-14 14:08 ` Bastien Nocera
2017-11-14 12:42 ` Marcin Niestroj [this message]
2017-11-14 14:17 ` [PATCH v2 2/3] Input: goodix - fix simultaneous axes inversion and swap Bastien Nocera
2017-11-14 12:42 ` [PATCH v2 3/3] Input: goodix - use generic touchscreen_properties Marcin Niestroj
2017-11-14 14:37 ` Bastien Nocera
2017-11-14 18:03 ` Dmitry Torokhov
2017-11-15 13:43 ` Bastien Nocera
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=20171114124217.2863-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox