linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: alps - Report pressure of v3 and v7 trackstick
@ 2018-03-21 20:07 Pali Rohár
  2018-03-26 22:37 ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Pali Rohár @ 2018-03-21 20:07 UTC (permalink / raw)
  To: Dmitry Torokhov, Masaki Ota; +Cc: linux-input, linux-kernel

ALPS v3 and v7 packet formats reports trackstick pressure. This information
is already parsed in unused "z" variable.

ALPS SS4 S2 devices already reports trackstick pressure as ABS_PRESSURE
attribute, therefore reports pressure in the same way also for v3 and v7.

This patch also updates parsing v3 pressure information, it is also stored
in 7 bits.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
 drivers/input/mouse/alps.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 010c1bcdb06d..0a9e6a3a2f9f 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -139,11 +139,11 @@ static const struct alps_model_info alps_model_data[] = {
 };
 
 static const struct alps_protocol_info alps_v3_protocol_data = {
-	ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT
+	ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
 };
 
 static const struct alps_protocol_info alps_v3_rushmore_data = {
-	ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT
+	ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
 };
 
 static const struct alps_protocol_info alps_v4_protocol_data = {
@@ -155,7 +155,7 @@ static const struct alps_protocol_info alps_v5_protocol_data = {
 };
 
 static const struct alps_protocol_info alps_v7_protocol_data = {
-	ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT
+	ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
 };
 
 static const struct alps_protocol_info alps_v8_protocol_data = {
@@ -583,7 +583,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
 
 	x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f));
 	y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f));
-	z = (packet[4] & 0x7c) >> 2;
+	z = packet[4] & 0x7c;
 
 	/*
 	 * The x and y values tend to be quite large, and when used
@@ -595,6 +595,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
 
 	input_report_rel(dev, REL_X, x);
 	input_report_rel(dev, REL_Y, -y);
+	input_report_abs(dev, ABS_PRESSURE, z);
 
 	/*
 	 * Most ALPS models report the trackstick buttons in the touchpad
@@ -1118,6 +1119,7 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
 
 	input_report_rel(dev2, REL_X, (char)x);
 	input_report_rel(dev2, REL_Y, -((char)y));
+	input_report_abs(dev2, ABS_PRESSURE, z);
 
 	input_report_key(dev2, BTN_LEFT, left);
 	input_report_key(dev2, BTN_RIGHT, right);
-- 
2.11.0

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

* Re: [PATCH] Input: alps - Report pressure of v3 and v7 trackstick
  2018-03-21 20:07 [PATCH] Input: alps - Report pressure of v3 and v7 trackstick Pali Rohár
@ 2018-03-26 22:37 ` Dmitry Torokhov
  2018-03-26 22:38   ` Pali Rohár
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2018-03-26 22:37 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Masaki Ota, linux-input, linux-kernel

Hi Pali,

On Wed, Mar 21, 2018 at 09:07:36PM +0100, Pali Rohár wrote:
> ALPS v3 and v7 packet formats reports trackstick pressure. This information
> is already parsed in unused "z" variable.
> 
> ALPS SS4 S2 devices already reports trackstick pressure as ABS_PRESSURE
> attribute, therefore reports pressure in the same way also for v3 and v7.
> 
> This patch also updates parsing v3 pressure information, it is also stored
> in 7 bits.
> 
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> ---
>  drivers/input/mouse/alps.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> index 010c1bcdb06d..0a9e6a3a2f9f 100644
> --- a/drivers/input/mouse/alps.c
> +++ b/drivers/input/mouse/alps.c
> @@ -139,11 +139,11 @@ static const struct alps_model_info alps_model_data[] = {
>  };
>  
>  static const struct alps_protocol_info alps_v3_protocol_data = {
> -	ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT
> +	ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE

It seems that with these changes we no longer have trackpoints that do
not report pressure in ALPS. Should we get rid of
ALPS_DUALPOINT_WITH_PRESSURE and clean up the code a bit?

Thanks.

>  };
>  
>  static const struct alps_protocol_info alps_v3_rushmore_data = {
> -	ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT
> +	ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
>  };
>  
>  static const struct alps_protocol_info alps_v4_protocol_data = {
> @@ -155,7 +155,7 @@ static const struct alps_protocol_info alps_v5_protocol_data = {
>  };
>  
>  static const struct alps_protocol_info alps_v7_protocol_data = {
> -	ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT
> +	ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
>  };
>  
>  static const struct alps_protocol_info alps_v8_protocol_data = {
> @@ -583,7 +583,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
>  
>  	x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f));
>  	y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f));
> -	z = (packet[4] & 0x7c) >> 2;
> +	z = packet[4] & 0x7c;
>  
>  	/*
>  	 * The x and y values tend to be quite large, and when used
> @@ -595,6 +595,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
>  
>  	input_report_rel(dev, REL_X, x);
>  	input_report_rel(dev, REL_Y, -y);
> +	input_report_abs(dev, ABS_PRESSURE, z);
>  
>  	/*
>  	 * Most ALPS models report the trackstick buttons in the touchpad
> @@ -1118,6 +1119,7 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
>  
>  	input_report_rel(dev2, REL_X, (char)x);
>  	input_report_rel(dev2, REL_Y, -((char)y));
> +	input_report_abs(dev2, ABS_PRESSURE, z);
>  
>  	input_report_key(dev2, BTN_LEFT, left);
>  	input_report_key(dev2, BTN_RIGHT, right);
> -- 
> 2.11.0
> 

-- 
Dmitry

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

* Re: [PATCH] Input: alps - Report pressure of v3 and v7 trackstick
  2018-03-26 22:37 ` Dmitry Torokhov
@ 2018-03-26 22:38   ` Pali Rohár
  2018-03-26 22:55     ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Pali Rohár @ 2018-03-26 22:38 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Masaki Ota, linux-input, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3323 bytes --]

On Monday 26 March 2018 15:37:32 Dmitry Torokhov wrote:
> Hi Pali,
> 
> On Wed, Mar 21, 2018 at 09:07:36PM +0100, Pali Rohár wrote:
> > ALPS v3 and v7 packet formats reports trackstick pressure. This information
> > is already parsed in unused "z" variable.
> > 
> > ALPS SS4 S2 devices already reports trackstick pressure as ABS_PRESSURE
> > attribute, therefore reports pressure in the same way also for v3 and v7.
> > 
> > This patch also updates parsing v3 pressure information, it is also stored
> > in 7 bits.
> > 
> > Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> > ---
> >  drivers/input/mouse/alps.c | 10 ++++++----
> >  1 file changed, 6 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> > index 010c1bcdb06d..0a9e6a3a2f9f 100644
> > --- a/drivers/input/mouse/alps.c
> > +++ b/drivers/input/mouse/alps.c
> > @@ -139,11 +139,11 @@ static const struct alps_model_info alps_model_data[] = {
> >  };
> >  
> >  static const struct alps_protocol_info alps_v3_protocol_data = {
> > -	ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT
> > +	ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> 
> It seems that with these changes we no longer have trackpoints that do
> not report pressure in ALPS. Should we get rid of

Nope, we still have. See them in the alps_model_data table.

> ALPS_DUALPOINT_WITH_PRESSURE and clean up the code a bit?
> 
> Thanks.
> 
> >  };
> >  
> >  static const struct alps_protocol_info alps_v3_rushmore_data = {
> > -	ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT
> > +	ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> >  };
> >  
> >  static const struct alps_protocol_info alps_v4_protocol_data = {
> > @@ -155,7 +155,7 @@ static const struct alps_protocol_info alps_v5_protocol_data = {
> >  };
> >  
> >  static const struct alps_protocol_info alps_v7_protocol_data = {
> > -	ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT
> > +	ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> >  };
> >  
> >  static const struct alps_protocol_info alps_v8_protocol_data = {
> > @@ -583,7 +583,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
> >  
> >  	x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f));
> >  	y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f));
> > -	z = (packet[4] & 0x7c) >> 2;
> > +	z = packet[4] & 0x7c;
> >  
> >  	/*
> >  	 * The x and y values tend to be quite large, and when used
> > @@ -595,6 +595,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
> >  
> >  	input_report_rel(dev, REL_X, x);
> >  	input_report_rel(dev, REL_Y, -y);
> > +	input_report_abs(dev, ABS_PRESSURE, z);
> >  
> >  	/*
> >  	 * Most ALPS models report the trackstick buttons in the touchpad
> > @@ -1118,6 +1119,7 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
> >  
> >  	input_report_rel(dev2, REL_X, (char)x);
> >  	input_report_rel(dev2, REL_Y, -((char)y));
> > +	input_report_abs(dev2, ABS_PRESSURE, z);
> >  
> >  	input_report_key(dev2, BTN_LEFT, left);
> >  	input_report_key(dev2, BTN_RIGHT, right);
> > -- 
> > 2.11.0
> > 
> 

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH] Input: alps - Report pressure of v3 and v7 trackstick
  2018-03-26 22:38   ` Pali Rohár
@ 2018-03-26 22:55     ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2018-03-26 22:55 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Masaki Ota, linux-input, linux-kernel

On Tue, Mar 27, 2018 at 12:38:56AM +0200, Pali Rohár wrote:
> On Monday 26 March 2018 15:37:32 Dmitry Torokhov wrote:
> > Hi Pali,
> > 
> > On Wed, Mar 21, 2018 at 09:07:36PM +0100, Pali Rohár wrote:
> > > ALPS v3 and v7 packet formats reports trackstick pressure. This information
> > > is already parsed in unused "z" variable.
> > > 
> > > ALPS SS4 S2 devices already reports trackstick pressure as ABS_PRESSURE
> > > attribute, therefore reports pressure in the same way also for v3 and v7.
> > > 
> > > This patch also updates parsing v3 pressure information, it is also stored
> > > in 7 bits.
> > > 
> > > Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> > > ---
> > >  drivers/input/mouse/alps.c | 10 ++++++----
> > >  1 file changed, 6 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> > > index 010c1bcdb06d..0a9e6a3a2f9f 100644
> > > --- a/drivers/input/mouse/alps.c
> > > +++ b/drivers/input/mouse/alps.c
> > > @@ -139,11 +139,11 @@ static const struct alps_model_info alps_model_data[] = {
> > >  };
> > >  
> > >  static const struct alps_protocol_info alps_v3_protocol_data = {
> > > -	ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT
> > > +	ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> > 
> > It seems that with these changes we no longer have trackpoints that do
> > not report pressure in ALPS. Should we get rid of
> 
> Nope, we still have. See them in the alps_model_data table.

Ah, I see now, OK. Applied, thank you.

> 
> > ALPS_DUALPOINT_WITH_PRESSURE and clean up the code a bit?
> > 
> > Thanks.
> > 
> > >  };
> > >  
> > >  static const struct alps_protocol_info alps_v3_rushmore_data = {
> > > -	ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT
> > > +	ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> > >  };
> > >  
> > >  static const struct alps_protocol_info alps_v4_protocol_data = {
> > > @@ -155,7 +155,7 @@ static const struct alps_protocol_info alps_v5_protocol_data = {
> > >  };
> > >  
> > >  static const struct alps_protocol_info alps_v7_protocol_data = {
> > > -	ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT
> > > +	ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
> > >  };
> > >  
> > >  static const struct alps_protocol_info alps_v8_protocol_data = {
> > > @@ -583,7 +583,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
> > >  
> > >  	x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f));
> > >  	y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f));
> > > -	z = (packet[4] & 0x7c) >> 2;
> > > +	z = packet[4] & 0x7c;
> > >  
> > >  	/*
> > >  	 * The x and y values tend to be quite large, and when used
> > > @@ -595,6 +595,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
> > >  
> > >  	input_report_rel(dev, REL_X, x);
> > >  	input_report_rel(dev, REL_Y, -y);
> > > +	input_report_abs(dev, ABS_PRESSURE, z);
> > >  
> > >  	/*
> > >  	 * Most ALPS models report the trackstick buttons in the touchpad
> > > @@ -1118,6 +1119,7 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
> > >  
> > >  	input_report_rel(dev2, REL_X, (char)x);
> > >  	input_report_rel(dev2, REL_Y, -((char)y));
> > > +	input_report_abs(dev2, ABS_PRESSURE, z);
> > >  
> > >  	input_report_key(dev2, BTN_LEFT, left);
> > >  	input_report_key(dev2, BTN_RIGHT, right);
> > > -- 
> > > 2.11.0
> > > 
> > 
> 
> -- 
> Pali Rohár
> pali.rohar@gmail.com



-- 
Dmitry

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

end of thread, other threads:[~2018-03-26 22:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-21 20:07 [PATCH] Input: alps - Report pressure of v3 and v7 trackstick Pali Rohár
2018-03-26 22:37 ` Dmitry Torokhov
2018-03-26 22:38   ` Pali Rohár
2018-03-26 22:55     ` Dmitry Torokhov

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