← Back to team overview

multi-touch-dev team mailing list archive

Re: n-trig updates

 

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/09/10 13:38, Andy Whitcroft wrote:
> On Wed, Apr 07, 2010 at 09:18:22PM +0200, Stéphane Chatty wrote:
>>
>> Le 7 avr. 10 à 19:43, multi-touch-dev-bounces
>> +chatty=enac.fr@xxxxxxxxxxxxxxxxxxx a écrit :
>>
>>>
>>> On Apr 1, 2010, at 3:48 PM, Stéphane Chatty wrote:
>>>
>>>>
>>>> Le 1 avr. 10 à 00:09, Rafi wrote:
>>>>
>>>>> Just an FYI, Stéphane and I have been seeing an odd behavior
>>>>> where the n-trig
>>>>> hardware stops sending events.  The devices look like they
>>>>> should be functioning
>>>>> normally and just show no sign of activity (no events coming
>>>>> down from the usb
>>>>> device).
>>>>
>>>> I think I have a working solution. It has to do with a message
>>>> starting with 0x0a that I had observed the PC sending to the
>>>> device without being able to reproduce it correctly. Considering
>>>> it as a feature report and sending it as such with
>>>> usbhid_submit_report seems to do the trick.
>>>>
>>>> I'll make a few more tests and send a patch to Rafi for further
>>>> testing.
>>>
>>> Any progress on this?
>>
>> Yes, the patch was submitted and accepted this morning. It has no
>> ill effect on Rafi's version of the firmware, and for me it turns
>> the device from useless to fully functional.
> 
> Could someone point me to the patch in this case.  I am going to be
> closing the kernel very early next week and if we want this in as well
> I will need to have the patch in my hand as soon as possible so I can
> test it and get it acked and in.
> 
> Thanks!
> 
> -apw

You can get Stephane's patch at

http://git.kernel.org/?p=linux/kernel/git/jikos/hid.git;a=history;f=drivers/hid/hid-ntrig.c;h=a418f9e19ce75bd06759b7f0ad5262ce160175d2;hb=refs/heads/for-next

Also attaching his submission email.  It looks like Jiri added a comment and
applied it after the addition of slab.h (that was a broad commit that hit files
all over the kernel recently).  Up to you if you want those tweaks, I don't know
what effect the slab include will have with a 2.6.32 kernel, and the comment is
definitely harmless.

The other two files I'm attaching are patches that I will send upstream later
today.  I discovered problems with legacy firmwares when testing Stephane's
patch (touch broken for evdev for 2.59, and completely broken for XP st
firmwares).  These clear that up, and a tiny bit of general house keeping.

Rafi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAku/lAQACgkQwuRiAT9o60950wCeNzaTZkqoeJ9BGzSEpuwZe9xC
HZIAoNPE6UJ0oLDjfDISbCin+H/wvQDb
=VGCc
-----END PGP SIGNATURE-----
--- Begin Message ---
Signed-off-by: Stephane Chatty <chatty@xxxxxxx>
Tested-by: Rafi Rubin <rafi@xxxxxxxxxxxxxx>

diff -rupN a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
--- a/drivers/hid/hid-ntrig.c	2010-03-20 02:17:57.000000000 +0100
+++ b/drivers/hid/hid-ntrig.c	2010-04-02 01:06:11.000000000 +0200
@@ -1,8 +1,8 @@
 /*
  *  HID driver for N-Trig touchscreens
  *
- *  Copyright (c) 2008 Rafi Rubin
- *  Copyright (c) 2009 Stephane Chatty
+ *  Copyright (c) 2008-2010 Rafi Rubin
+ *  Copyright (c) 2009-2010 Stephane Chatty
  *
  */
 
@@ -16,6 +16,8 @@
 #include <linux/device.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/usb.h>
+#include "usbhid/usbhid.h"
 
 #include "hid-ids.h"
 
@@ -285,6 +287,7 @@ static int ntrig_probe(struct hid_device
 	struct ntrig_data *nd;
 	struct hid_input *hidinput;
 	struct input_dev *input;
+	struct hid_report *report;
 
 	if (id->driver_data)
 		hdev->quirks |= HID_QUIRK_MULTI_INPUT;
@@ -348,6 +351,11 @@ static int ntrig_probe(struct hid_device
 		}
 	}
 
+	report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0x0a];
+	if (report)
+		usbhid_submit_report(hdev, report, USB_DIR_OUT);
+
+
 	return 0;
 err_free:
 	kfree(nd);


--- End Message ---
>From 550440d0acc09bc8b60bc1d66ec218268068298a Mon Sep 17 00:00:00 2001
From: Rafi Rubin <rafi@xxxxxxxxxxxxxx>
Date: Fri, 9 Apr 2010 16:36:01 -0400
Subject: [PATCH 1/2] Emit TOUCH with DOUBLETAP for single touch

Signed-off-by: Rafi Rubin <rafi@xxxxxxxxxxxxxx>
---
 drivers/hid/hid-ntrig.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index f93c551..7a21e92 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -172,6 +172,8 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
 			if (!nd->reading_mt) {
 				input_report_key(input, BTN_TOOL_DOUBLETAP,
 						 (nd->confidence != 0));
+				input_report_key(input, BTN_TOUCH,
+						 (nd->confidence != 0));
 				input_event(input, EV_ABS, ABS_X, nd->x);
 				input_event(input, EV_ABS, ABS_Y, nd->y);
 			}
-- 
1.7.0.4

>From 539f4f3ca5e4b0201df61286e55350730147017c Mon Sep 17 00:00:00 2001
From: Rafi Rubin <rafi@xxxxxxxxxxxxxx>
Date: Fri, 9 Apr 2010 16:37:22 -0400
Subject: [PATCH 2/2] Use TIPSWITCH for TOUCH

TipSwitch is a better match for touch.  Confidence and InRange work
for more current firmwares, but with some older versions only
TipSwitch is appropriate.

Signed-off-by: Rafi Rubin <rafi@xxxxxxxxxxxxxx>
---
 drivers/hid/hid-ntrig.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index 7a21e92..cf5c4a4 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -30,10 +30,12 @@ struct ntrig_data {
 	/* Incoming raw values for a single contact */
 	__u16 x, y, w, h;
 	__u16 id;
-	__u8 confidence;
+
+	bool tipswitch;
+	bool confidence;
+	bool first_contact_touch;
 
 	bool reading_mt;
-	__u8 first_contact_confidence;
 
 	__u8 mt_footer[4];
 	__u8 mt_foot_count;
@@ -140,9 +142,10 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
 		case 0xff000001:
 			/* Tag indicating the start of a multitouch group */
 			nd->reading_mt = 1;
-			nd->first_contact_confidence = 0;
+			nd->first_contact_touch = 0;
 			break;
 		case HID_DG_TIPSWITCH:
+			nd->tipswitch = value;
 			/* Prevent emission of touch until validated */
 			return 1;
 		case HID_DG_CONFIDENCE:
@@ -170,10 +173,15 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
 			 * to emit a normal (X, Y) position
 			 */
 			if (!nd->reading_mt) {
-				input_report_key(input, BTN_TOOL_DOUBLETAP,
-						 (nd->confidence != 0));
+				/*
+				 * TIPSWITCH indicates the presence of a
+				 * finger.  DOUBLETAP is emitted are both
+				 * emitted to support legacy drivers.
+				 */
 				input_report_key(input, BTN_TOUCH,
-						 (nd->confidence != 0));
+						 nd->tipswitch);
+				input_report_key(input, BTN_TOOL_DOUBLETAP,
+						 nd->tipswitch);
 				input_event(input, EV_ABS, ABS_X, nd->x);
 				input_event(input, EV_ABS, ABS_Y, nd->y);
 			}
@@ -212,7 +220,8 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
 
 			/* emit a normal (X, Y) for the first point only */
 			if (nd->id == 0) {
-				nd->first_contact_confidence = nd->confidence;
+				nd->first_contact_touch = nd->confidence &&
+					nd->tipswitch;
 				input_event(input, EV_ABS, ABS_X, nd->x);
 				input_event(input, EV_ABS, ABS_Y, nd->y);
 			}
@@ -242,7 +251,7 @@ static int ntrig_event (struct hid_device *hid, struct hid_field *field,
 
 			nd->reading_mt = 0;
 
-			if (nd->first_contact_confidence) {
+			if (nd->first_contact_touch) {
 				switch (value) {
 				case 0:	/* for single touch devices */
 				case 1:
-- 
1.7.0.4


Follow ups

References