linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Nir Perry <nirperry@gmail.com>,
	Masaki Ota <masaki.ota@jp.alps.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>
Subject: [PATCH 4.9 24/47] Input: ALPS - fix multi-touch decoding on SS4 plus touchpads
Date: Mon, 22 Jan 2018 09:45:35 +0100	[thread overview]
Message-ID: <20180122083927.463145228@linuxfoundation.org> (raw)
In-Reply-To: <20180122083925.568134913@linuxfoundation.org>

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nir Perry <nirperry@gmail.com>

commit 4d94e776bd29670f01befa27e12df784fa05fa2e upstream.

The fix for handling two-finger scroll (i4a646580f793 - "Input: ALPS -
fix two-finger scroll breakage in right side on ALPS touchpad")
introduced a minor "typo" that broke decoding of multi-touch events are
decoded on some ALPS touchpads.  For example, tapping with three-fingers
can no longer be used to emulate middle-mouse-button (the kernel doesn't
recognize this as the proper event, and doesn't report it correctly to
userspace).  This affects touchpads that use SS4 "plus" protocol
variant, like those found on Dell E7270 & E7470 laptops (tested on
E7270).

First, probably the code in alps_decode_ss4_v2() for case
SS4_PACKET_ID_MULTI used inconsistent indices to "f->mt[]". You can see
0 & 1 are used for the "if" part but 2 & 3 are used for the "else" part.

Second, in the previous patch, new macros were introduced to decode X
coordinates specific to the SS4 "plus" variant, but the macro to
define the maximum X value wasn't changed accordingly. The macros to
decode X values for "plus" variant are effectively shifted right by 1
bit, but the max wasn't shifted too. This causes the driver to
incorrectly handle "no data" cases, which also interfered with how
multi-touch was handled.

Fixes: 4a646580f793 ("Input: ALPS - fix two-finger scroll breakage...")
Signed-off-by: Nir Perry <nirperry@gmail.com>
Reviewed-by: Masaki Ota <masaki.ota@jp.alps.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/input/mouse/alps.c |   23 +++++++++++++----------
 drivers/input/mouse/alps.h |   10 ++++++----
 2 files changed, 19 insertions(+), 14 deletions(-)

--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -1247,29 +1247,32 @@ static int alps_decode_ss4_v2(struct alp
 	case SS4_PACKET_ID_MULTI:
 		if (priv->flags & ALPS_BUTTONPAD) {
 			if (IS_SS4PLUS_DEV(priv->dev_id)) {
-				f->mt[0].x = SS4_PLUS_BTL_MF_X_V2(p, 0);
-				f->mt[1].x = SS4_PLUS_BTL_MF_X_V2(p, 1);
+				f->mt[2].x = SS4_PLUS_BTL_MF_X_V2(p, 0);
+				f->mt[3].x = SS4_PLUS_BTL_MF_X_V2(p, 1);
+				no_data_x = SS4_PLUS_MFPACKET_NO_AX_BL;
 			} else {
 				f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
 				f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
+				no_data_x = SS4_MFPACKET_NO_AX_BL;
 			}
+			no_data_y = SS4_MFPACKET_NO_AY_BL;
 
 			f->mt[2].y = SS4_BTL_MF_Y_V2(p, 0);
 			f->mt[3].y = SS4_BTL_MF_Y_V2(p, 1);
-			no_data_x = SS4_MFPACKET_NO_AX_BL;
-			no_data_y = SS4_MFPACKET_NO_AY_BL;
 		} else {
 			if (IS_SS4PLUS_DEV(priv->dev_id)) {
-				f->mt[0].x = SS4_PLUS_STD_MF_X_V2(p, 0);
-				f->mt[1].x = SS4_PLUS_STD_MF_X_V2(p, 1);
+				f->mt[2].x = SS4_PLUS_STD_MF_X_V2(p, 0);
+				f->mt[3].x = SS4_PLUS_STD_MF_X_V2(p, 1);
+				no_data_x = SS4_PLUS_MFPACKET_NO_AX;
 			} else {
-				f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
-				f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
+				f->mt[2].x = SS4_STD_MF_X_V2(p, 0);
+				f->mt[3].x = SS4_STD_MF_X_V2(p, 1);
+				no_data_x = SS4_MFPACKET_NO_AX;
 			}
+			no_data_y = SS4_MFPACKET_NO_AY;
+
 			f->mt[2].y = SS4_STD_MF_Y_V2(p, 0);
 			f->mt[3].y = SS4_STD_MF_Y_V2(p, 1);
-			no_data_x = SS4_MFPACKET_NO_AX;
-			no_data_y = SS4_MFPACKET_NO_AY;
 		}
 
 		f->first_mp = 0;
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -120,10 +120,12 @@ enum SS4_PACKET_ID {
 #define SS4_IS_5F_DETECTED(_b)	((_b[2] & 0x10) == 0x10)
 
 
-#define SS4_MFPACKET_NO_AX	8160	/* X-Coordinate value */
-#define SS4_MFPACKET_NO_AY	4080	/* Y-Coordinate value */
-#define SS4_MFPACKET_NO_AX_BL	8176	/* Buttonless X-Coordinate value */
-#define SS4_MFPACKET_NO_AY_BL	4088	/* Buttonless Y-Coordinate value */
+#define SS4_MFPACKET_NO_AX		8160	/* X-Coordinate value */
+#define SS4_MFPACKET_NO_AY		4080	/* Y-Coordinate value */
+#define SS4_MFPACKET_NO_AX_BL		8176	/* Buttonless X-Coord value */
+#define SS4_MFPACKET_NO_AY_BL		4088	/* Buttonless Y-Coord value */
+#define SS4_PLUS_MFPACKET_NO_AX		4080	/* SS4 PLUS, X */
+#define SS4_PLUS_MFPACKET_NO_AX_BL	4088	/* Buttonless SS4 PLUS, X */
 
 /*
  * enum V7_PACKET_ID - defines the packet type for V7

  parent reply	other threads:[~2018-01-22  8:45 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22  8:45 [PATCH 4.9 00/47] 4.9.78-stable review Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 01/47] libnvdimm, btt: Fix an incompatibility in the log layout Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 02/47] scsi: sg: disable SET_FORCE_LOW_DMA Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 03/47] futex: Prevent overflow by strengthen input validation Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 04/47] ALSA: seq: Make ioctls race-free Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 05/47] ALSA: pcm: Remove yet superfluous WARN_ON() Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 06/47] ALSA: hda - Apply headphone noise quirk for another Dell XPS 13 variant Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 07/47] ALSA: hda - Apply the existing quirk to iMac 14,1 Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 08/47] timers: Unconditionally check deferrable base Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 09/47] af_key: fix buffer overread in verify_address_len() Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 10/47] af_key: fix buffer overread in parse_exthdrs() Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 11/47] iser-target: Fix possible use-after-free in connection establishment error Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 12/47] scsi: hpsa: fix volume offline state Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 13/47] sched/deadline: Zero out positive runtime after throttling constrained tasks Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 14/47] x86/retpoline: Fill RSB on context switch for affected CPUs Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 15/47] x86/retpoline: Add LFENCE to the retpoline/RSB filling RSB macros Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 16/47] objtool: Improve error message for bad file argument Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 17/47] x86/cpufeature: Move processor tracing out of scattered features Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 18/47] module: Add retpoline tag to VERMAGIC Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 19/47] x86/mm/pkeys: Fix fill_sig_info_pkey Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 20/47] x86/tsc: Fix erroneous TSC rate on Skylake Xeon Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 21/47] pipe: avoid round_pipe_size() nr_pages overflow on 32-bit Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 22/47] x86/apic/vector: Fix off by one in error path Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 23/47] perf tools: Fix build with ARCH=x86_64 Greg Kroah-Hartman
2018-01-22  8:45 ` Greg Kroah-Hartman [this message]
2018-01-22  8:45 ` [PATCH 4.9 25/47] Input: 88pm860x-ts - fix child-node lookup Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 26/47] Input: twl6040-vibra " Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 27/47] Input: twl4030-vibra - fix sibling-node lookup Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 28/47] tracing: Fix converting enums from the map in trace_event_eval_update() Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 29/47] phy: work around phys references to usb-nop-xceiv devices Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 30/47] ARM: sunxi_defconfig: Enable CMA Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 31/47] ARM: dts: kirkwood: fix pin-muxing of MPP7 on OpenBlocks A7 Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 32/47] can: peak: fix potential bug in packet fragmentation Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 33/47] scripts/gdb/linux/tasks.py: fix get_thread_info Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 34/47] proc: fix coredump vs read /proc/*/stat race Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 35/47] libata: apply MAX_SEC_1024 to all LITEON EP1 series devices Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 36/47] workqueue: avoid hard lockups in show_workqueue_state() Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 37/47] dm btree: fix serious bug in btree_split_beneath() Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 38/47] dm thin metadata: THIN_MAX_CONCURRENT_LOCKS should be 6 Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 39/47] arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 40/47] x86/cpu, x86/pti: Do not enable PTI on AMD processors Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 41/47] usbip: fix warning in vhci_hcd_probe/lockdep_init_map Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 42/47] x86/mce: Make machine check speculation protected Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 43/47] retpoline: Introduce start/end markers of indirect thunk Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 44/47] kprobes/x86: Blacklist indirect thunk functions for kprobes Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 45/47] kprobes/x86: Disable optimizing on the function jumps to indirect thunk Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 46/47] x86/pti: Document fix wrong index Greg Kroah-Hartman
2018-01-22  8:45 ` [PATCH 4.9 47/47] x86/retpoline: Optimize inline assembler for vmexit_fill_RSB Greg Kroah-Hartman
2018-01-22 18:50 ` [PATCH 4.9 00/47] 4.9.78-stable review Naresh Kamboju
2018-01-22 19:09 ` Guenter Roeck
2018-01-22 20:08 ` Shuah Khan
2018-01-23  0:08 ` kernelci.org bot

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=20180122083927.463145228@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masaki.ota@jp.alps.com \
    --cc=nirperry@gmail.com \
    --cc=stable@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;
as well as URLs for NNTP newsgroup(s).