linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix Alps Touchpad two finger scroll does not work on right side
@ 2017-07-21  0:27 Masaki Ota
  2017-07-21  6:53 ` Takashi Iwai
  2017-07-22 18:58 ` Paul Donohue
  0 siblings, 2 replies; 5+ messages in thread
From: Masaki Ota @ 2017-07-21  0:27 UTC (permalink / raw)
  To: dmitry.torokhov, linux-kernel, benjamin.tissoires, pali.rohar
  Cc: labbott, nick.m.fletcher, tiwai, linux-input, linux-kernel, masaki.ota

From: Masaki Ota <masaki.ota@jp.alps.com>

Fixed the issue that two finger scroll does not work correctly
on V8 protocol. The cause is that V8 protocol X-coordinate decode
is wrong at SS4 PLUS device. I added SS4 PLUS X decode definition.

Signed-off-by: Masaki Ota <masaki.ota@jp.alps.com>
Tested-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/input/mouse/alps.c | 41 +++++++++++++++++++++++++++++++----------
 drivers/input/mouse/alps.h |  8 ++++++++
 2 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index f210e19ddba6..2627c724bb7c 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -1210,14 +1210,24 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
 
 	case SS4_PACKET_ID_TWO:
 		if (priv->flags & ALPS_BUTTONPAD) {
-			f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
+			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);
+			} else {
+				f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
+				f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
+			}
 			f->mt[0].y = SS4_BTL_MF_Y_V2(p, 0);
-			f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
 			f->mt[1].y = SS4_BTL_MF_Y_V2(p, 1);
 		} else {
-			f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
+			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);
+			} 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[0].y = SS4_STD_MF_Y_V2(p, 0);
-			f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
 			f->mt[1].y = SS4_STD_MF_Y_V2(p, 1);
 		}
 		f->pressure = SS4_MF_Z_V2(p, 0) ? 0x30 : 0;
@@ -1234,16 +1244,27 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
 
 	case SS4_PACKET_ID_MULTI:
 		if (priv->flags & ALPS_BUTTONPAD) {
-			f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
+			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);
+			} else {
+				f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
+				f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
+			}
+
 			f->mt[2].y = SS4_BTL_MF_Y_V2(p, 0);
-			f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
 			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 {
-			f->mt[2].x = SS4_STD_MF_X_V2(p, 0);
+			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);
+			} 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].y = SS4_STD_MF_Y_V2(p, 0);
-			f->mt[3].x = SS4_STD_MF_X_V2(p, 1);
 			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;
@@ -2536,8 +2557,8 @@ static int alps_set_defaults_ss4_v2(struct psmouse *psmouse,
 
 	memset(otp, 0, sizeof(otp));
 
-	if (alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]) ||
-	    alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]))
+	if (alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]) ||
+	    alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]))
 		return -1;
 
 	alps_update_device_area_ss4_v2(otp, priv);
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
index 4334f2805d93..75542199edda 100644
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -99,6 +99,10 @@ enum SS4_PACKET_ID {
 				 ((_b[1 + _i * 3]  << 5) & 0x1F00)	\
 				)
 
+#define SS4_PLUS_STD_MF_X_V2(_b, _i) (((_b[0 + (_i) * 3] << 4) & 0x0070) | \
+				 ((_b[1 + (_i) * 3]  << 4) & 0x0F80)	\
+				)
+
 #define SS4_STD_MF_Y_V2(_b, _i)	(((_b[1 + (_i) * 3] << 3) & 0x0010) |	\
 				 ((_b[2 + (_i) * 3] << 5) & 0x01E0) |	\
 				 ((_b[2 + (_i) * 3] << 4) & 0x0E00)	\
@@ -108,6 +112,10 @@ enum SS4_PACKET_ID {
 				 ((_b[0 + (_i) * 3] >> 3) & 0x0010)	\
 				)
 
+#define SS4_PLUS_BTL_MF_X_V2(_b, _i) (SS4_PLUS_STD_MF_X_V2(_b, _i) |	\
+				 ((_b[0 + (_i) * 3] >> 4) & 0x0008)	\
+				)
+
 #define SS4_BTL_MF_Y_V2(_b, _i)	(SS4_STD_MF_Y_V2(_b, _i) | \
 				 ((_b[0 + (_i) * 3] >> 3) & 0x0008)	\
 				)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix Alps Touchpad two finger scroll does not work on right side
  2017-07-21  0:27 [PATCH] Fix Alps Touchpad two finger scroll does not work on right side Masaki Ota
@ 2017-07-21  6:53 ` Takashi Iwai
  2017-07-31 12:10   ` Takashi Iwai
  2017-07-22 18:58 ` Paul Donohue
  1 sibling, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2017-07-21  6:53 UTC (permalink / raw)
  To: Masaki Ota
  Cc: dmitry.torokhov, linux-kernel, benjamin.tissoires, pali.rohar,
	labbott, nick.m.fletcher, tiwai, linux-input, linux-kernel,
	masaki.ota

On Fri, 21 Jul 2017 02:27:30 +0200,
Masaki Ota wrote:
> 
> From: Masaki Ota <masaki.ota@jp.alps.com>
> 
> Fixed the issue that two finger scroll does not work correctly
> on V8 protocol. The cause is that V8 protocol X-coordinate decode
> is wrong at SS4 PLUS device. I added SS4 PLUS X decode definition.
> 
> Signed-off-by: Masaki Ota <masaki.ota@jp.alps.com>
> Tested-by: Takashi Iwai <tiwai@suse.de>

Please put Cc to stable, too, in addition to:

Fixes: e7348396c6d5 ("Input: ALPS - fix V8+ protocol handling (73 03 28)")

Mote to note: the problem itself was introduced even before the commit
mentioned above.  But the two-finger scroll worked casually although
it reported wrong values by some reason.  It got broken by the commit
above because it changed x_max value, and now libinput correctly
ignores the MT events at right-half of touchpad (the X coord is
reported as doubled).

Also, one finger event is decoded differently, thus it didn't suffer
from this problem.


thanks,

Takashi

> ---
>  drivers/input/mouse/alps.c | 41 +++++++++++++++++++++++++++++++----------
>  drivers/input/mouse/alps.h |  8 ++++++++
>  2 files changed, 39 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> index f210e19ddba6..2627c724bb7c 100644
> --- a/drivers/input/mouse/alps.c
> +++ b/drivers/input/mouse/alps.c
> @@ -1210,14 +1210,24 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
>  
>  	case SS4_PACKET_ID_TWO:
>  		if (priv->flags & ALPS_BUTTONPAD) {
> -			f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
> +			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);
> +			} else {
> +				f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
> +				f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
> +			}
>  			f->mt[0].y = SS4_BTL_MF_Y_V2(p, 0);
> -			f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
>  			f->mt[1].y = SS4_BTL_MF_Y_V2(p, 1);
>  		} else {
> -			f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
> +			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);
> +			} 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[0].y = SS4_STD_MF_Y_V2(p, 0);
> -			f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
>  			f->mt[1].y = SS4_STD_MF_Y_V2(p, 1);
>  		}
>  		f->pressure = SS4_MF_Z_V2(p, 0) ? 0x30 : 0;
> @@ -1234,16 +1244,27 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
>  
>  	case SS4_PACKET_ID_MULTI:
>  		if (priv->flags & ALPS_BUTTONPAD) {
> -			f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
> +			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);
> +			} else {
> +				f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
> +				f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
> +			}
> +
>  			f->mt[2].y = SS4_BTL_MF_Y_V2(p, 0);
> -			f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
>  			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 {
> -			f->mt[2].x = SS4_STD_MF_X_V2(p, 0);
> +			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);
> +			} 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].y = SS4_STD_MF_Y_V2(p, 0);
> -			f->mt[3].x = SS4_STD_MF_X_V2(p, 1);
>  			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;
> @@ -2536,8 +2557,8 @@ static int alps_set_defaults_ss4_v2(struct psmouse *psmouse,
>  
>  	memset(otp, 0, sizeof(otp));
>  
> -	if (alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]) ||
> -	    alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]))
> +	if (alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]) ||
> +	    alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]))
>  		return -1;
>  
>  	alps_update_device_area_ss4_v2(otp, priv);
> diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
> index 4334f2805d93..75542199edda 100644
> --- a/drivers/input/mouse/alps.h
> +++ b/drivers/input/mouse/alps.h
> @@ -99,6 +99,10 @@ enum SS4_PACKET_ID {
>  				 ((_b[1 + _i * 3]  << 5) & 0x1F00)	\
>  				)
>  
> +#define SS4_PLUS_STD_MF_X_V2(_b, _i) (((_b[0 + (_i) * 3] << 4) & 0x0070) | \
> +				 ((_b[1 + (_i) * 3]  << 4) & 0x0F80)	\
> +				)
> +
>  #define SS4_STD_MF_Y_V2(_b, _i)	(((_b[1 + (_i) * 3] << 3) & 0x0010) |	\
>  				 ((_b[2 + (_i) * 3] << 5) & 0x01E0) |	\
>  				 ((_b[2 + (_i) * 3] << 4) & 0x0E00)	\
> @@ -108,6 +112,10 @@ enum SS4_PACKET_ID {
>  				 ((_b[0 + (_i) * 3] >> 3) & 0x0010)	\
>  				)
>  
> +#define SS4_PLUS_BTL_MF_X_V2(_b, _i) (SS4_PLUS_STD_MF_X_V2(_b, _i) |	\
> +				 ((_b[0 + (_i) * 3] >> 4) & 0x0008)	\
> +				)
> +
>  #define SS4_BTL_MF_Y_V2(_b, _i)	(SS4_STD_MF_Y_V2(_b, _i) | \
>  				 ((_b[0 + (_i) * 3] >> 3) & 0x0008)	\
>  				)
> -- 
> 2.11.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix Alps Touchpad two finger scroll does not work on right side
  2017-07-21  0:27 [PATCH] Fix Alps Touchpad two finger scroll does not work on right side Masaki Ota
  2017-07-21  6:53 ` Takashi Iwai
@ 2017-07-22 18:58 ` Paul Donohue
  1 sibling, 0 replies; 5+ messages in thread
From: Paul Donohue @ 2017-07-22 18:58 UTC (permalink / raw)
  To: Masaki Ota
  Cc: dmitry.torokhov, benjamin.tissoires, pali.rohar, labbott,
	nick.m.fletcher, tiwai, linux-input, linux-kernel, masaki.ota

Tested-by: Paul Donohue <linux-kernel@PaulSD.com>

On Fri, Jul 21, 2017 at 09:27:30AM +0900, Masaki Ota wrote:
> From: Masaki Ota <masaki.ota@jp.alps.com>
> 
> Fixed the issue that two finger scroll does not work correctly
> on V8 protocol. The cause is that V8 protocol X-coordinate decode
> is wrong at SS4 PLUS device. I added SS4 PLUS X decode definition.
> 
> Signed-off-by: Masaki Ota <masaki.ota@jp.alps.com>
> Tested-by: Takashi Iwai <tiwai@suse.de>
> ---
>  drivers/input/mouse/alps.c | 41 +++++++++++++++++++++++++++++++----------
>  drivers/input/mouse/alps.h |  8 ++++++++
>  2 files changed, 39 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> index f210e19ddba6..2627c724bb7c 100644
> --- a/drivers/input/mouse/alps.c
> +++ b/drivers/input/mouse/alps.c
> @@ -1210,14 +1210,24 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
>  
>  	case SS4_PACKET_ID_TWO:
>  		if (priv->flags & ALPS_BUTTONPAD) {
> -			f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
> +			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);
> +			} else {
> +				f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
> +				f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
> +			}
>  			f->mt[0].y = SS4_BTL_MF_Y_V2(p, 0);
> -			f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
>  			f->mt[1].y = SS4_BTL_MF_Y_V2(p, 1);
>  		} else {
> -			f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
> +			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);
> +			} 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[0].y = SS4_STD_MF_Y_V2(p, 0);
> -			f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
>  			f->mt[1].y = SS4_STD_MF_Y_V2(p, 1);
>  		}
>  		f->pressure = SS4_MF_Z_V2(p, 0) ? 0x30 : 0;
> @@ -1234,16 +1244,27 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
>  
>  	case SS4_PACKET_ID_MULTI:
>  		if (priv->flags & ALPS_BUTTONPAD) {
> -			f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
> +			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);
> +			} else {
> +				f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
> +				f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
> +			}
> +
>  			f->mt[2].y = SS4_BTL_MF_Y_V2(p, 0);
> -			f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
>  			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 {
> -			f->mt[2].x = SS4_STD_MF_X_V2(p, 0);
> +			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);
> +			} 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].y = SS4_STD_MF_Y_V2(p, 0);
> -			f->mt[3].x = SS4_STD_MF_X_V2(p, 1);
>  			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;
> @@ -2536,8 +2557,8 @@ static int alps_set_defaults_ss4_v2(struct psmouse *psmouse,
>  
>  	memset(otp, 0, sizeof(otp));
>  
> -	if (alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]) ||
> -	    alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]))
> +	if (alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]) ||
> +	    alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]))
>  		return -1;
>  
>  	alps_update_device_area_ss4_v2(otp, priv);
> diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
> index 4334f2805d93..75542199edda 100644
> --- a/drivers/input/mouse/alps.h
> +++ b/drivers/input/mouse/alps.h
> @@ -99,6 +99,10 @@ enum SS4_PACKET_ID {
>  				 ((_b[1 + _i * 3]  << 5) & 0x1F00)	\
>  				)
>  
> +#define SS4_PLUS_STD_MF_X_V2(_b, _i) (((_b[0 + (_i) * 3] << 4) & 0x0070) | \
> +				 ((_b[1 + (_i) * 3]  << 4) & 0x0F80)	\
> +				)
> +
>  #define SS4_STD_MF_Y_V2(_b, _i)	(((_b[1 + (_i) * 3] << 3) & 0x0010) |	\
>  				 ((_b[2 + (_i) * 3] << 5) & 0x01E0) |	\
>  				 ((_b[2 + (_i) * 3] << 4) & 0x0E00)	\
> @@ -108,6 +112,10 @@ enum SS4_PACKET_ID {
>  				 ((_b[0 + (_i) * 3] >> 3) & 0x0010)	\
>  				)
>  
> +#define SS4_PLUS_BTL_MF_X_V2(_b, _i) (SS4_PLUS_STD_MF_X_V2(_b, _i) |	\
> +				 ((_b[0 + (_i) * 3] >> 4) & 0x0008)	\
> +				)
> +
>  #define SS4_BTL_MF_Y_V2(_b, _i)	(SS4_STD_MF_Y_V2(_b, _i) | \
>  				 ((_b[0 + (_i) * 3] >> 3) & 0x0008)	\
>  				)
> -- 
> 2.11.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix Alps Touchpad two finger scroll does not work on right side
  2017-07-21  6:53 ` Takashi Iwai
@ 2017-07-31 12:10   ` Takashi Iwai
  2017-08-15  6:20     ` Takashi Iwai
  0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2017-07-31 12:10 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: Masaki Ota, linux-kernel, benjamin.tissoires, pali.rohar,
	labbott, nick.m.fletcher, linux-input, linux-kernel, masaki.ota

On Fri, 21 Jul 2017 08:53:05 +0200,
Takashi Iwai wrote:
> 
> On Fri, 21 Jul 2017 02:27:30 +0200,
> Masaki Ota wrote:
> > 
> > From: Masaki Ota <masaki.ota@jp.alps.com>
> > 
> > Fixed the issue that two finger scroll does not work correctly
> > on V8 protocol. The cause is that V8 protocol X-coordinate decode
> > is wrong at SS4 PLUS device. I added SS4 PLUS X decode definition.
> > 
> > Signed-off-by: Masaki Ota <masaki.ota@jp.alps.com>
> > Tested-by: Takashi Iwai <tiwai@suse.de>
> 
> Please put Cc to stable, too, in addition to:
> 
> Fixes: e7348396c6d5 ("Input: ALPS - fix V8+ protocol handling (73 03 28)")
> 
> Mote to note: the problem itself was introduced even before the commit
> mentioned above.  But the two-finger scroll worked casually although
> it reported wrong values by some reason.  It got broken by the commit
> above because it changed x_max value, and now libinput correctly
> ignores the MT events at right-half of touchpad (the X coord is
> reported as doubled).
> 
> Also, one finger event is decoded differently, thus it didn't suffer
> from this problem.

Hi Dmitry, could you check this patch, in case you overlooked?


thanks,

Takashi


> 
> 
> thanks,
> 
> Takashi
> 
> > ---
> >  drivers/input/mouse/alps.c | 41 +++++++++++++++++++++++++++++++----------
> >  drivers/input/mouse/alps.h |  8 ++++++++
> >  2 files changed, 39 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> > index f210e19ddba6..2627c724bb7c 100644
> > --- a/drivers/input/mouse/alps.c
> > +++ b/drivers/input/mouse/alps.c
> > @@ -1210,14 +1210,24 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
> >  
> >  	case SS4_PACKET_ID_TWO:
> >  		if (priv->flags & ALPS_BUTTONPAD) {
> > -			f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
> > +			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);
> > +			} else {
> > +				f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
> > +				f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
> > +			}
> >  			f->mt[0].y = SS4_BTL_MF_Y_V2(p, 0);
> > -			f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
> >  			f->mt[1].y = SS4_BTL_MF_Y_V2(p, 1);
> >  		} else {
> > -			f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
> > +			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);
> > +			} 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[0].y = SS4_STD_MF_Y_V2(p, 0);
> > -			f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
> >  			f->mt[1].y = SS4_STD_MF_Y_V2(p, 1);
> >  		}
> >  		f->pressure = SS4_MF_Z_V2(p, 0) ? 0x30 : 0;
> > @@ -1234,16 +1244,27 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
> >  
> >  	case SS4_PACKET_ID_MULTI:
> >  		if (priv->flags & ALPS_BUTTONPAD) {
> > -			f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
> > +			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);
> > +			} else {
> > +				f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
> > +				f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
> > +			}
> > +
> >  			f->mt[2].y = SS4_BTL_MF_Y_V2(p, 0);
> > -			f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
> >  			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 {
> > -			f->mt[2].x = SS4_STD_MF_X_V2(p, 0);
> > +			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);
> > +			} 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].y = SS4_STD_MF_Y_V2(p, 0);
> > -			f->mt[3].x = SS4_STD_MF_X_V2(p, 1);
> >  			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;
> > @@ -2536,8 +2557,8 @@ static int alps_set_defaults_ss4_v2(struct psmouse *psmouse,
> >  
> >  	memset(otp, 0, sizeof(otp));
> >  
> > -	if (alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]) ||
> > -	    alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]))
> > +	if (alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]) ||
> > +	    alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]))
> >  		return -1;
> >  
> >  	alps_update_device_area_ss4_v2(otp, priv);
> > diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
> > index 4334f2805d93..75542199edda 100644
> > --- a/drivers/input/mouse/alps.h
> > +++ b/drivers/input/mouse/alps.h
> > @@ -99,6 +99,10 @@ enum SS4_PACKET_ID {
> >  				 ((_b[1 + _i * 3]  << 5) & 0x1F00)	\
> >  				)
> >  
> > +#define SS4_PLUS_STD_MF_X_V2(_b, _i) (((_b[0 + (_i) * 3] << 4) & 0x0070) | \
> > +				 ((_b[1 + (_i) * 3]  << 4) & 0x0F80)	\
> > +				)
> > +
> >  #define SS4_STD_MF_Y_V2(_b, _i)	(((_b[1 + (_i) * 3] << 3) & 0x0010) |	\
> >  				 ((_b[2 + (_i) * 3] << 5) & 0x01E0) |	\
> >  				 ((_b[2 + (_i) * 3] << 4) & 0x0E00)	\
> > @@ -108,6 +112,10 @@ enum SS4_PACKET_ID {
> >  				 ((_b[0 + (_i) * 3] >> 3) & 0x0010)	\
> >  				)
> >  
> > +#define SS4_PLUS_BTL_MF_X_V2(_b, _i) (SS4_PLUS_STD_MF_X_V2(_b, _i) |	\
> > +				 ((_b[0 + (_i) * 3] >> 4) & 0x0008)	\
> > +				)
> > +
> >  #define SS4_BTL_MF_Y_V2(_b, _i)	(SS4_STD_MF_Y_V2(_b, _i) | \
> >  				 ((_b[0 + (_i) * 3] >> 3) & 0x0008)	\
> >  				)
> > -- 
> > 2.11.0
> > 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix Alps Touchpad two finger scroll does not work on right side
  2017-07-31 12:10   ` Takashi Iwai
@ 2017-08-15  6:20     ` Takashi Iwai
  0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2017-08-15  6:20 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Masaki Ota, linux-kernel, benjamin.tissoires, pali.rohar,
	labbott, nick.m.fletcher, linux-input, linux-kernel, masaki.ota

On Mon, 31 Jul 2017 14:10:29 +0200,
Takashi Iwai wrote:
> 
> On Fri, 21 Jul 2017 08:53:05 +0200,
> Takashi Iwai wrote:
> > 
> > On Fri, 21 Jul 2017 02:27:30 +0200,
> > Masaki Ota wrote:
> > > 
> > > From: Masaki Ota <masaki.ota@jp.alps.com>
> > > 
> > > Fixed the issue that two finger scroll does not work correctly
> > > on V8 protocol. The cause is that V8 protocol X-coordinate decode
> > > is wrong at SS4 PLUS device. I added SS4 PLUS X decode definition.
> > > 
> > > Signed-off-by: Masaki Ota <masaki.ota@jp.alps.com>
> > > Tested-by: Takashi Iwai <tiwai@suse.de>
> > 
> > Please put Cc to stable, too, in addition to:
> > 
> > Fixes: e7348396c6d5 ("Input: ALPS - fix V8+ protocol handling (73 03 28)")
> > 
> > Mote to note: the problem itself was introduced even before the commit
> > mentioned above.  But the two-finger scroll worked casually although
> > it reported wrong values by some reason.  It got broken by the commit
> > above because it changed x_max value, and now libinput correctly
> > ignores the MT events at right-half of touchpad (the X coord is
> > reported as doubled).
> > 
> > Also, one finger event is decoded differently, thus it didn't suffer
> > from this problem.
> 
> Hi Dmitry, could you check this patch, in case you overlooked?

I hate a repeated ping, but since still not seeing any action after
four weeks...   What's about this patch?


thanks,

Takashi

> 
> 
> thanks,
> 
> Takashi
> 
> 
> > 
> > 
> > thanks,
> > 
> > Takashi
> > 
> > > ---
> > >  drivers/input/mouse/alps.c | 41 +++++++++++++++++++++++++++++++----------
> > >  drivers/input/mouse/alps.h |  8 ++++++++
> > >  2 files changed, 39 insertions(+), 10 deletions(-)
> > > 
> > > diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> > > index f210e19ddba6..2627c724bb7c 100644
> > > --- a/drivers/input/mouse/alps.c
> > > +++ b/drivers/input/mouse/alps.c
> > > @@ -1210,14 +1210,24 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
> > >  
> > >  	case SS4_PACKET_ID_TWO:
> > >  		if (priv->flags & ALPS_BUTTONPAD) {
> > > -			f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
> > > +			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);
> > > +			} else {
> > > +				f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
> > > +				f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
> > > +			}
> > >  			f->mt[0].y = SS4_BTL_MF_Y_V2(p, 0);
> > > -			f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
> > >  			f->mt[1].y = SS4_BTL_MF_Y_V2(p, 1);
> > >  		} else {
> > > -			f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
> > > +			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);
> > > +			} 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[0].y = SS4_STD_MF_Y_V2(p, 0);
> > > -			f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
> > >  			f->mt[1].y = SS4_STD_MF_Y_V2(p, 1);
> > >  		}
> > >  		f->pressure = SS4_MF_Z_V2(p, 0) ? 0x30 : 0;
> > > @@ -1234,16 +1244,27 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
> > >  
> > >  	case SS4_PACKET_ID_MULTI:
> > >  		if (priv->flags & ALPS_BUTTONPAD) {
> > > -			f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
> > > +			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);
> > > +			} else {
> > > +				f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
> > > +				f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
> > > +			}
> > > +
> > >  			f->mt[2].y = SS4_BTL_MF_Y_V2(p, 0);
> > > -			f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
> > >  			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 {
> > > -			f->mt[2].x = SS4_STD_MF_X_V2(p, 0);
> > > +			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);
> > > +			} 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].y = SS4_STD_MF_Y_V2(p, 0);
> > > -			f->mt[3].x = SS4_STD_MF_X_V2(p, 1);
> > >  			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;
> > > @@ -2536,8 +2557,8 @@ static int alps_set_defaults_ss4_v2(struct psmouse *psmouse,
> > >  
> > >  	memset(otp, 0, sizeof(otp));
> > >  
> > > -	if (alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]) ||
> > > -	    alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]))
> > > +	if (alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]) ||
> > > +	    alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]))
> > >  		return -1;
> > >  
> > >  	alps_update_device_area_ss4_v2(otp, priv);
> > > diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
> > > index 4334f2805d93..75542199edda 100644
> > > --- a/drivers/input/mouse/alps.h
> > > +++ b/drivers/input/mouse/alps.h
> > > @@ -99,6 +99,10 @@ enum SS4_PACKET_ID {
> > >  				 ((_b[1 + _i * 3]  << 5) & 0x1F00)	\
> > >  				)
> > >  
> > > +#define SS4_PLUS_STD_MF_X_V2(_b, _i) (((_b[0 + (_i) * 3] << 4) & 0x0070) | \
> > > +				 ((_b[1 + (_i) * 3]  << 4) & 0x0F80)	\
> > > +				)
> > > +
> > >  #define SS4_STD_MF_Y_V2(_b, _i)	(((_b[1 + (_i) * 3] << 3) & 0x0010) |	\
> > >  				 ((_b[2 + (_i) * 3] << 5) & 0x01E0) |	\
> > >  				 ((_b[2 + (_i) * 3] << 4) & 0x0E00)	\
> > > @@ -108,6 +112,10 @@ enum SS4_PACKET_ID {
> > >  				 ((_b[0 + (_i) * 3] >> 3) & 0x0010)	\
> > >  				)
> > >  
> > > +#define SS4_PLUS_BTL_MF_X_V2(_b, _i) (SS4_PLUS_STD_MF_X_V2(_b, _i) |	\
> > > +				 ((_b[0 + (_i) * 3] >> 4) & 0x0008)	\
> > > +				)
> > > +
> > >  #define SS4_BTL_MF_Y_V2(_b, _i)	(SS4_STD_MF_Y_V2(_b, _i) | \
> > >  				 ((_b[0 + (_i) * 3] >> 3) & 0x0008)	\
> > >  				)
> > > -- 
> > > 2.11.0
> > > 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-15  6:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-21  0:27 [PATCH] Fix Alps Touchpad two finger scroll does not work on right side Masaki Ota
2017-07-21  6:53 ` Takashi Iwai
2017-07-31 12:10   ` Takashi Iwai
2017-08-15  6:20     ` Takashi Iwai
2017-07-22 18:58 ` Paul Donohue

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).