linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] elantech: fix for newer hardware versions (v7)
@ 2013-07-05 22:18 Matteo Delfino
  2013-07-06  4:30 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Matteo Delfino @ 2013-07-05 22:18 UTC (permalink / raw)
  To: linux-input; +Cc: Alessandro Rubini, Dmitry Torokhov

* Fix version recognition in elantech_set_properties

  The new hardware reports itself as v7 but the packets'
  structure is unaltered.

* Fix packet type recognition in elantech_packet_check_v4

  The bitmask used for v6 is too wide, only the last three bits of
  the third byte in a packet (packet[3] & 0x03) are actually used to
  distinguish between packet types.
  Starting from v7, additional information (to be interpreted) is
  stored in the remaining bits (packets[3] & 0x1c).
  In addition, the value stored in (packet[0] & 0x0c) is no longer
  a constant but contains additional information yet to be deciphered.
  This change should be backwards compatible with v6 hardware.

Additional-author: Giovanni Frigione <gio.frigione@gmail.com>
Signed-off-by: Matteo Delfino <kendatsuba@gmail.com>
---
 drivers/input/mouse/elantech.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index e2a9867..4d54773 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -677,17 +677,15 @@ static int elantech_packet_check_v3(struct psmouse
*psmouse)
 static int elantech_packet_check_v4(struct psmouse *psmouse)
 {
 	unsigned char *packet = psmouse->packet;
+	unsigned char packet_type = packet[3] & 0x03;

-	if ((packet[0] & 0x0c) == 0x04 &&
-	    (packet[3] & 0x1f) == 0x11)
+	if (packet_type == 0x01)
 		return PACKET_V4_HEAD;

-	if ((packet[0] & 0x0c) == 0x04 &&
-	    (packet[3] & 0x1f) == 0x12)
+	if (packet_type == 0x02)
 		return PACKET_V4_MOTION;

-	if ((packet[0] & 0x0c) == 0x04 &&
-	    (packet[3] & 0x1f) == 0x10)
+	if (packet_type == 0x00)
 		return PACKET_V4_STATUS;

 	return PACKET_UNKNOWN;
@@ -1226,6 +1224,7 @@ static int elantech_set_properties(struct
elantech_data *etd)
 			etd->hw_version = 3;
 			break;
 		case 6:
+		case 7:
 			etd->hw_version = 4;
 			break;
 		default:
-- 
1.7.10.4

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

* Re: [PATCH] elantech: fix for newer hardware versions (v7)
  2013-07-05 22:18 [PATCH] elantech: fix for newer hardware versions (v7) Matteo Delfino
@ 2013-07-06  4:30 ` Dmitry Torokhov
  2013-07-06  7:20   ` Matteo Delfino
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2013-07-06  4:30 UTC (permalink / raw)
  To: Matteo Delfino; +Cc: linux-input, Alessandro Rubini

Hi Matteo,

On Sat, Jul 06, 2013 at 12:18:32AM +0200, Matteo Delfino wrote:
> * Fix version recognition in elantech_set_properties
> 
>   The new hardware reports itself as v7 but the packets'
>   structure is unaltered.
> 
> * Fix packet type recognition in elantech_packet_check_v4
> 
>   The bitmask used for v6 is too wide, only the last three bits of
>   the third byte in a packet (packet[3] & 0x03) are actually used to
>   distinguish between packet types.
>   Starting from v7, additional information (to be interpreted) is
>   stored in the remaining bits (packets[3] & 0x1c).
>   In addition, the value stored in (packet[0] & 0x0c) is no longer
>   a constant but contains additional information yet to be deciphered.
>   This change should be backwards compatible with v6 hardware.
> 
> Additional-author: Giovanni Frigione <gio.frigione@gmail.com>
> Signed-off-by: Matteo Delfino <kendatsuba@gmail.com>

Thank you for the patch, unfortunately your mailer line-wrapped it and
it can't be applied. Could you please resend it using MUA that does not
perform line-wrapping?

Also, now that you only use (packet[3] & 0x03) to determine packet type,
could you turn series of 'if' statements in elantech_packet_check_v4()
into a 'switch'?

Thanks!

-- 
Dmitry

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

* Re: [PATCH] elantech: fix for newer hardware versions (v7)
  2013-07-06  4:30 ` Dmitry Torokhov
@ 2013-07-06  7:20   ` Matteo Delfino
  0 siblings, 0 replies; 3+ messages in thread
From: Matteo Delfino @ 2013-07-06  7:20 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, Alessandro Rubini

Hi Dmitry,

On 07/06/2013 06:30 AM, Dmitry Torokhov wrote:
> Thank you for the patch, unfortunately your mailer line-wrapped it and
> it can't be applied. Could you please resend it using MUA that does not
> perform line-wrapping?
>

Of course, sorry about that.

> Also, now that you only use (packet[3] & 0x03) to determine packet type,
> could you turn series of 'if' statements in elantech_packet_check_v4()
> into a 'switch'?

Sure, i will.

Best regards,
Matteo


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

end of thread, other threads:[~2013-07-06  7:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-05 22:18 [PATCH] elantech: fix for newer hardware versions (v7) Matteo Delfino
2013-07-06  4:30 ` Dmitry Torokhov
2013-07-06  7:20   ` Matteo Delfino

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