linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] input: wacom - add 0xE5 (MT device) support
  2012-02-01  4:03 [PATCH 1/2] input : wacom - retrieve maximum number of touch points chris
@ 2012-02-01  4:03 ` chris
  0 siblings, 0 replies; 15+ messages in thread
From: chris @ 2012-02-01  4:03 UTC (permalink / raw)
  To: dmitry.torokhov, linux-input; +Cc: Ping Cheng, Ping Cheng

From: Ping Cheng <pinglinux@gmail.com>

And getting rid of duplicate code since X/Y will always be present.

Tested-by: Chris Bagwell <chris@cnpbagwell.com>
Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>
Signed-off-by: Ping Cheng <pingc@wacom.com>
---
 drivers/input/tablet/wacom_sys.c |   57 ++++++++++++------------
 drivers/input/tablet/wacom_wac.c |   88 ++++++++++++++++++++++++++++++++++++-
 drivers/input/tablet/wacom_wac.h |    8 +++
 3 files changed, 122 insertions(+), 31 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 5004a75..dc00386 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -306,6 +306,10 @@ static int wacom_parse_hid(struct usb_interface *intf,
 							/* need to reset back */
 							features->pktlen = WACOM_PKGLEN_TPC2FG;
 						}
+
+						if (features->type == MTSCREEN)
+							features->pktlen = WACOM_PKGLEN_MTOUCH;
+
 						if (features->type == BAMBOO_PT) {
 							/* need to reset back */
 							features->pktlen = WACOM_PKGLEN_BBTOUCH;
@@ -338,18 +342,15 @@ static int wacom_parse_hid(struct usb_interface *intf,
 			case HID_USAGE_Y:
 				if (usage == WCM_DESKTOP) {
 					if (finger) {
-						features->device_type = BTN_TOOL_FINGER;
-						if (features->type == TABLETPC2FG) {
-							/* need to reset back */
-							features->pktlen = WACOM_PKGLEN_TPC2FG;
+						int type = features->type;
+
+						if (type == TABLETPC2FG || type == MTSCREEN) {
 							features->y_max =
 								get_unaligned_le16(&report[i + 3]);
 							features->y_phy =
 								get_unaligned_le16(&report[i + 6]);
 							i += 7;
-						} else if (features->type == BAMBOO_PT) {
-							/* need to reset back */
-							features->pktlen = WACOM_PKGLEN_BBTOUCH;
+						} else if (type == BAMBOO_PT) {
 							features->y_phy =
 								get_unaligned_le16(&report[i + 3]);
 							features->y_max =
@@ -363,10 +364,6 @@ static int wacom_parse_hid(struct usb_interface *intf,
 							i += 4;
 						}
 					} else if (pen) {
-						/* penabled only accepts exact bytes of data */
-						if (features->type == TABLETPC2FG)
-							features->pktlen = WACOM_PKGLEN_GRAPHIRE;
-						features->device_type = BTN_TOOL_PEN;
 						features->y_max =
 							get_unaligned_le16(&report[i + 3]);
 						i += 4;
@@ -429,24 +426,28 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
 	if (!rep_data)
 		return error;
 
-	/* ask to report tablet data if it is MT Tablet PC or
-	 * not a Tablet PC */
-	if (features->type == TABLETPC2FG) {
-		do {
-			rep_data[0] = 3;
-			rep_data[1] = 4;
-			rep_data[2] = 0;
-			rep_data[3] = 0;
-			report_id = 3;
-			error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
+	/* ask to report Wacom data */
+	if (features->device_type == BTN_TOOL_FINGER) {
+		/* if it is an MT Tablet PC touch */
+		if ((features->type == TABLETPC2FG) ||
+		    (features->type == MTSCREEN)) {
+			do {
+				rep_data[0] = 3;
+				rep_data[1] = 4;
+				rep_data[2] = 0;
+				rep_data[3] = 0;
+				report_id = 3;
+				error = wacom_set_report(intf,
+						 WAC_HID_FEATURE_REPORT,
 						 report_id, rep_data, 4, 1);
-			if (error >= 0)
-				error = wacom_get_report(intf,
+				if (error >= 0)
+					error = wacom_get_report(intf,
 						WAC_HID_FEATURE_REPORT,
 						report_id, rep_data, 4, 1);
-		} while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES);
-	} else if (features->type != TABLETPC &&
-		   features->device_type == BTN_TOOL_PEN) {
+			} while ((error < 0 || rep_data[1] != 4) &&
+				 limit++ < WAC_MSG_RETRIES);
+		}
+	} else if (features->type != TABLETPC) { /* or not a Tablet PC pen */
 		do {
 			rep_data[0] = 2;
 			rep_data[1] = 2;
@@ -478,9 +479,9 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
 	features->pressure_fuzz = 0;
 	features->distance_fuzz = 0;
 
-	/* only Tablet PCs and Bamboo P&T need to retrieve the info */
+	/* only devices that support touch need to retrieve the info */
 	if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) &&
-	    (features->type != BAMBOO_PT))
+	    (features->type != BAMBOO_PT) && (features->type != MTSCREEN))
 		goto out;
 
 	if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index c56d577..a7d37de 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -729,6 +729,75 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
 	return 1;
 }
 
+static int wacom_mt_touch(struct wacom_wac *wacom)
+{
+	struct wacom_features *features = &wacom->features;
+	struct input_dev *input = wacom->input;
+	char *data = wacom->data;
+	struct input_mt_slot *mt;
+	int i, id = -1, j = 0, k = 4;
+	int x = 0, y = 0;
+	int current_num_contacts = data[2];
+	int contacts_to_send = 0;
+	bool touch = false;
+
+	/* reset the counter by the first packet since only the first
+	 * packet in series will have non-zero current_num_contacts
+	 */
+	if (current_num_contacts) {
+		features->num_contacts = current_num_contacts;
+		features->num_contacts_left = current_num_contacts;
+	}
+
+	/* There are at most 5 contacts per packet */
+	contacts_to_send = min(5, (int)features->num_contacts_left);
+
+	for (i = 0; i < contacts_to_send; i++) {
+		id = le16_to_cpup((__le16 *)&data[k]);
+
+		/* is there an existing slot for this contact? */
+		for (j = 0; j < features->touch_max; j++) {
+			mt = &input->mt[j];
+			if (input_mt_get_value(mt, ABS_MT_TRACKING_ID) == id )
+				break;
+		}
+
+		/* no. then find an unused slot to fill */
+		if (j >= features->touch_max) {
+			for (j = 0; j < features->touch_max; j++) {
+				mt = &input->mt[j];
+				if (input_mt_get_value(mt, ABS_MT_TRACKING_ID) == -1 )
+					break;
+			}
+		}
+
+		touch = data[k - 1] & 0x1;
+		input_mt_slot(input, j);
+		if (touch) {
+			x = le16_to_cpup((__le16 *)&data[k + 6]);
+			y = le16_to_cpup((__le16 *)&data[k + 8]);
+
+			input_report_abs(input, ABS_MT_POSITION_X, x);
+			input_report_abs(input, ABS_MT_POSITION_Y, y);
+		} else
+			id = -1;
+
+		/* keep the id from firmware since we need
+		 * it to process future events
+		 */
+		input_report_abs(input, ABS_MT_TRACKING_ID, id);
+
+		k += WACOM_BYTES_PER_MT_PACKET;
+	}
+
+	input_mt_report_pointer_emulation(input, true);
+
+	features->num_contacts_left -= contacts_to_send;
+	if (features->num_contacts_left < 0)
+		features->num_contacts_left = 0;
+	return 1;
+}
+
 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
 {
 	struct input_dev *input = wacom->input;
@@ -767,6 +836,10 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
 	bool prox;
 	int x = 0, y = 0;
 
+	if ((wacom->features.touch_max > 1) ||
+				(len > WACOM_PKGLEN_TPC2FG))
+		return 0;
+
 	if (!wacom->shared->stylus_in_proximity) {
 		if (len == WACOM_PKGLEN_TPC1FG) {
 			prox = data[0] & 0x01;
@@ -835,10 +908,10 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
 
 	switch (len) {
 	case WACOM_PKGLEN_TPC1FG:
-		 return wacom_tpc_single_touch(wacom, len);
+		return wacom_tpc_single_touch(wacom, len);
 
 	case WACOM_PKGLEN_TPC2FG:
- 		return wacom_tpc_mt_touch(wacom);
+		return wacom_tpc_mt_touch(wacom);
 
 	default:
 		switch (data[0]) {
@@ -847,6 +920,9 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
 		case WACOM_REPORT_TPCST:
 			return wacom_tpc_single_touch(wacom, len);
 
+		case WACOM_REPORT_TPCMT:
+			return wacom_mt_touch(wacom);
+
 		case WACOM_REPORT_PENABLED:
 			return wacom_tpc_pen(wacom);
 		}
@@ -1088,6 +1164,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 
 	case TABLETPC:
 	case TABLETPC2FG:
+	case MTSCREEN:
 		sync = wacom_tpc_irq(wacom_wac, len);
 		break;
 
@@ -1156,7 +1233,7 @@ void wacom_setup_device_quirks(struct wacom_features *features)
 
 	/* these device have multiple inputs */
 	if (features->type == TABLETPC || features->type == TABLETPC2FG ||
-	    features->type == BAMBOO_PT)
+	    features->type == BAMBOO_PT || features->type == MTSCREEN)
 		features->quirks |= WACOM_QUIRK_MULTI_INPUT;
 
 	/* quirk for bamboo touch with 2 low res touches */
@@ -1330,6 +1407,7 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
 		break;
 
 	case TABLETPC2FG:
+	case MTSCREEN:
 		if (features->device_type == BTN_TOOL_FINGER) {
 
 			input_mt_init_slots(input_dev, features->touch_max);
@@ -1633,6 +1711,9 @@ static const struct wacom_features wacom_features_0xE3 =
 	{ "Wacom ISDv4 E3",       WACOM_PKGLEN_TPC2FG,    26202, 16325,  255,
 	  0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
 	  .touch_max = 2 };
+static const struct wacom_features wacom_features_0xE5 =
+	{ "Wacom ISDv4 E5",       WACOM_PKGLEN_MTOUCH,    26202, 16325,  255,
+	  0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0xE6 =
 	{ "Wacom ISDv4 E6",       WACOM_PKGLEN_TPC2FG,    27760, 15694,  255,
 	  0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
@@ -1799,6 +1880,7 @@ const struct usb_device_id wacom_ids[] = {
 	{ USB_DEVICE_WACOM(0x9F) },
 	{ USB_DEVICE_WACOM(0xE2) },
 	{ USB_DEVICE_WACOM(0xE3) },
+	{ USB_DEVICE_WACOM(0xE5) },
 	{ USB_DEVICE_WACOM(0xE6) },
 	{ USB_DEVICE_WACOM(0x47) },
 	{ USB_DEVICE_WACOM(0xF4) },
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index 1c9dc3e..265b09f 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -24,6 +24,10 @@
 #define WACOM_PKGLEN_BBTOUCH	20
 #define WACOM_PKGLEN_BBTOUCH3	64
 #define WACOM_PKGLEN_BBPEN	10
+#define WACOM_PKGLEN_MTOUCH	62
+
+/* wacom data size per MT contact */
+#define WACOM_BYTES_PER_MT_PACKET	11
 
 /* device IDs */
 #define STYLUS_DEVICE_ID	0x02
@@ -39,6 +43,7 @@
 #define WACOM_REPORT_INTUOSPAD		12
 #define WACOM_REPORT_TPC1FG		6
 #define WACOM_REPORT_TPC2FG		13
+#define WACOM_REPORT_TPCMT		13
 #define WACOM_REPORT_TPCHID		15
 #define WACOM_REPORT_TPCST		16
 
@@ -68,6 +73,7 @@ enum {
 	WACOM_MO,
 	TABLETPC,
 	TABLETPC2FG,
+	MTSCREEN,
 	MAX_TYPE
 };
 
@@ -92,6 +98,8 @@ struct wacom_features {
 	int distance_fuzz;
 	unsigned quirks;
 	unsigned touch_max;
+	unsigned num_contacts;
+	unsigned num_contacts_left;
 };
 
 struct wacom_shared {
-- 
1.7.7.4


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

* [PATCH 2/2] input: wacom - add 0xE5 (MT device) support
  2012-04-15 22:50 [PATCH 0/2] Add E5 support chris
@ 2012-04-15 22:50 ` chris
  0 siblings, 0 replies; 15+ messages in thread
From: chris @ 2012-04-15 22:50 UTC (permalink / raw)
  To: linux-input, dmitry.torokhov, pinglinux; +Cc: Chris Bagwell, Ping Cheng

From: Ping Cheng <pinglinux@gmail.com>

Main part of patch is adding support for a new Wacom MT touch
packet and labels these devices using MTSCREEN type.

Other items of interest:

Delete some duplicate code in HID parsing for Y info since
its already done in X path.

In wacom_query_tablet_data(), only invoke the set report
that requests tablets to send Wacom Touch packets for
Finger interfaces.  Mostly, this is to make code intent clear.

Tested-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Chris Bagwell <chris@cnpbagwell.com>
Signed-off-by: Ping Cheng <pingc@wacom.com>
---
 drivers/input/tablet/wacom.h     |    4 +-
 drivers/input/tablet/wacom_sys.c |   86 +++++++++++++++++++---------------
 drivers/input/tablet/wacom_wac.c |   96 ++++++++++++++++++++++++++++++++++++--
 drivers/input/tablet/wacom_wac.h |    8 +++
 4 files changed, 149 insertions(+), 45 deletions(-)

diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index b4842d0..b79d451 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -135,6 +135,6 @@ extern const struct usb_device_id wacom_ids[];
 
 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
 void wacom_setup_device_quirks(struct wacom_features *features);
-void wacom_setup_input_capabilities(struct input_dev *input_dev,
-				    struct wacom_wac *wacom_wac);
+int wacom_setup_input_capabilities(struct input_dev *input_dev,
+				   struct wacom_wac *wacom_wac);
 #endif
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 469f6ce..822ab06 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -310,6 +310,10 @@ static int wacom_parse_hid(struct usb_interface *intf,
 							/* need to reset back */
 							features->pktlen = WACOM_PKGLEN_TPC2FG;
 						}
+
+						if (features->type == MTSCREEN)
+							features->pktlen = WACOM_PKGLEN_MTOUCH;
+
 						if (features->type == BAMBOO_PT) {
 							/* need to reset back */
 							features->pktlen = WACOM_PKGLEN_BBTOUCH;
@@ -342,18 +346,15 @@ static int wacom_parse_hid(struct usb_interface *intf,
 			case HID_USAGE_Y:
 				if (usage == WCM_DESKTOP) {
 					if (finger) {
-						features->device_type = BTN_TOOL_FINGER;
-						if (features->type == TABLETPC2FG) {
-							/* need to reset back */
-							features->pktlen = WACOM_PKGLEN_TPC2FG;
+						int type = features->type;
+
+						if (type == TABLETPC2FG || type == MTSCREEN) {
 							features->y_max =
 								get_unaligned_le16(&report[i + 3]);
 							features->y_phy =
 								get_unaligned_le16(&report[i + 6]);
 							i += 7;
-						} else if (features->type == BAMBOO_PT) {
-							/* need to reset back */
-							features->pktlen = WACOM_PKGLEN_BBTOUCH;
+						} else if (type == BAMBOO_PT) {
 							features->y_phy =
 								get_unaligned_le16(&report[i + 3]);
 							features->y_max =
@@ -367,10 +368,6 @@ static int wacom_parse_hid(struct usb_interface *intf,
 							i += 4;
 						}
 					} else if (pen) {
-						/* penabled only accepts exact bytes of data */
-						if (features->type == TABLETPC2FG)
-							features->pktlen = WACOM_PKGLEN_GRAPHIRE;
-						features->device_type = BTN_TOOL_PEN;
 						features->y_max =
 							get_unaligned_le16(&report[i + 3]);
 						i += 4;
@@ -433,22 +430,27 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
 	if (!rep_data)
 		return error;
 
-	/* ask to report tablet data if it is MT Tablet PC or
-	 * not a Tablet PC */
-	if (features->type == TABLETPC2FG) {
-		do {
-			rep_data[0] = 3;
-			rep_data[1] = 4;
-			rep_data[2] = 0;
-			rep_data[3] = 0;
-			report_id = 3;
-			error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
-						 report_id, rep_data, 4, 1);
-			if (error >= 0)
-				error = wacom_get_report(intf,
-						WAC_HID_FEATURE_REPORT,
-						report_id, rep_data, 4, 1);
-		} while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES);
+	/* ask to report Wacom data */
+	if (features->device_type == BTN_TOOL_FINGER) {
+		/* if it is an MT Tablet PC touch */
+		if ((features->type == TABLETPC2FG) ||
+		    (features->type == MTSCREEN)) {
+			do {
+				rep_data[0] = 3;
+				rep_data[1] = 4;
+				rep_data[2] = 0;
+				rep_data[3] = 0;
+				report_id = 3;
+				error = wacom_set_report(intf,
+							 WAC_HID_FEATURE_REPORT,
+							 report_id, rep_data, 4, 1);
+				if (error >= 0)
+					error = wacom_get_report(intf,
+								 WAC_HID_FEATURE_REPORT,
+								 report_id, rep_data, 4, 1);
+			} while ((error < 0 || rep_data[1] != 4) &&
+				 limit++ < WAC_MSG_RETRIES);
+		}
 	} else if (features->type != TABLETPC &&
 		   features->type != WIRELESS &&
 		   features->device_type == BTN_TOOL_PEN) {
@@ -459,8 +461,8 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
 						 report_id, rep_data, 2, 1);
 			if (error >= 0)
 				error = wacom_get_report(intf,
-						WAC_HID_FEATURE_REPORT,
-						report_id, rep_data, 2, 1);
+							 WAC_HID_FEATURE_REPORT,
+							 report_id, rep_data, 2, 1);
 		} while ((error < 0 || rep_data[1] != 2) && limit++ < WAC_MSG_RETRIES);
 	}
 
@@ -498,9 +500,9 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
 		}
 	}
 
-	/* only Tablet PCs and Bamboo P&T need to retrieve the info */
+	/* only devices that support touch need to retrieve the info */
 	if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) &&
-	    (features->type != BAMBOO_PT))
+	    (features->type != BAMBOO_PT) && (features->type != MTSCREEN))
 		goto out;
 
 	if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {
@@ -971,8 +973,10 @@ static int wacom_register_input(struct wacom *wacom)
 	int error;
 
 	input_dev = input_allocate_device();
-	if (!input_dev)
-		return -ENOMEM;
+	if (!input_dev) {
+		error = -ENOMEM;
+		goto fail1;
+	}
 
 	input_dev->name = wacom_wac->name;
 	input_dev->dev.parent = &intf->dev;
@@ -982,14 +986,20 @@ static int wacom_register_input(struct wacom *wacom)
 	input_set_drvdata(input_dev, wacom);
 
 	wacom_wac->input = input_dev;
-	wacom_setup_input_capabilities(input_dev, wacom_wac);
+	error = wacom_setup_input_capabilities(input_dev, wacom_wac);
+	if (error)
+		goto fail1;
 
 	error = input_register_device(input_dev);
-	if (error) {
-		input_free_device(input_dev);
-		wacom_wac->input = NULL;
-	}
+	if (error)
+		goto fail2;
+
+	return 0;
 
+fail2:
+	input_free_device(input_dev);
+	wacom_wac->input = NULL;
+fail1:
 	return error;
 }
 
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index a257bed..ded0e8b 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -768,6 +768,70 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
 	return 1;
 }
 
+static int find_slot_from_contactid(struct wacom_wac *wacom, int contactid)
+{
+	int touch_max = wacom->features.touch_max;
+	int i;
+
+	if (!wacom->slots)
+		return -1;
+
+	for (i = 0; i < touch_max; ++i) {
+		if (wacom->slots[i] == contactid)
+			return i;
+	}
+	for (i = 0; i < touch_max; ++i) {
+		if (wacom->slots[i] == -1)
+			return i;
+	}
+	return -1;
+}
+
+static int wacom_mt_touch(struct wacom_wac *wacom)
+{
+	struct input_dev *input = wacom->input;
+	char *data = wacom->data;
+	int i;
+	int current_num_contacts = data[2];
+	int contacts_to_send = 0;
+
+	/* reset the counter by the first packet since only the first
+	 * packet in series will have non-zero current_num_contacts
+	 */
+	if (current_num_contacts)
+		wacom->num_contacts_left = current_num_contacts;
+
+	/* There are at most 5 contacts per packet */
+	contacts_to_send = min(5, (int)wacom->num_contacts_left);
+
+	for (i = 0; i < contacts_to_send; i++) {
+		int offset = (WACOM_BYTES_PER_MT_PACKET * i) + 3;
+		bool touch = data[offset] & 0x1;
+		int id = le16_to_cpup((__le16 *)&data[offset + 1]);
+		int slot = find_slot_from_contactid(wacom, id);
+
+		if (slot < 0)
+			continue;
+
+		input_mt_slot(input, slot);
+		input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
+		if (touch) {
+			int x = le16_to_cpup((__le16 *)&data[offset + 7]);
+			int y = le16_to_cpup((__le16 *)&data[offset + 9]);
+			input_report_abs(input, ABS_MT_POSITION_X, x);
+			input_report_abs(input, ABS_MT_POSITION_Y, y);
+		}
+		wacom->slots[slot] = touch ? id : -1;
+	}
+
+	input_mt_report_pointer_emulation(input, true);
+
+	wacom->num_contacts_left -= contacts_to_send;
+	if (wacom->num_contacts_left < 0)
+		wacom->num_contacts_left = 0;
+	return 1;
+}
+
 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
 {
 	struct input_dev *input = wacom->input;
@@ -806,6 +870,10 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
 	bool prox;
 	int x = 0, y = 0;
 
+	if ((wacom->features.touch_max > 1) ||
+				(len > WACOM_PKGLEN_TPC2FG))
+		return 0;
+
 	if (!wacom->shared->stylus_in_proximity) {
 		if (len == WACOM_PKGLEN_TPC1FG) {
 			prox = data[0] & 0x01;
@@ -873,10 +941,10 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
 
 	switch (len) {
 	case WACOM_PKGLEN_TPC1FG:
-		 return wacom_tpc_single_touch(wacom, len);
+		return wacom_tpc_single_touch(wacom, len);
 
 	case WACOM_PKGLEN_TPC2FG:
- 		return wacom_tpc_mt_touch(wacom);
+		return wacom_tpc_mt_touch(wacom);
 
 	default:
 		switch (data[0]) {
@@ -885,6 +953,9 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
 		case WACOM_REPORT_TPCST:
 			return wacom_tpc_single_touch(wacom, len);
 
+		case WACOM_REPORT_TPCMT:
+			return wacom_mt_touch(wacom);
+
 		case WACOM_REPORT_PENABLED:
 			return wacom_tpc_pen(wacom);
 		}
@@ -1164,6 +1235,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 
 	case TABLETPC:
 	case TABLETPC2FG:
+	case MTSCREEN:
 		sync = wacom_tpc_irq(wacom_wac, len);
 		break;
 
@@ -1237,7 +1309,8 @@ void wacom_setup_device_quirks(struct wacom_features *features)
 	/* these device have multiple inputs */
 	if (features->type == TABLETPC || features->type == TABLETPC2FG ||
 	    features->type == BAMBOO_PT || features->type == WIRELESS ||
-	    (features->type >= INTUOS5S && features->type <= INTUOS5L))
+	    (features->type >= INTUOS5S && features->type <= INTUOS5L) ||
+	    features->type == MTSCREEN)
 		features->quirks |= WACOM_QUIRK_MULTI_INPUT;
 
 	/* quirk for bamboo touch with 2 low res touches */
@@ -1268,8 +1341,8 @@ static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
        return (logical_max * 100) / physical_max;
 }
 
-void wacom_setup_input_capabilities(struct input_dev *input_dev,
-				    struct wacom_wac *wacom_wac)
+int wacom_setup_input_capabilities(struct input_dev *input_dev,
+				   struct wacom_wac *wacom_wac)
 {
 	struct wacom_features *features = &wacom_wac->features;
 	int i;
@@ -1465,8 +1538,16 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
 		break;
 
 	case TABLETPC2FG:
+	case MTSCREEN:
 		if (features->device_type == BTN_TOOL_FINGER) {
 
+			wacom_wac->slots = kmalloc(features->touch_max *
+						   sizeof(int), GFP_KERNEL);
+			if (!wacom_wac->slots)
+				return -ENOMEM;
+			for (i = 0; i < features->touch_max; i++)
+				wacom_wac->slots[i] = -1;
+
 			input_mt_init_slots(input_dev, features->touch_max);
 			input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE,
 					0, MT_TOOL_MAX, 0, 0);
@@ -1552,6 +1633,7 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
 		}
 		break;
 	}
+	return 0;
 }
 
 static const struct wacom_features wacom_features_0x00 =
@@ -1784,6 +1866,9 @@ static const struct wacom_features wacom_features_0xE3 =
 	{ "Wacom ISDv4 E3",       WACOM_PKGLEN_TPC2FG,    26202, 16325,  255,
 	  0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
 	  .touch_max = 2 };
+static const struct wacom_features wacom_features_0xE5 =
+	{ "Wacom ISDv4 E5",       WACOM_PKGLEN_MTOUCH,    26202, 16325,  255,
+	  0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0xE6 =
 	{ "Wacom ISDv4 E6",       WACOM_PKGLEN_TPC2FG,    27760, 15694,  255,
 	  0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
@@ -1962,6 +2047,7 @@ const struct usb_device_id wacom_ids[] = {
 	{ USB_DEVICE_WACOM(0x9F) },
 	{ USB_DEVICE_WACOM(0xE2) },
 	{ USB_DEVICE_WACOM(0xE3) },
+	{ USB_DEVICE_WACOM(0xE5) },
 	{ USB_DEVICE_WACOM(0xE6) },
 	{ USB_DEVICE_WACOM(0xEC) },
 	{ USB_DEVICE_WACOM(0x47) },
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index 321269c..3dde639 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -25,6 +25,10 @@
 #define WACOM_PKGLEN_BBTOUCH3	64
 #define WACOM_PKGLEN_BBPEN	10
 #define WACOM_PKGLEN_WIRELESS	32
+#define WACOM_PKGLEN_MTOUCH	62
+
+/* wacom data size per MT contact */
+#define WACOM_BYTES_PER_MT_PACKET	11
 
 /* device IDs */
 #define STYLUS_DEVICE_ID	0x02
@@ -41,6 +45,7 @@
 #define WACOM_REPORT_INTUOS5PAD		3
 #define WACOM_REPORT_TPC1FG		6
 #define WACOM_REPORT_TPC2FG		13
+#define WACOM_REPORT_TPCMT		13
 #define WACOM_REPORT_TPCHID		15
 #define WACOM_REPORT_TPCST		16
 
@@ -76,6 +81,7 @@ enum {
 	WACOM_MO,
 	TABLETPC,
 	TABLETPC2FG,
+	MTSCREEN,
 	MAX_TYPE
 };
 
@@ -118,6 +124,8 @@ struct wacom_wac {
 	struct input_dev *input;
 	int pid;
 	int battery_capacity;
+	unsigned num_contacts_left;
+	int *slots;
 };
 
 #endif
-- 
1.7.7.6


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

* [PATCH 2/2] input: wacom - add 0xE5 (MT device) support
@ 2012-04-26  1:14 Ping Cheng
  2012-04-30  4:10 ` Dmitry Torokhov
  2012-06-14 21:23 ` [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support" Jonathan Nieder
  0 siblings, 2 replies; 15+ messages in thread
From: Ping Cheng @ 2012-04-26  1:14 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, Ping Cheng, Chris Bagwell, Ping Cheng

Main part of patch is adding support for a new Wacom MT touch
packet and labels these devices using MTSCREEN type.

Other items of interest:

Delete some duplicate code in HID parsing for Y info since
its already done in X path.

In wacom_query_tablet_data(), only invoke the set report
that requests tablets to send Wacom Touch packets for
Finger interfaces.  Mostly, this is to make code intent clear.

Tested-by: Jason Gerecke <killertofu@gmail.com>
Signed-off-by: Chris Bagwell <chris@cnpbagwell.com>
Signed-off-by: Ping Cheng <pingc@wacom.com>
---
 drivers/input/tablet/wacom.h     |    4 +-
 drivers/input/tablet/wacom_sys.c |   86 +++++++++++++++++++---------------
 drivers/input/tablet/wacom_wac.c |   96 ++++++++++++++++++++++++++++++++++++--
 drivers/input/tablet/wacom_wac.h |    8 +++
 4 files changed, 149 insertions(+), 45 deletions(-)

diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index b4842d0..b79d451 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -135,6 +135,6 @@ extern const struct usb_device_id wacom_ids[];
 
 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
 void wacom_setup_device_quirks(struct wacom_features *features);
-void wacom_setup_input_capabilities(struct input_dev *input_dev,
-				    struct wacom_wac *wacom_wac);
+int wacom_setup_input_capabilities(struct input_dev *input_dev,
+				   struct wacom_wac *wacom_wac);
 #endif
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 347026b..a941d6e 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -317,6 +317,10 @@ static int wacom_parse_hid(struct usb_interface *intf,
 							/* need to reset back */
 							features->pktlen = WACOM_PKGLEN_TPC2FG;
 						}
+
+						if (features->type == MTSCREEN)
+							features->pktlen = WACOM_PKGLEN_MTOUCH;
+
 						if (features->type == BAMBOO_PT) {
 							/* need to reset back */
 							features->pktlen = WACOM_PKGLEN_BBTOUCH;
@@ -349,18 +353,15 @@ static int wacom_parse_hid(struct usb_interface *intf,
 			case HID_USAGE_Y:
 				if (usage == WCM_DESKTOP) {
 					if (finger) {
-						features->device_type = BTN_TOOL_FINGER;
-						if (features->type == TABLETPC2FG) {
-							/* need to reset back */
-							features->pktlen = WACOM_PKGLEN_TPC2FG;
+						int type = features->type;
+
+						if (type == TABLETPC2FG || type == MTSCREEN) {
 							features->y_max =
 								get_unaligned_le16(&report[i + 3]);
 							features->y_phy =
 								get_unaligned_le16(&report[i + 6]);
 							i += 7;
-						} else if (features->type == BAMBOO_PT) {
-							/* need to reset back */
-							features->pktlen = WACOM_PKGLEN_BBTOUCH;
+						} else if (type == BAMBOO_PT) {
 							features->y_phy =
 								get_unaligned_le16(&report[i + 3]);
 							features->y_max =
@@ -374,10 +375,6 @@ static int wacom_parse_hid(struct usb_interface *intf,
 							i += 4;
 						}
 					} else if (pen) {
-						/* penabled only accepts exact bytes of data */
-						if (features->type == TABLETPC2FG)
-							features->pktlen = WACOM_PKGLEN_GRAPHIRE;
-						features->device_type = BTN_TOOL_PEN;
 						features->y_max =
 							get_unaligned_le16(&report[i + 3]);
 						i += 4;
@@ -440,22 +437,27 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
 	if (!rep_data)
 		return error;
 
-	/* ask to report tablet data if it is MT Tablet PC or
-	 * not a Tablet PC */
-	if (features->type == TABLETPC2FG) {
-		do {
-			rep_data[0] = 3;
-			rep_data[1] = 4;
-			rep_data[2] = 0;
-			rep_data[3] = 0;
-			report_id = 3;
-			error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
-						 report_id, rep_data, 4, 1);
-			if (error >= 0)
-				error = wacom_get_report(intf,
-						WAC_HID_FEATURE_REPORT,
-						report_id, rep_data, 4, 1);
-		} while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES);
+	/* ask to report Wacom data */
+	if (features->device_type == BTN_TOOL_FINGER) {
+		/* if it is an MT Tablet PC touch */
+		if ((features->type == TABLETPC2FG) ||
+		    (features->type == MTSCREEN)) {
+			do {
+				rep_data[0] = 3;
+				rep_data[1] = 4;
+				rep_data[2] = 0;
+				rep_data[3] = 0;
+				report_id = 3;
+				error = wacom_set_report(intf,
+							 WAC_HID_FEATURE_REPORT,
+							 report_id, rep_data, 4, 1);
+				if (error >= 0)
+					error = wacom_get_report(intf,
+								 WAC_HID_FEATURE_REPORT,
+								 report_id, rep_data, 4, 1);
+			} while ((error < 0 || rep_data[1] != 4) &&
+				 limit++ < WAC_MSG_RETRIES);
+		}
 	} else if (features->type != TABLETPC &&
 		   features->type != WIRELESS &&
 		   features->device_type == BTN_TOOL_PEN) {
@@ -466,8 +468,8 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
 						 report_id, rep_data, 2, 1);
 			if (error >= 0)
 				error = wacom_get_report(intf,
-						WAC_HID_FEATURE_REPORT,
-						report_id, rep_data, 2, 1);
+							 WAC_HID_FEATURE_REPORT,
+							 report_id, rep_data, 2, 1);
 		} while ((error < 0 || rep_data[1] != 2) && limit++ < WAC_MSG_RETRIES);
 	}
 
@@ -505,9 +507,9 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
 		}
 	}
 
-	/* only Tablet PCs and Bamboo P&T need to retrieve the info */
+	/* only devices that support touch need to retrieve the info */
 	if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) &&
-	    (features->type != BAMBOO_PT))
+	    (features->type != BAMBOO_PT) && (features->type != MTSCREEN))
 		goto out;
 
 	if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {
@@ -978,8 +980,10 @@ static int wacom_register_input(struct wacom *wacom)
 	int error;
 
 	input_dev = input_allocate_device();
-	if (!input_dev)
-		return -ENOMEM;
+	if (!input_dev) {
+		error = -ENOMEM;
+		goto fail1;
+	}
 
 	input_dev->name = wacom_wac->name;
 	input_dev->dev.parent = &intf->dev;
@@ -989,14 +993,20 @@ static int wacom_register_input(struct wacom *wacom)
 	input_set_drvdata(input_dev, wacom);
 
 	wacom_wac->input = input_dev;
-	wacom_setup_input_capabilities(input_dev, wacom_wac);
+	error = wacom_setup_input_capabilities(input_dev, wacom_wac);
+	if (error)
+		goto fail1;
 
 	error = input_register_device(input_dev);
-	if (error) {
-		input_free_device(input_dev);
-		wacom_wac->input = NULL;
-	}
+	if (error)
+		goto fail2;
+
+	return 0;
 
+fail2:
+	input_free_device(input_dev);
+	wacom_wac->input = NULL;
+fail1:
 	return error;
 }
 
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index e5cd0e5..3afd3bc 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -768,6 +768,70 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
 	return 1;
 }
 
+static int find_slot_from_contactid(struct wacom_wac *wacom, int contactid)
+{
+	int touch_max = wacom->features.touch_max;
+	int i;
+
+	if (!wacom->slots)
+		return -1;
+
+	for (i = 0; i < touch_max; ++i) {
+		if (wacom->slots[i] == contactid)
+			return i;
+	}
+	for (i = 0; i < touch_max; ++i) {
+		if (wacom->slots[i] == -1)
+			return i;
+	}
+	return -1;
+}
+
+static int wacom_mt_touch(struct wacom_wac *wacom)
+{
+	struct input_dev *input = wacom->input;
+	char *data = wacom->data;
+	int i;
+	int current_num_contacts = data[2];
+	int contacts_to_send = 0;
+
+	/* reset the counter by the first packet since only the first
+	 * packet in series will have non-zero current_num_contacts
+	 */
+	if (current_num_contacts)
+		wacom->num_contacts_left = current_num_contacts;
+
+	/* There are at most 5 contacts per packet */
+	contacts_to_send = min(5, (int)wacom->num_contacts_left);
+
+	for (i = 0; i < contacts_to_send; i++) {
+		int offset = (WACOM_BYTES_PER_MT_PACKET * i) + 3;
+		bool touch = data[offset] & 0x1;
+		int id = le16_to_cpup((__le16 *)&data[offset + 1]);
+		int slot = find_slot_from_contactid(wacom, id);
+
+		if (slot < 0)
+			continue;
+
+		input_mt_slot(input, slot);
+		input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
+		if (touch) {
+			int x = le16_to_cpup((__le16 *)&data[offset + 7]);
+			int y = le16_to_cpup((__le16 *)&data[offset + 9]);
+			input_report_abs(input, ABS_MT_POSITION_X, x);
+			input_report_abs(input, ABS_MT_POSITION_Y, y);
+		}
+		wacom->slots[slot] = touch ? id : -1;
+	}
+
+	input_mt_report_pointer_emulation(input, true);
+
+	wacom->num_contacts_left -= contacts_to_send;
+	if (wacom->num_contacts_left < 0)
+		wacom->num_contacts_left = 0;
+	return 1;
+}
+
 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
 {
 	struct input_dev *input = wacom->input;
@@ -806,6 +870,10 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
 	bool prox;
 	int x = 0, y = 0;
 
+	if ((wacom->features.touch_max > 1) ||
+				(len > WACOM_PKGLEN_TPC2FG))
+		return 0;
+
 	if (!wacom->shared->stylus_in_proximity) {
 		if (len == WACOM_PKGLEN_TPC1FG) {
 			prox = data[0] & 0x01;
@@ -873,10 +941,10 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
 
 	switch (len) {
 	case WACOM_PKGLEN_TPC1FG:
-		 return wacom_tpc_single_touch(wacom, len);
+		return wacom_tpc_single_touch(wacom, len);
 
 	case WACOM_PKGLEN_TPC2FG:
- 		return wacom_tpc_mt_touch(wacom);
+		return wacom_tpc_mt_touch(wacom);
 
 	default:
 		switch (data[0]) {
@@ -885,6 +953,9 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
 		case WACOM_REPORT_TPCST:
 			return wacom_tpc_single_touch(wacom, len);
 
+		case WACOM_REPORT_TPCMT:
+			return wacom_mt_touch(wacom);
+
 		case WACOM_REPORT_PENABLED:
 			return wacom_tpc_pen(wacom);
 		}
@@ -1164,6 +1235,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 
 	case TABLETPC:
 	case TABLETPC2FG:
+	case MTSCREEN:
 		sync = wacom_tpc_irq(wacom_wac, len);
 		break;
 
@@ -1237,7 +1309,8 @@ void wacom_setup_device_quirks(struct wacom_features *features)
 	/* these device have multiple inputs */
 	if (features->type == TABLETPC || features->type == TABLETPC2FG ||
 	    features->type == BAMBOO_PT || features->type == WIRELESS ||
-	    (features->type >= INTUOS5S && features->type <= INTUOS5L))
+	    (features->type >= INTUOS5S && features->type <= INTUOS5L) ||
+	    features->type == MTSCREEN)
 		features->quirks |= WACOM_QUIRK_MULTI_INPUT;
 
 	/* quirk for bamboo touch with 2 low res touches */
@@ -1268,8 +1341,8 @@ static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
        return (logical_max * 100) / physical_max;
 }
 
-void wacom_setup_input_capabilities(struct input_dev *input_dev,
-				    struct wacom_wac *wacom_wac)
+int wacom_setup_input_capabilities(struct input_dev *input_dev,
+				   struct wacom_wac *wacom_wac)
 {
 	struct wacom_features *features = &wacom_wac->features;
 	int i;
@@ -1465,8 +1538,16 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
 		break;
 
 	case TABLETPC2FG:
+	case MTSCREEN:
 		if (features->device_type == BTN_TOOL_FINGER) {
 
+			wacom_wac->slots = kmalloc(features->touch_max *
+						   sizeof(int), GFP_KERNEL);
+			if (!wacom_wac->slots)
+				return -ENOMEM;
+			for (i = 0; i < features->touch_max; i++)
+				wacom_wac->slots[i] = -1;
+
 			input_mt_init_slots(input_dev, features->touch_max);
 			input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE,
 					0, MT_TOOL_MAX, 0, 0);
@@ -1552,6 +1633,7 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
 		}
 		break;
 	}
+	return 0;
 }
 
 static const struct wacom_features wacom_features_0x00 =
@@ -1784,6 +1866,9 @@ static const struct wacom_features wacom_features_0xE3 =
 	{ "Wacom ISDv4 E3",       WACOM_PKGLEN_TPC2FG,    26202, 16325,  255,
 	  0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
 	  .touch_max = 2 };
+static const struct wacom_features wacom_features_0xE5 =
+	{ "Wacom ISDv4 E5",       WACOM_PKGLEN_MTOUCH,    26202, 16325,  255,
+	  0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0xE6 =
 	{ "Wacom ISDv4 E6",       WACOM_PKGLEN_TPC2FG,    27760, 15694,  255,
 	  0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
@@ -1962,6 +2047,7 @@ const struct usb_device_id wacom_ids[] = {
 	{ USB_DEVICE_WACOM(0x9F) },
 	{ USB_DEVICE_WACOM(0xE2) },
 	{ USB_DEVICE_WACOM(0xE3) },
+	{ USB_DEVICE_WACOM(0xE5) },
 	{ USB_DEVICE_WACOM(0xE6) },
 	{ USB_DEVICE_WACOM(0xEC) },
 	{ USB_DEVICE_WACOM(0x47) },
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index 321269c..3dde639 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -25,6 +25,10 @@
 #define WACOM_PKGLEN_BBTOUCH3	64
 #define WACOM_PKGLEN_BBPEN	10
 #define WACOM_PKGLEN_WIRELESS	32
+#define WACOM_PKGLEN_MTOUCH	62
+
+/* wacom data size per MT contact */
+#define WACOM_BYTES_PER_MT_PACKET	11
 
 /* device IDs */
 #define STYLUS_DEVICE_ID	0x02
@@ -41,6 +45,7 @@
 #define WACOM_REPORT_INTUOS5PAD		3
 #define WACOM_REPORT_TPC1FG		6
 #define WACOM_REPORT_TPC2FG		13
+#define WACOM_REPORT_TPCMT		13
 #define WACOM_REPORT_TPCHID		15
 #define WACOM_REPORT_TPCST		16
 
@@ -76,6 +81,7 @@ enum {
 	WACOM_MO,
 	TABLETPC,
 	TABLETPC2FG,
+	MTSCREEN,
 	MAX_TYPE
 };
 
@@ -118,6 +124,8 @@ struct wacom_wac {
 	struct input_dev *input;
 	int pid;
 	int battery_capacity;
+	unsigned num_contacts_left;
+	int *slots;
 };
 
 #endif
-- 
1.7.5.4


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

* Re: [PATCH 2/2] input: wacom - add 0xE5 (MT device) support
  2012-04-26  1:14 [PATCH 2/2] input: wacom - add 0xE5 (MT device) support Ping Cheng
@ 2012-04-30  4:10 ` Dmitry Torokhov
  2012-06-14 21:23 ` [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support" Jonathan Nieder
  1 sibling, 0 replies; 15+ messages in thread
From: Dmitry Torokhov @ 2012-04-30  4:10 UTC (permalink / raw)
  To: Ping Cheng; +Cc: linux-input, Chris Bagwell, Ping Cheng

On Wed, Apr 25, 2012 at 06:14:16PM -0700, Ping Cheng wrote:
> Main part of patch is adding support for a new Wacom MT touch
> packet and labels these devices using MTSCREEN type.
> 
> Other items of interest:
> 
> Delete some duplicate code in HID parsing for Y info since
> its already done in X path.
> 
> In wacom_query_tablet_data(), only invoke the set report
> that requests tablets to send Wacom Touch packets for
> Finger interfaces.  Mostly, this is to make code intent clear.

Applied, but:

> +
> +	wacom->num_contacts_left -= contacts_to_send;
> +	if (wacom->num_contacts_left < 0)
> +		wacom->num_contacts_left = 0;

num_contacts_left is unsigned so this condition woudl never fire.
Changed num_contacts_left to be signed before applying.

Thanks.

-- 
Dmitry

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

* [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support"
  2012-04-26  1:14 [PATCH 2/2] input: wacom - add 0xE5 (MT device) support Ping Cheng
  2012-04-30  4:10 ` Dmitry Torokhov
@ 2012-06-14 21:23 ` Jonathan Nieder
  2012-06-14 23:51   ` Ping Cheng
  1 sibling, 1 reply; 15+ messages in thread
From: Jonathan Nieder @ 2012-06-14 21:23 UTC (permalink / raw)
  To: Ping Cheng
  Cc: dmitry.torokhov, Bjørn Mork, linux-input, Jason Gerecke,
	Chris Bagwell, Ping Cheng

This reverts commit 1963518b9b1b8019d33b4b08deee6f873ffa2730.

It was supposed to just add support for new MTSCREEN devices, but
instead it significantly changed the code handling TABLETPC2FG and
BAMBOO_PT.  That destroys debugability.  Back to the drawing board.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Hi,

Ping Cheng wrote:

> Main part of patch is adding support for a new Wacom MT touch
> packet and labels these devices using MTSCREEN type.
>
> Other items of interest:

Agh!

A patch adding new hardware support should not touch existing support
for other devices at the same time.  Especially not cosmetic changes.

[1] has an analysis by Bjørn of why those unrelated changes are
probably buggy, but I don't really care about that at the moment.  If
it were a separate patch with a description explaining what it was
supposed to do, the normal review process would take care of those
things.  Piggy-backing onto another patch is just not a good idea.

How about this patch (untested)?

Thanks,
Jonathan

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=55;bug=677164

 drivers/input/tablet/wacom.h     |    4 +-
 drivers/input/tablet/wacom_sys.c |   91 +++++++++++++++--------------------
 drivers/input/tablet/wacom_wac.c |   99 ++------------------------------------
 drivers/input/tablet/wacom_wac.h |    8 ---
 4 files changed, 45 insertions(+), 157 deletions(-)

diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index b79d45198d82..b4842d0e61dd 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -135,6 +135,6 @@ extern const struct usb_device_id wacom_ids[];
 
 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
 void wacom_setup_device_quirks(struct wacom_features *features);
-int wacom_setup_input_capabilities(struct input_dev *input_dev,
-				   struct wacom_wac *wacom_wac);
+void wacom_setup_input_capabilities(struct input_dev *input_dev,
+				    struct wacom_wac *wacom_wac);
 #endif
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index cad5602d3ce4..a0cc46e5f13c 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -320,10 +320,6 @@ static int wacom_parse_hid(struct usb_interface *intf,
 							/* need to reset back */
 							features->pktlen = WACOM_PKGLEN_TPC2FG;
 						}
-
-						if (features->type == MTSCREEN)
-							features->pktlen = WACOM_PKGLEN_MTOUCH;
-
 						if (features->type == BAMBOO_PT) {
 							/* need to reset back */
 							features->pktlen = WACOM_PKGLEN_BBTOUCH;
@@ -356,15 +352,18 @@ static int wacom_parse_hid(struct usb_interface *intf,
 			case HID_USAGE_Y:
 				if (usage == WCM_DESKTOP) {
 					if (finger) {
-						int type = features->type;
-
-						if (type == TABLETPC2FG || type == MTSCREEN) {
+						features->device_type = BTN_TOOL_FINGER;
+						if (features->type == TABLETPC2FG) {
+							/* need to reset back */
+							features->pktlen = WACOM_PKGLEN_TPC2FG;
 							features->y_max =
 								get_unaligned_le16(&report[i + 3]);
 							features->y_phy =
 								get_unaligned_le16(&report[i + 6]);
 							i += 7;
-						} else if (type == BAMBOO_PT) {
+						} else if (features->type == BAMBOO_PT) {
+							/* need to reset back */
+							features->pktlen = WACOM_PKGLEN_BBTOUCH;
 							features->y_phy =
 								get_unaligned_le16(&report[i + 3]);
 							features->y_max =
@@ -378,6 +377,10 @@ static int wacom_parse_hid(struct usb_interface *intf,
 							i += 4;
 						}
 					} else if (pen) {
+						/* penabled only accepts exact bytes of data */
+						if (features->type == TABLETPC2FG)
+							features->pktlen = WACOM_PKGLEN_GRAPHIRE;
+						features->device_type = BTN_TOOL_PEN;
 						features->y_max =
 							get_unaligned_le16(&report[i + 3]);
 						i += 4;
@@ -440,29 +443,22 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
 	if (!rep_data)
 		return error;
 
-	/* ask to report Wacom data */
-	if (features->device_type == BTN_TOOL_FINGER) {
-		/* if it is an MT Tablet PC touch */
-		if (features->type == TABLETPC2FG ||
-		    features->type == MTSCREEN) {
-			do {
-				rep_data[0] = 3;
-				rep_data[1] = 4;
-				rep_data[2] = 0;
-				rep_data[3] = 0;
-				report_id = 3;
-				error = wacom_set_report(intf,
-							 WAC_HID_FEATURE_REPORT,
-							 report_id,
-							 rep_data, 4, 1);
-				if (error >= 0)
-					error = wacom_get_report(intf,
-							WAC_HID_FEATURE_REPORT,
-							report_id,
-							rep_data, 4, 1);
-			} while ((error < 0 || rep_data[1] != 4) &&
-				 limit++ < WAC_MSG_RETRIES);
-		}
+	/* ask to report tablet data if it is MT Tablet PC or
+	 * not a Tablet PC */
+	if (features->type == TABLETPC2FG) {
+		do {
+			rep_data[0] = 3;
+			rep_data[1] = 4;
+			rep_data[2] = 0;
+			rep_data[3] = 0;
+			report_id = 3;
+			error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
+						 report_id, rep_data, 4, 1);
+			if (error >= 0)
+				error = wacom_get_report(intf,
+						WAC_HID_FEATURE_REPORT,
+						report_id, rep_data, 4, 1);
+		} while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES);
 	} else if (features->type != TABLETPC &&
 		   features->type != WIRELESS &&
 		   features->device_type == BTN_TOOL_PEN) {
@@ -484,7 +480,7 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
 }
 
 static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
-					 struct wacom_features *features)
+		struct wacom_features *features)
 {
 	int error = 0;
 	struct usb_host_interface *interface = intf->cur_altsetting;
@@ -512,13 +508,10 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
 		}
 	}
 
-	/* only devices that support touch need to retrieve the info */
-	if (features->type != TABLETPC &&
-	    features->type != TABLETPC2FG &&
-	    features->type != BAMBOO_PT &&
-	    features->type != MTSCREEN) {
+	/* only Tablet PCs and Bamboo P&T need to retrieve the info */
+	if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) &&
+	    (features->type != BAMBOO_PT))
 		goto out;
-	}
 
 	error = usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc);
 	if (error) {
@@ -990,10 +983,8 @@ static int wacom_register_input(struct wacom *wacom)
 	int error;
 
 	input_dev = input_allocate_device();
-	if (!input_dev) {
-		error = -ENOMEM;
-		goto fail1;
-	}
+	if (!input_dev)
+		return -ENOMEM;
 
 	input_dev->name = wacom_wac->name;
 	input_dev->dev.parent = &intf->dev;
@@ -1003,20 +994,14 @@ static int wacom_register_input(struct wacom *wacom)
 	input_set_drvdata(input_dev, wacom);
 
 	wacom_wac->input = input_dev;
-	error = wacom_setup_input_capabilities(input_dev, wacom_wac);
-	if (error)
-		goto fail1;
+	wacom_setup_input_capabilities(input_dev, wacom_wac);
 
 	error = input_register_device(input_dev);
-	if (error)
-		goto fail2;
+	if (error) {
+		input_free_device(input_dev);
+		wacom_wac->input = NULL;
+	}
 
-	return 0;
-
-fail2:
-	input_free_device(input_dev);
-	wacom_wac->input = NULL;
-fail1:
 	return error;
 }
 
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 004bc1bb1544..5b31418b416b 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -776,72 +776,6 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
 	return 1;
 }
 
-static int find_slot_from_contactid(struct wacom_wac *wacom, int contactid)
-{
-	int touch_max = wacom->features.touch_max;
-	int i;
-
-	if (!wacom->slots)
-		return -1;
-
-	for (i = 0; i < touch_max; ++i) {
-		if (wacom->slots[i] == contactid)
-			return i;
-	}
-	for (i = 0; i < touch_max; ++i) {
-		if (wacom->slots[i] == -1)
-			return i;
-	}
-	return -1;
-}
-
-static int wacom_mt_touch(struct wacom_wac *wacom)
-{
-	struct input_dev *input = wacom->input;
-	char *data = wacom->data;
-	int i;
-	int current_num_contacts = data[2];
-	int contacts_to_send = 0;
-
-	/*
-	 * First packet resets the counter since only the first
-	 * packet in series will have non-zero current_num_contacts.
-	 */
-	if (current_num_contacts)
-		wacom->num_contacts_left = current_num_contacts;
-
-	/* There are at most 5 contacts per packet */
-	contacts_to_send = min(5, wacom->num_contacts_left);
-
-	for (i = 0; i < contacts_to_send; i++) {
-		int offset = (WACOM_BYTES_PER_MT_PACKET * i) + 3;
-		bool touch = data[offset] & 0x1;
-		int id = le16_to_cpup((__le16 *)&data[offset + 1]);
-		int slot = find_slot_from_contactid(wacom, id);
-
-		if (slot < 0)
-			continue;
-
-		input_mt_slot(input, slot);
-		input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
-		if (touch) {
-			int x = le16_to_cpup((__le16 *)&data[offset + 7]);
-			int y = le16_to_cpup((__le16 *)&data[offset + 9]);
-			input_report_abs(input, ABS_MT_POSITION_X, x);
-			input_report_abs(input, ABS_MT_POSITION_Y, y);
-		}
-		wacom->slots[slot] = touch ? id : -1;
-	}
-
-	input_mt_report_pointer_emulation(input, true);
-
-	wacom->num_contacts_left -= contacts_to_send;
-	if (wacom->num_contacts_left < 0)
-		wacom->num_contacts_left = 0;
-
-	return 1;
-}
-
 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
 {
 	struct input_dev *input = wacom->input;
@@ -880,9 +814,6 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
 	bool prox;
 	int x = 0, y = 0;
 
-	if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
-		return 0;
-
 	if (!wacom->shared->stylus_in_proximity) {
 		if (len == WACOM_PKGLEN_TPC1FG) {
 			prox = data[0] & 0x01;
@@ -951,10 +882,10 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
 
 	switch (len) {
 	case WACOM_PKGLEN_TPC1FG:
-		return wacom_tpc_single_touch(wacom, len);
+		 return wacom_tpc_single_touch(wacom, len);
 
 	case WACOM_PKGLEN_TPC2FG:
-		return wacom_tpc_mt_touch(wacom);
+ 		return wacom_tpc_mt_touch(wacom);
 
 	default:
 		switch (data[0]) {
@@ -963,9 +894,6 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
 		case WACOM_REPORT_TPCST:
 			return wacom_tpc_single_touch(wacom, len);
 
-		case WACOM_REPORT_TPCMT:
-			return wacom_mt_touch(wacom);
-
 		case WACOM_REPORT_PENABLED:
 			return wacom_tpc_pen(wacom);
 		}
@@ -1245,7 +1173,6 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 
 	case TABLETPC:
 	case TABLETPC2FG:
-	case MTSCREEN:
 		sync = wacom_tpc_irq(wacom_wac, len);
 		break;
 
@@ -1319,8 +1246,7 @@ void wacom_setup_device_quirks(struct wacom_features *features)
 	/* these device have multiple inputs */
 	if (features->type == TABLETPC || features->type == TABLETPC2FG ||
 	    features->type == BAMBOO_PT || features->type == WIRELESS ||
-	    (features->type >= INTUOS5S && features->type <= INTUOS5L) ||
-	    features->type == MTSCREEN)
+	    (features->type >= INTUOS5S && features->type <= INTUOS5L))
 		features->quirks |= WACOM_QUIRK_MULTI_INPUT;
 
 	/* quirk for bamboo touch with 2 low res touches */
@@ -1351,8 +1277,8 @@ static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
        return (logical_max * 100) / physical_max;
 }
 
-int wacom_setup_input_capabilities(struct input_dev *input_dev,
-				   struct wacom_wac *wacom_wac)
+void wacom_setup_input_capabilities(struct input_dev *input_dev,
+				    struct wacom_wac *wacom_wac)
 {
 	struct wacom_features *features = &wacom_wac->features;
 	int i;
@@ -1548,18 +1474,8 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
 		break;
 
 	case TABLETPC2FG:
-	case MTSCREEN:
 		if (features->device_type == BTN_TOOL_FINGER) {
 
-			wacom_wac->slots = kmalloc(features->touch_max *
-							sizeof(int),
-						   GFP_KERNEL);
-			if (!wacom_wac->slots)
-				return -ENOMEM;
-
-			for (i = 0; i < features->touch_max; i++)
-				wacom_wac->slots[i] = -1;
-
 			input_mt_init_slots(input_dev, features->touch_max);
 			input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE,
 					0, MT_TOOL_MAX, 0, 0);
@@ -1645,7 +1561,6 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
 		}
 		break;
 	}
-	return 0;
 }
 
 static const struct wacom_features wacom_features_0x00 =
@@ -1878,9 +1793,6 @@ static const struct wacom_features wacom_features_0xE3 =
 	{ "Wacom ISDv4 E3",       WACOM_PKGLEN_TPC2FG,    26202, 16325,  255,
 	  0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
 	  .touch_max = 2 };
-static const struct wacom_features wacom_features_0xE5 =
-	{ "Wacom ISDv4 E5",       WACOM_PKGLEN_MTOUCH,    26202, 16325,  255,
-	  0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0xE6 =
 	{ "Wacom ISDv4 E6",       WACOM_PKGLEN_TPC2FG,    27760, 15694,  255,
 	  0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
@@ -2059,7 +1971,6 @@ const struct usb_device_id wacom_ids[] = {
 	{ USB_DEVICE_WACOM(0x9F) },
 	{ USB_DEVICE_WACOM(0xE2) },
 	{ USB_DEVICE_WACOM(0xE3) },
-	{ USB_DEVICE_WACOM(0xE5) },
 	{ USB_DEVICE_WACOM(0xE6) },
 	{ USB_DEVICE_WACOM(0xEC) },
 	{ USB_DEVICE_WACOM(0x47) },
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index 78fbd3f42009..321269c1ac4c 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -25,10 +25,6 @@
 #define WACOM_PKGLEN_BBTOUCH3	64
 #define WACOM_PKGLEN_BBPEN	10
 #define WACOM_PKGLEN_WIRELESS	32
-#define WACOM_PKGLEN_MTOUCH	62
-
-/* wacom data size per MT contact */
-#define WACOM_BYTES_PER_MT_PACKET	11
 
 /* device IDs */
 #define STYLUS_DEVICE_ID	0x02
@@ -45,7 +41,6 @@
 #define WACOM_REPORT_INTUOS5PAD		3
 #define WACOM_REPORT_TPC1FG		6
 #define WACOM_REPORT_TPC2FG		13
-#define WACOM_REPORT_TPCMT		13
 #define WACOM_REPORT_TPCHID		15
 #define WACOM_REPORT_TPCST		16
 
@@ -81,7 +76,6 @@ enum {
 	WACOM_MO,
 	TABLETPC,
 	TABLETPC2FG,
-	MTSCREEN,
 	MAX_TYPE
 };
 
@@ -124,8 +118,6 @@ struct wacom_wac {
 	struct input_dev *input;
 	int pid;
 	int battery_capacity;
-	int num_contacts_left;
-	int *slots;
 };
 
 #endif
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support"
  2012-06-14 21:23 ` [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support" Jonathan Nieder
@ 2012-06-14 23:51   ` Ping Cheng
  2012-06-15  0:27     ` Jonathan Nieder
  0 siblings, 1 reply; 15+ messages in thread
From: Ping Cheng @ 2012-06-14 23:51 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: dmitry.torokhov, Bjørn Mork, linux-input, Jason Gerecke,
	Chris Bagwell

On Thu, Jun 14, 2012 at 2:23 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> This reverts commit 1963518b9b1b8019d33b4b08deee6f873ffa2730.
>
> It was supposed to just add support for new MTSCREEN devices, but
> instead it significantly changed the code handling TABLETPC2FG and
> BAMBOO_PT.  That destroys debugability.  Back to the drawing board.
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> Hi,
>
> Ping Cheng wrote:
>
>> Main part of patch is adding support for a new Wacom MT touch
>> packet and labels these devices using MTSCREEN type.
>>
>> Other items of interest:
>
> Agh!
>
> A patch adding new hardware support should not touch existing support
> for other devices at the same time.  Especially not cosmetic changes.
>
> [1] has an analysis by Bjørn of why those unrelated changes are
> probably buggy,

I feel very bad about the issue. More testing should have been done
among us during the development. Since the patch was touched by more
than one people at linuxwacom.sf.net project, we most likely did not
test TPC2FG devices after last person's change.

> but I don't really care about that at the moment.  If
> it were a separate patch with a description explaining what it was
> supposed to do, the normal review process would take care of those
> things.  Piggy-backing onto another patch is just not a good idea.

You are right. But it would be hard to follow why we made the other
changes without putting them together, escpecially we had to exchange
ideas among developers due to personal and testing issues.

All in all, I am very sorry about the problem. But reverting back
isn't as easy as it sounds since we have many patches built on it now.
Using your patch requires us the same amount of time to test on other
devices, which does not help us move forward.

So, I propose we make a patch that fixes the issue upstream. Then
backport it to 3.2.18. Does this work for you?

Thank you.

Ping

> How about this patch (untested)?
>
> Thanks,
> Jonathan
>
> [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=55;bug=677164
>
>  drivers/input/tablet/wacom.h     |    4 +-
>  drivers/input/tablet/wacom_sys.c |   91 +++++++++++++++--------------------
>  drivers/input/tablet/wacom_wac.c |   99 ++------------------------------------
>  drivers/input/tablet/wacom_wac.h |    8 ---
>  4 files changed, 45 insertions(+), 157 deletions(-)
>
> diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
> index b79d45198d82..b4842d0e61dd 100644
> --- a/drivers/input/tablet/wacom.h
> +++ b/drivers/input/tablet/wacom.h
> @@ -135,6 +135,6 @@ extern const struct usb_device_id wacom_ids[];
>
>  void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
>  void wacom_setup_device_quirks(struct wacom_features *features);
> -int wacom_setup_input_capabilities(struct input_dev *input_dev,
> -                                  struct wacom_wac *wacom_wac);
> +void wacom_setup_input_capabilities(struct input_dev *input_dev,
> +                                   struct wacom_wac *wacom_wac);
>  #endif
> diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
> index cad5602d3ce4..a0cc46e5f13c 100644
> --- a/drivers/input/tablet/wacom_sys.c
> +++ b/drivers/input/tablet/wacom_sys.c
> @@ -320,10 +320,6 @@ static int wacom_parse_hid(struct usb_interface *intf,
>                                                        /* need to reset back */
>                                                        features->pktlen = WACOM_PKGLEN_TPC2FG;
>                                                }
> -
> -                                               if (features->type == MTSCREEN)
> -                                                       features->pktlen = WACOM_PKGLEN_MTOUCH;
> -
>                                                if (features->type == BAMBOO_PT) {
>                                                        /* need to reset back */
>                                                        features->pktlen = WACOM_PKGLEN_BBTOUCH;
> @@ -356,15 +352,18 @@ static int wacom_parse_hid(struct usb_interface *intf,
>                        case HID_USAGE_Y:
>                                if (usage == WCM_DESKTOP) {
>                                        if (finger) {
> -                                               int type = features->type;
> -
> -                                               if (type == TABLETPC2FG || type == MTSCREEN) {
> +                                               features->device_type = BTN_TOOL_FINGER;
> +                                               if (features->type == TABLETPC2FG) {
> +                                                       /* need to reset back */
> +                                                       features->pktlen = WACOM_PKGLEN_TPC2FG;
>                                                        features->y_max =
>                                                                get_unaligned_le16(&report[i + 3]);
>                                                        features->y_phy =
>                                                                get_unaligned_le16(&report[i + 6]);
>                                                        i += 7;
> -                                               } else if (type == BAMBOO_PT) {
> +                                               } else if (features->type == BAMBOO_PT) {
> +                                                       /* need to reset back */
> +                                                       features->pktlen = WACOM_PKGLEN_BBTOUCH;
>                                                        features->y_phy =
>                                                                get_unaligned_le16(&report[i + 3]);
>                                                        features->y_max =
> @@ -378,6 +377,10 @@ static int wacom_parse_hid(struct usb_interface *intf,
>                                                        i += 4;
>                                                }
>                                        } else if (pen) {
> +                                               /* penabled only accepts exact bytes of data */
> +                                               if (features->type == TABLETPC2FG)
> +                                                       features->pktlen = WACOM_PKGLEN_GRAPHIRE;
> +                                               features->device_type = BTN_TOOL_PEN;
>                                                features->y_max =
>                                                        get_unaligned_le16(&report[i + 3]);
>                                                i += 4;
> @@ -440,29 +443,22 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
>        if (!rep_data)
>                return error;
>
> -       /* ask to report Wacom data */
> -       if (features->device_type == BTN_TOOL_FINGER) {
> -               /* if it is an MT Tablet PC touch */
> -               if (features->type == TABLETPC2FG ||
> -                   features->type == MTSCREEN) {
> -                       do {
> -                               rep_data[0] = 3;
> -                               rep_data[1] = 4;
> -                               rep_data[2] = 0;
> -                               rep_data[3] = 0;
> -                               report_id = 3;
> -                               error = wacom_set_report(intf,
> -                                                        WAC_HID_FEATURE_REPORT,
> -                                                        report_id,
> -                                                        rep_data, 4, 1);
> -                               if (error >= 0)
> -                                       error = wacom_get_report(intf,
> -                                                       WAC_HID_FEATURE_REPORT,
> -                                                       report_id,
> -                                                       rep_data, 4, 1);
> -                       } while ((error < 0 || rep_data[1] != 4) &&
> -                                limit++ < WAC_MSG_RETRIES);
> -               }
> +       /* ask to report tablet data if it is MT Tablet PC or
> +        * not a Tablet PC */
> +       if (features->type == TABLETPC2FG) {
> +               do {
> +                       rep_data[0] = 3;
> +                       rep_data[1] = 4;
> +                       rep_data[2] = 0;
> +                       rep_data[3] = 0;
> +                       report_id = 3;
> +                       error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
> +                                                report_id, rep_data, 4, 1);
> +                       if (error >= 0)
> +                               error = wacom_get_report(intf,
> +                                               WAC_HID_FEATURE_REPORT,
> +                                               report_id, rep_data, 4, 1);
> +               } while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES);
>        } else if (features->type != TABLETPC &&
>                   features->type != WIRELESS &&
>                   features->device_type == BTN_TOOL_PEN) {
> @@ -484,7 +480,7 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
>  }
>
>  static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
> -                                        struct wacom_features *features)
> +               struct wacom_features *features)
>  {
>        int error = 0;
>        struct usb_host_interface *interface = intf->cur_altsetting;
> @@ -512,13 +508,10 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
>                }
>        }
>
> -       /* only devices that support touch need to retrieve the info */
> -       if (features->type != TABLETPC &&
> -           features->type != TABLETPC2FG &&
> -           features->type != BAMBOO_PT &&
> -           features->type != MTSCREEN) {
> +       /* only Tablet PCs and Bamboo P&T need to retrieve the info */
> +       if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) &&
> +           (features->type != BAMBOO_PT))
>                goto out;
> -       }
>
>        error = usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc);
>        if (error) {
> @@ -990,10 +983,8 @@ static int wacom_register_input(struct wacom *wacom)
>        int error;
>
>        input_dev = input_allocate_device();
> -       if (!input_dev) {
> -               error = -ENOMEM;
> -               goto fail1;
> -       }
> +       if (!input_dev)
> +               return -ENOMEM;
>
>        input_dev->name = wacom_wac->name;
>        input_dev->dev.parent = &intf->dev;
> @@ -1003,20 +994,14 @@ static int wacom_register_input(struct wacom *wacom)
>        input_set_drvdata(input_dev, wacom);
>
>        wacom_wac->input = input_dev;
> -       error = wacom_setup_input_capabilities(input_dev, wacom_wac);
> -       if (error)
> -               goto fail1;
> +       wacom_setup_input_capabilities(input_dev, wacom_wac);
>
>        error = input_register_device(input_dev);
> -       if (error)
> -               goto fail2;
> +       if (error) {
> +               input_free_device(input_dev);
> +               wacom_wac->input = NULL;
> +       }
>
> -       return 0;
> -
> -fail2:
> -       input_free_device(input_dev);
> -       wacom_wac->input = NULL;
> -fail1:
>        return error;
>  }
>
> diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
> index 004bc1bb1544..5b31418b416b 100644
> --- a/drivers/input/tablet/wacom_wac.c
> +++ b/drivers/input/tablet/wacom_wac.c
> @@ -776,72 +776,6 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
>        return 1;
>  }
>
> -static int find_slot_from_contactid(struct wacom_wac *wacom, int contactid)
> -{
> -       int touch_max = wacom->features.touch_max;
> -       int i;
> -
> -       if (!wacom->slots)
> -               return -1;
> -
> -       for (i = 0; i < touch_max; ++i) {
> -               if (wacom->slots[i] == contactid)
> -                       return i;
> -       }
> -       for (i = 0; i < touch_max; ++i) {
> -               if (wacom->slots[i] == -1)
> -                       return i;
> -       }
> -       return -1;
> -}
> -
> -static int wacom_mt_touch(struct wacom_wac *wacom)
> -{
> -       struct input_dev *input = wacom->input;
> -       char *data = wacom->data;
> -       int i;
> -       int current_num_contacts = data[2];
> -       int contacts_to_send = 0;
> -
> -       /*
> -        * First packet resets the counter since only the first
> -        * packet in series will have non-zero current_num_contacts.
> -        */
> -       if (current_num_contacts)
> -               wacom->num_contacts_left = current_num_contacts;
> -
> -       /* There are at most 5 contacts per packet */
> -       contacts_to_send = min(5, wacom->num_contacts_left);
> -
> -       for (i = 0; i < contacts_to_send; i++) {
> -               int offset = (WACOM_BYTES_PER_MT_PACKET * i) + 3;
> -               bool touch = data[offset] & 0x1;
> -               int id = le16_to_cpup((__le16 *)&data[offset + 1]);
> -               int slot = find_slot_from_contactid(wacom, id);
> -
> -               if (slot < 0)
> -                       continue;
> -
> -               input_mt_slot(input, slot);
> -               input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
> -               if (touch) {
> -                       int x = le16_to_cpup((__le16 *)&data[offset + 7]);
> -                       int y = le16_to_cpup((__le16 *)&data[offset + 9]);
> -                       input_report_abs(input, ABS_MT_POSITION_X, x);
> -                       input_report_abs(input, ABS_MT_POSITION_Y, y);
> -               }
> -               wacom->slots[slot] = touch ? id : -1;
> -       }
> -
> -       input_mt_report_pointer_emulation(input, true);
> -
> -       wacom->num_contacts_left -= contacts_to_send;
> -       if (wacom->num_contacts_left < 0)
> -               wacom->num_contacts_left = 0;
> -
> -       return 1;
> -}
> -
>  static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
>  {
>        struct input_dev *input = wacom->input;
> @@ -880,9 +814,6 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
>        bool prox;
>        int x = 0, y = 0;
>
> -       if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
> -               return 0;
> -
>        if (!wacom->shared->stylus_in_proximity) {
>                if (len == WACOM_PKGLEN_TPC1FG) {
>                        prox = data[0] & 0x01;
> @@ -951,10 +882,10 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
>
>        switch (len) {
>        case WACOM_PKGLEN_TPC1FG:
> -               return wacom_tpc_single_touch(wacom, len);
> +                return wacom_tpc_single_touch(wacom, len);
>
>        case WACOM_PKGLEN_TPC2FG:
> -               return wacom_tpc_mt_touch(wacom);
> +               return wacom_tpc_mt_touch(wacom);
>
>        default:
>                switch (data[0]) {
> @@ -963,9 +894,6 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
>                case WACOM_REPORT_TPCST:
>                        return wacom_tpc_single_touch(wacom, len);
>
> -               case WACOM_REPORT_TPCMT:
> -                       return wacom_mt_touch(wacom);
> -
>                case WACOM_REPORT_PENABLED:
>                        return wacom_tpc_pen(wacom);
>                }
> @@ -1245,7 +1173,6 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
>
>        case TABLETPC:
>        case TABLETPC2FG:
> -       case MTSCREEN:
>                sync = wacom_tpc_irq(wacom_wac, len);
>                break;
>
> @@ -1319,8 +1246,7 @@ void wacom_setup_device_quirks(struct wacom_features *features)
>        /* these device have multiple inputs */
>        if (features->type == TABLETPC || features->type == TABLETPC2FG ||
>            features->type == BAMBOO_PT || features->type == WIRELESS ||
> -           (features->type >= INTUOS5S && features->type <= INTUOS5L) ||
> -           features->type == MTSCREEN)
> +           (features->type >= INTUOS5S && features->type <= INTUOS5L))
>                features->quirks |= WACOM_QUIRK_MULTI_INPUT;
>
>        /* quirk for bamboo touch with 2 low res touches */
> @@ -1351,8 +1277,8 @@ static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
>        return (logical_max * 100) / physical_max;
>  }
>
> -int wacom_setup_input_capabilities(struct input_dev *input_dev,
> -                                  struct wacom_wac *wacom_wac)
> +void wacom_setup_input_capabilities(struct input_dev *input_dev,
> +                                   struct wacom_wac *wacom_wac)
>  {
>        struct wacom_features *features = &wacom_wac->features;
>        int i;
> @@ -1548,18 +1474,8 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
>                break;
>
>        case TABLETPC2FG:
> -       case MTSCREEN:
>                if (features->device_type == BTN_TOOL_FINGER) {
>
> -                       wacom_wac->slots = kmalloc(features->touch_max *
> -                                                       sizeof(int),
> -                                                  GFP_KERNEL);
> -                       if (!wacom_wac->slots)
> -                               return -ENOMEM;
> -
> -                       for (i = 0; i < features->touch_max; i++)
> -                               wacom_wac->slots[i] = -1;
> -
>                        input_mt_init_slots(input_dev, features->touch_max);
>                        input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE,
>                                        0, MT_TOOL_MAX, 0, 0);
> @@ -1645,7 +1561,6 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
>                }
>                break;
>        }
> -       return 0;
>  }
>
>  static const struct wacom_features wacom_features_0x00 =
> @@ -1878,9 +1793,6 @@ static const struct wacom_features wacom_features_0xE3 =
>        { "Wacom ISDv4 E3",       WACOM_PKGLEN_TPC2FG,    26202, 16325,  255,
>          0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
>          .touch_max = 2 };
> -static const struct wacom_features wacom_features_0xE5 =
> -       { "Wacom ISDv4 E5",       WACOM_PKGLEN_MTOUCH,    26202, 16325,  255,
> -         0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
>  static const struct wacom_features wacom_features_0xE6 =
>        { "Wacom ISDv4 E6",       WACOM_PKGLEN_TPC2FG,    27760, 15694,  255,
>          0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
> @@ -2059,7 +1971,6 @@ const struct usb_device_id wacom_ids[] = {
>        { USB_DEVICE_WACOM(0x9F) },
>        { USB_DEVICE_WACOM(0xE2) },
>        { USB_DEVICE_WACOM(0xE3) },
> -       { USB_DEVICE_WACOM(0xE5) },
>        { USB_DEVICE_WACOM(0xE6) },
>        { USB_DEVICE_WACOM(0xEC) },
>        { USB_DEVICE_WACOM(0x47) },
> diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
> index 78fbd3f42009..321269c1ac4c 100644
> --- a/drivers/input/tablet/wacom_wac.h
> +++ b/drivers/input/tablet/wacom_wac.h
> @@ -25,10 +25,6 @@
>  #define WACOM_PKGLEN_BBTOUCH3  64
>  #define WACOM_PKGLEN_BBPEN     10
>  #define WACOM_PKGLEN_WIRELESS  32
> -#define WACOM_PKGLEN_MTOUCH    62
> -
> -/* wacom data size per MT contact */
> -#define WACOM_BYTES_PER_MT_PACKET      11
>
>  /* device IDs */
>  #define STYLUS_DEVICE_ID       0x02
> @@ -45,7 +41,6 @@
>  #define WACOM_REPORT_INTUOS5PAD                3
>  #define WACOM_REPORT_TPC1FG            6
>  #define WACOM_REPORT_TPC2FG            13
> -#define WACOM_REPORT_TPCMT             13
>  #define WACOM_REPORT_TPCHID            15
>  #define WACOM_REPORT_TPCST             16
>
> @@ -81,7 +76,6 @@ enum {
>        WACOM_MO,
>        TABLETPC,
>        TABLETPC2FG,
> -       MTSCREEN,
>        MAX_TYPE
>  };
>
> @@ -124,8 +118,6 @@ struct wacom_wac {
>        struct input_dev *input;
>        int pid;
>        int battery_capacity;
> -       int num_contacts_left;
> -       int *slots;
>  };
>
>  #endif
> --
> 1.7.10.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support"
  2012-06-14 23:51   ` Ping Cheng
@ 2012-06-15  0:27     ` Jonathan Nieder
  2012-06-15 19:08       ` Ping Cheng
  0 siblings, 1 reply; 15+ messages in thread
From: Jonathan Nieder @ 2012-06-15  0:27 UTC (permalink / raw)
  To: Ping Cheng
  Cc: dmitry.torokhov, Bjørn Mork, linux-input, Jason Gerecke,
	Chris Bagwell

Ping Cheng wrote:

> I feel very bad about the issue. More testing should have been done
> among us during the development. Since the patch was touched by more
> than one people at linuxwacom.sf.net project, we most likely did not
> test TPC2FG devices after last person's change.

It's not really about testing.  A patch adding MTSCREEN support simply
should not touch the non-MTSCREEN cases at all.  It can make perfect
sense to have some preparatory changes that affect other devices, as
earlier patches in the same series.

And I don't think it's your fault --- others on the linux-input@ list
could have caught it.

[...]
> All in all, I am very sorry about the problem. But reverting back
> isn't as easy as it sounds since we have many patches built on it now.
> Using your patch requires us the same amount of time to test on other
> devices, which does not help us move forward.
>
> So, I propose we make a patch that fixes the issue upstream.

Yeah, that works for me.  But please be more careful in the future.

Thanks,
Jonathan

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

* Re: [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support"
  2012-06-15  0:27     ` Jonathan Nieder
@ 2012-06-15 19:08       ` Ping Cheng
  2012-06-16  3:39         ` Jonathan Nieder
                           ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Ping Cheng @ 2012-06-15 19:08 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: dmitry.torokhov, Bjørn Mork, linux-input, Jason Gerecke,
	Chris Bagwell

On Thu, Jun 14, 2012 at 5:27 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Ping Cheng wrote:
>
>> I feel very bad about the issue. More testing should have been done
>> among us during the development. Since the patch was touched by more
>> than one people at linuxwacom.sf.net project, we most likely did not
>> test TPC2FG devices after last person's change.
>
> It's not really about testing.  A patch adding MTSCREEN support simply

Here is an update on my testing (for hardware, I have to test to be
sure). The result shows driver in upstream and 3.2.20 both work with
TPC2FG.

I downloaded, built and installed 3.5.-rc2 and 3.2.20 from kernel.org
without changing anything in the source. 3.5.-rc2 works all right. But
I can not boot 3.2.20 on my system (the error has nothing to do with
wacom driver). I didn't waste my time to fix 3.2.20 since we only care
about Wacom driver now. I copied wacom driver from 3.2.20 to 3.5.-rc2
source and built there. Replaced wacom.ko for 3.5.-rc2 with the driver
built from 3.2.20 code. It also works.

Then, I built the driver from input-wacom-0.13.0 for 3.5.-rc2.
Everything built fine, no warnings. But when I load the driver, it did
not find the device. I need more time to figure out the root cause. We
most likely need to introduce a new base version for later kernels.
2.6.38 is too old.

Since this issue doesn't affect upstream, let's bring the discussion
to linuxwacom.sf.net.

Thank you for the heads up and suggestions. We'll sure be careful in the future.

Ping

> should not touch the non-MTSCREEN cases at all.  It can make perfect
> sense to have some preparatory changes that affect other devices, as
> earlier patches in the same series.
>
> And I don't think it's your fault --- others on the linux-input@ list
> could have caught it.
>
> [...]
>> All in all, I am very sorry about the problem. But reverting back
>> isn't as easy as it sounds since we have many patches built on it now.
>> Using your patch requires us the same amount of time to test on other
>> devices, which does not help us move forward.
>>
>> So, I propose we make a patch that fixes the issue upstream.
>
> Yeah, that works for me.  But please be more careful in the future.
>
> Thanks,
> Jonathan
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support"
  2012-06-15 19:08       ` Ping Cheng
@ 2012-06-16  3:39         ` Jonathan Nieder
  2012-06-16  4:01         ` Jonathan Nieder
  2012-06-16 22:25         ` Jonathan Nieder
  2 siblings, 0 replies; 15+ messages in thread
From: Jonathan Nieder @ 2012-06-16  3:39 UTC (permalink / raw)
  To: Ping Cheng
  Cc: dmitry.torokhov, Bjørn Mork, linux-input, Jason Gerecke,
	Chris Bagwell

Ping Cheng wrote:
> On Thu, Jun 14, 2012 at 5:27 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:

>> It's not really about testing.  A patch adding MTSCREEN support simply
>
> Here is an update on my testing (for hardware, I have to test to be
> sure). The result shows driver in upstream and 3.2.20 both work with
> TPC2FG.

I will ask Nils to test 3.5-rc2 or newer.  For reference, he
reproduced trouble (the driver rejecting his tablet) using 3.4.2 with
the following patches on top:

  9fee619505bd Input: wacom - add basic Intuos5 support
  f860e581fd47 Input: wacom - add Intuos5 Touch Ring/ExpressKey support
  9b5b95dd516a Input: wacom - add Intuos5 Touch Ring LED support
  ae584ca47328 Input: wacom - add Intuos5 multitouch sensor support
  f393ee2b814e Input: wacom - retrieve maximum number of touch points
  1963518b9b1b Input: wacom - add 0xE5 (MT device) support
  a882c932a628 Input: wacom - return proper error if
               usb_get_extra_descriptor() fails

His machine is a Thinkpad x220t.  The built-in tablet has USB id
056a:00e6.  3.4.2 without those patches works fine.  (More details at [1].)

I prefer to start with making sure mainline works well first, and then
I'll be happy to work with you on backporting the current driver to
3.2-based kernels if you'd like.

Thanks again for your help,
Jonathan

[1] http://bugs.debian.org/677164
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support"
  2012-06-15 19:08       ` Ping Cheng
  2012-06-16  3:39         ` Jonathan Nieder
@ 2012-06-16  4:01         ` Jonathan Nieder
  2012-06-19  0:06           ` Ping Cheng
  2012-06-16 22:25         ` Jonathan Nieder
  2 siblings, 1 reply; 15+ messages in thread
From: Jonathan Nieder @ 2012-06-16  4:01 UTC (permalink / raw)
  To: Ping Cheng
  Cc: dmitry.torokhov, Bjørn Mork, linux-input, Jason Gerecke,
	Chris Bagwell

Ping Cheng wrote:

> I downloaded, built and installed 3.5.-rc2 and 3.2.20 from kernel.org
> without changing anything in the source. 3.5.-rc2 works all right. But
> I can not boot 3.2.20 on my system (the error has nothing to do with
> wacom driver).

By the way, if you have time to describe the boot failure in more
detail to stable@vger.kernel.org (feel free to cc me), that would be
very useful.

Thanks much,
Jonathan

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

* Re: [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support"
  2012-06-15 19:08       ` Ping Cheng
  2012-06-16  3:39         ` Jonathan Nieder
  2012-06-16  4:01         ` Jonathan Nieder
@ 2012-06-16 22:25         ` Jonathan Nieder
  2012-06-17  0:43           ` Chris Bagwell
  2 siblings, 1 reply; 15+ messages in thread
From: Jonathan Nieder @ 2012-06-16 22:25 UTC (permalink / raw)
  To: Ping Cheng
  Cc: dmitry.torokhov, Bjørn Mork, linux-input, Jason Gerecke,
	Chris Bagwell, Nils Kanning

Hi Ping,

Ping Cheng wrote:

> Here is an update on my testing (for hardware, I have to test to be
> sure). The result shows driver in upstream and 3.2.20 both work with
> TPC2FG.

Again, thanks much for this.

Nils (cc-ed) tested Linus's "master" branch (3.5-rc2+) this morning.
The outcome:

| I built the kernel from the git repository as you described. The tablet
| does not work. 
|
| lsusb -t gives:
| Port 5: Dev 5, If 0, Class=HID, Driver=, 12M
|
| The dmesg output is attached. The two input files mentioned in this
| file, which are related to the wacom tablet, are not there after
| booting.

Logs at [1].

For comparison, v3.4.2 works fine.  v3.4.2 plus some unrelated
Intuous5 support patches (9fee619505bd + f860e581fd47 + 9b5b95dd516a +
ae584ca47328) also works fine.

Nils also tested v3.4.2 plus the following patch.

  f393ee2b814e Input: wacom - retrieve maximum number of touch points
               from the HID usage table when it is supported

The exact patch used is at [2].  That produced:

| Linux video capture interface: v2.00
| ------------[ cut here ]------------
| kernel BUG at mm/slab.c:505!
| invalid opcode: 0000 [#1] SMP 
[...]
| Pid: 579, comm: modprobe Not tainted 3.4.2-amd64 #1 LENOVO 42992QG/42992QG
[...]
| Call Trace:
|  [<ffffffff810ef84e>] ? kfree+0x50/0x6c
|  [<ffffffffa04029cd>] ? wacom_probe+0x52c/0x957 [wacom]
|  [<ffffffffa006866b>] ? usb_probe_interface+0xf2/0x15d [usbcore]

which is "BUG_ON(!PageSlab(page))" in page_get_cache() and represents
a free of an invalid pointer.

Full log at [3].

Known problem?  Any ideas for tracking it down?

Thanks again and hope that helps,
Jonathan

[1] http://bugs.debian.org/677164#87
[2] http://bugs.debian.org/677164#50
[3] http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=77;filename=dmesg_0001;att=1;bug=677164

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

* Re: [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support"
  2012-06-16 22:25         ` Jonathan Nieder
@ 2012-06-17  0:43           ` Chris Bagwell
  2012-06-17 21:08             ` Nils Kanning
  0 siblings, 1 reply; 15+ messages in thread
From: Chris Bagwell @ 2012-06-17  0:43 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: Ping Cheng, dmitry.torokhov, Bjørn Mork, linux-input,
	Jason Gerecke, Nils Kanning

On Sat, Jun 16, 2012 at 5:25 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Hi Ping,
>
> Ping Cheng wrote:
>
>> Here is an update on my testing (for hardware, I have to test to be
>> sure). The result shows driver in upstream and 3.2.20 both work with
>> TPC2FG.
>
> Again, thanks much for this.
>
> Nils (cc-ed) tested Linus's "master" branch (3.5-rc2+) this morning.
> The outcome:
>
> | I built the kernel from the git repository as you described. The tablet
> | does not work.
> |
> | lsusb -t gives:
> | Port 5: Dev 5, If 0, Class=HID, Driver=, 12M
> |
> | The dmesg output is attached. The two input files mentioned in this
> | file, which are related to the wacom tablet, are not there after
> | booting.
>
> Logs at [1].
>
> For comparison, v3.4.2 works fine.  v3.4.2 plus some unrelated
> Intuous5 support patches (9fee619505bd + f860e581fd47 + 9b5b95dd516a +
> ae584ca47328) also works fine.
>
> Nils also tested v3.4.2 plus the following patch.
>
>  f393ee2b814e Input: wacom - retrieve maximum number of touch points
>               from the HID usage table when it is supported
>
> The exact patch used is at [2].  That produced:
>
> | Linux video capture interface: v2.00
> | ------------[ cut here ]------------
> | kernel BUG at mm/slab.c:505!
> | invalid opcode: 0000 [#1] SMP
> [...]
> | Pid: 579, comm: modprobe Not tainted 3.4.2-amd64 #1 LENOVO 42992QG/42992QG
> [...]
> | Call Trace:
> |  [<ffffffff810ef84e>] ? kfree+0x50/0x6c
> |  [<ffffffffa04029cd>] ? wacom_probe+0x52c/0x957 [wacom]
> |  [<ffffffffa006866b>] ? usb_probe_interface+0xf2/0x15d [usbcore]
>
> which is "BUG_ON(!PageSlab(page))" in page_get_cache() and represents
> a free of an invalid pointer.
>
> Full log at [3].
>
> Known problem?  Any ideas for tracking it down?
>
> Thanks again and hope that helps,
> Jonathan
>
> [1] http://bugs.debian.org/677164#87
> [2] http://bugs.debian.org/677164#50
> [3] http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=77;filename=dmesg_0001;att=1;bug=677164

Its not obvious to me yet why patch [2] would cause the crash in log
[1].  The only reason I see for wacom_probe() to be calling kfree() is
in error case were its trying to unload the interface.  Since the
dmesg shows Pen loading, this is most likely crashing while processing
the Finger/touch interface.

That makes some sense because patch [2] adds logic that should only be
invoked on the touch interface.

Can you "rmmod wacom" and this run "lsusb -vvv" and email me directly
or post to debian bug report the section for Wacom?  I'd like to look
at HID report for MAXCONTACTS and other items for touch interface.  In
this part of patch [2]:

+			case HID_USAGE_CONTACTMAX:
+				wacom_retrieve_report_data(intf, features);
+				i++;
+				break;

that i++ may not be needed and may cause it to ignore an important
piece of data on this 0xE6 device.

Thats my only guess right now.  From here, you may need to sprinkle
the wacom_probe() function with a bunch of printk()'s to see exactly
which part is failing and requesting to jump to "fail1:" label.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support"
  2012-06-17  0:43           ` Chris Bagwell
@ 2012-06-17 21:08             ` Nils Kanning
  2012-06-18  2:39               ` Chris Bagwell
  0 siblings, 1 reply; 15+ messages in thread
From: Nils Kanning @ 2012-06-17 21:08 UTC (permalink / raw)
  To: Chris Bagwell
  Cc: Jonathan Nieder, Ping Cheng, dmitry.torokhov, Bjørn Mork,
	linux-input, Jason Gerecke


[-- Attachment #1.1: Type: text/plain, Size: 648 bytes --]

On Sat, 2012-06-16 at 19:43 -0500, Chris Bagwell wrote:
> > The exact patch used is at [2].  That produced:

> Can you "rmmod wacom" and this run "lsusb -vvv" and email me directly
> or post to debian bug report the section for Wacom?  I'd like to look

With this kernel I could not remove the wacom module using "rmmod
wacom" (the options -f or -w do not help). Furthermore "lsusb -vvv"
hangs at the wacom device and does not produce more then:
Bus 002 Device 004: ID 056a:00e6 Wacom Co., Ltd

The output of "lsusb -vvv" using the Debian kernel from linux-image
3.2.17 and after doing "rmmod wacom" is in the attached file.

Nils


[-- Attachment #1.2: lsusb --]
[-- Type: text/plain, Size: 28606 bytes --]

Bus 002 Device 004: ID 056a:00e6 Wacom Co., Ltd 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x056a Wacom Co., Ltd
  idProduct          0x00e6 
  bcdDevice            1.39
  iManufacturer           1 Tablet
  iProduct                2 ISD-V4
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           59
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     181
          Report Descriptor: (length is 181)
            Item(Global): Usage Page, data= [ 0x0d ] 13
                            Digitizer
            Item(Local ): Usage, data= [ 0x02 ] 2
                            Pen
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Global): Report ID, data= [ 0x02 ] 2
            Item(Local ): Usage, data= [ 0x20 ] 32
                            Stylus
            Item(Main  ): Collection, data= [ 0x00 ] 0
                            Physical
            Item(Local ): Usage, data= [ 0x42 ] 66
                            Tip Switch
            Item(Local ): Usage, data= [ 0x44 ] 68
                            Barrel Switch
            Item(Local ): Usage, data= [ 0x45 ] 69
                            Eraser
            Item(Local ): Usage, data= [ 0x3c ] 60
                            Invert
            Item(Local ): Usage, data= [ 0x00 ] 0
                            Undefined
            Item(Local ): Usage, data= [ 0x32 ] 50
                            In Range
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0x01 ] 1
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x06 ] 6
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Input, data= [ 0x03 ] 3
                            Constant Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Usage Page, data= [ 0x01 ] 1
                            Generic Desktop Controls
            Item(Local ): Usage, data= [ 0x30 ] 48
                            Direction-X
            Item(Global): Logical Maximum, data= [ 0x70 0x6c ] 27760
            Item(Global): Physical Maximum, data= [ 0x70 0x6c ] 27760
            Item(Global): Unit, data= [ 0x11 ] 17
                            System: SI Linear, Unit: Centimeter
            Item(Global): Unit Exponent, data= [ 0x0d ] 13
                            Unit Exponent: 13
            Item(Global): Report Size, data= [ 0x10 ] 16
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x31 ] 49
                            Direction-Y
            Item(Global): Logical Maximum, data= [ 0x4e 0x3d ] 15694
            Item(Global): Physical Maximum, data= [ 0x4e 0x3d ] 15694
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Physical Maximum, data= [ 0x00 ] 0
            Item(Global): Unit, data= [ 0x00 ] 0
                            System: None, Unit: (None)
            Item(Global): Unit Exponent, data= [ 0x00 ] 0
                            Unit Exponent: 0
            Item(Global): Usage Page, data= [ 0x0d ] 13
                            Digitizer
            Item(Local ): Usage, data= [ 0x30 ] 48
                            Tip Pressure
            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
            Item(Global): Usage Page, data= [ 0x00 0xff ] 65280
                            (null)
            Item(Local ): Usage, data= [ 0x00 ] 0
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Global): Report ID, data= [ 0x11 ] 17
            Item(Global): Usage Page, data= [ 0x0d ] 13
                            Digitizer
            Item(Local ): Usage, data= [ 0x20 ] 32
                            Stylus
            Item(Main  ): Collection, data= [ 0x00 ] 0
                            Physical
            Item(Local ): Usage, data= [ 0x42 ] 66
                            Tip Switch
            Item(Local ): Usage, data= [ 0x44 ] 68
                            Barrel Switch
            Item(Local ): Usage, data= [ 0x45 ] 69
                            Eraser
            Item(Local ): Usage, data= [ 0x3c ] 60
                            Invert
            Item(Local ): Usage, data= [ 0x00 ] 0
                            Undefined
            Item(Local ): Usage, data= [ 0x32 ] 50
                            In Range
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0x01 ] 1
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x06 ] 6
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Input, data= [ 0x03 ] 3
                            Constant Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Usage Page, data= [ 0x01 ] 1
                            Generic Desktop Controls
            Item(Local ): Usage, data= [ 0x30 ] 48
                            Direction-X
            Item(Global): Logical Maximum, data= [ 0x70 0x6c ] 27760
            Item(Global): Physical Maximum, data= [ 0x70 0x6c ] 27760
            Item(Global): Unit, data= [ 0x11 ] 17
                            System: SI Linear, Unit: Centimeter
            Item(Global): Unit Exponent, data= [ 0x0d ] 13
                            Unit Exponent: 13
            Item(Global): Report Size, data= [ 0x10 ] 16
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x31 ] 49
                            Direction-Y
            Item(Global): Logical Maximum, data= [ 0x4e 0x3d ] 15694
            Item(Global): Physical Maximum, data= [ 0x4e 0x3d ] 15694
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Physical Maximum, data= [ 0x00 ] 0
            Item(Global): Unit, data= [ 0x00 ] 0
                            System: None, Unit: (None)
            Item(Global): Unit Exponent, data= [ 0x00 ] 0
                            Unit Exponent: 0
            Item(Global): Usage Page, data= [ 0x0d ] 13
                            Digitizer
            Item(Local ): Usage, data= [ 0x30 ] 48
                            Tip Pressure
            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Local ): Usage, data= [ 0x00 ] 0
                            Undefined
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x03 ] 3
            Item(Main  ): Feature, data= [ 0x12 ] 18
                            Data Variable Absolute No_Wrap Non_Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               7
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     357
          Report Descriptor: (length is 357)
            Item(Global): Usage Page, data= [ 0x0d ] 13
                            Digitizer
            Item(Local ): Usage, data= [ 0x04 ] 4
                            Touch Screen
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Global): Report ID, data= [ 0x0c ] 12
            Item(Local ): Usage, data= [ 0x22 ] 34
                            Finger
            Item(Main  ): Collection, data= [ 0x00 ] 0
                            Physical
            Item(Local ): Usage, data= [ 0x42 ] 66
                            Tip Switch
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0x01 ] 1
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x32 ] 50
                            In Range
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x47 ] 71
                            Confidence
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report Count, data= [ 0x05 ] 5
            Item(Main  ): Input, data= [ 0x03 ] 3
                            Constant Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Usage Page, data= [ 0x01 ] 1
                            Generic Desktop Controls
            Item(Local ): Usage, data= [ 0x30 ] 48
                            Direction-X
            Item(Global): Logical Maximum, data= [ 0xd8 0x0a ] 2776
            Item(Global): Physical Maximum, data= [ 0x70 0x6c ] 27760
            Item(Global): Unit, data= [ 0x11 ] 17
                            System: SI Linear, Unit: Centimeter
            Item(Global): Unit Exponent, data= [ 0x0d ] 13
                            Unit Exponent: 13
            Item(Global): Report Size, data= [ 0x10 ] 16
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x31 ] 49
                            Direction-Y
            Item(Global): Logical Maximum, data= [ 0x21 0x06 ] 1569
            Item(Global): Physical Maximum, data= [ 0x4e 0x3d ] 15694
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Physical Maximum, data= [ 0x00 ] 0
            Item(Global): Unit, data= [ 0x00 ] 0
                            System: None, Unit: (None)
            Item(Global): Unit Exponent, data= [ 0x00 ] 0
                            Unit Exponent: 0
            Item(Global): Usage Page, data= [ 0x0d ] 13
                            Digitizer
            Item(Local ): Usage, data= [ 0x48 ] 72
                            Width
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x49 ] 73
                            Height
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x51 ] 81
                            Contact ID
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x55 ] 85
                            Maximum Contact Number
            Item(Main  ): Feature, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
            Item(Global): Usage Page, data= [ 0x00 0xff ] 65280
                            (null)
            Item(Local ): Usage, data= [ 0x01 ] 1
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Global): Report ID, data= [ 0x0d ] 13
            Item(Global): Usage Page, data= [ 0x0d ] 13
                            Digitizer
            Item(Local ): Usage, data= [ 0x22 ] 34
                            Finger
            Item(Main  ): Collection, data= [ 0x00 ] 0
                            Physical
            Item(Local ): Usage, data= [ 0x42 ] 66
                            Tip Switch
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0x01 ] 1
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x04 ] 4
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report Count, data= [ 0x04 ] 4
            Item(Main  ): Input, data= [ 0x03 ] 3
                            Constant Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Usage Page, data= [ 0x01 ] 1
                            Generic Desktop Controls
            Item(Local ): Usage, data= [ 0x30 ] 48
                            Direction-X
            Item(Global): Logical Maximum, data= [ 0xd8 0x0a ] 2776
            Item(Global): Physical Maximum, data= [ 0x70 0x6c ] 27760
            Item(Global): Unit, data= [ 0x11 ] 17
                            System: SI Linear, Unit: Centimeter
            Item(Global): Unit Exponent, data= [ 0x0d ] 13
                            Unit Exponent: 13
            Item(Global): Report Size, data= [ 0x10 ] 16
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x31 ] 49
                            Direction-Y
            Item(Global): Logical Maximum, data= [ 0x21 0x06 ] 1569
            Item(Global): Physical Maximum, data= [ 0x4e 0x3d ] 15694
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Physical Maximum, data= [ 0x00 ] 0
            Item(Global): Unit, data= [ 0x00 ] 0
                            System: None, Unit: (None)
            Item(Global): Unit Exponent, data= [ 0x00 ] 0
                            Unit Exponent: 0
            Item(Global): Usage Page, data= [ 0x0d ] 13
                            Digitizer
            Item(Local ): Usage, data= [ 0x48 ] 72
                            Width
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x49 ] 73
                            Height
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Global): Report ID, data= [ 0x02 ] 2
            Item(Local ): Usage, data= [ 0x00 ] 0
                            Undefined
            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Main  ): Feature, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report ID, data= [ 0x03 ] 3
            Item(Local ): Usage, data= [ 0x00 ] 0
                            Undefined
            Item(Global): Report Count, data= [ 0x03 ] 3
            Item(Main  ): Feature, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report ID, data= [ 0x05 ] 5
            Item(Local ): Usage, data= [ 0x00 ] 0
                            Undefined
            Item(Global): Report Count, data= [ 0x08 ] 8
            Item(Main  ): Feature, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report ID, data= [ 0x06 ] 6
            Item(Local ): Usage, data= [ 0x00 ] 0
                            Undefined
            Item(Global): Report Count, data= [ 0x08 ] 8
            Item(Main  ): Feature, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Global): Usage Page, data= [ 0x0d ] 13
                            Digitizer
            Item(Local ): Usage, data= [ 0x0e ] 14
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Global): Report ID, data= [ 0x0e ] 14
            Item(Local ): Usage, data= [ 0x52 ] 82
                            Input Mode
            Item(Local ): Usage, data= [ 0x53 ] 83
                            Device Index
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Feature, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Global): Usage Page, data= [ 0x01 ] 1
                            Generic Desktop Controls
            Item(Local ): Usage, data= [ 0x02 ] 2
                            Mouse
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Global): Report ID, data= [ 0x0f ] 15
            Item(Local ): Usage, data= [ 0x01 ] 1
                            Pointer
            Item(Main  ): Collection, data= [ 0x00 ] 0
                            Physical
            Item(Global): Usage Page, data= [ 0x09 ] 9
                            Buttons
            Item(Local ): Usage Minimum, data= [ 0x01 ] 1
                            Button 1 (Primary)
            Item(Local ): Usage Maximum, data= [ 0x02 ] 2
                            Button 2 (Secondary)
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Global): Report Size, data= [ 0x06 ] 6
            Item(Main  ): Input, data= [ 0x03 ] 3
                            Constant Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Usage Page, data= [ 0x01 ] 1
                            Generic Desktop Controls
            Item(Local ): Usage, data= [ 0x30 ] 48
                            Direction-X
            Item(Local ): Usage, data= [ 0x31 ] 49
                            Direction-Y
            Item(Global): Logical Maximum, data= [ 0xff 0x7f ] 32767
            Item(Global): Report Size, data= [ 0x10 ] 16
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
            Item(Global): Usage Page, data= [ 0x0d ] 13
                            Digitizer
            Item(Local ): Usage, data= [ 0x04 ] 4
                            Touch Screen
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Global): Report ID, data= [ 0x10 ] 16
            Item(Local ): Usage, data= [ 0x22 ] 34
                            Finger
            Item(Main  ): Collection, data= [ 0x00 ] 0
                            Physical
            Item(Local ): Usage, data= [ 0x42 ] 66
                            Tip Switch
            Item(Local ): Usage, data= [ 0x32 ] 50
                            In Range
            Item(Global): Logical Minimum, data= [ 0x00 ] 0
            Item(Global): Logical Maximum, data= [ 0x01 ] 1
            Item(Global): Report Size, data= [ 0x01 ] 1
            Item(Global): Report Count, data= [ 0x02 ] 2
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Report Count, data= [ 0x06 ] 6
            Item(Main  ): Input, data= [ 0x03 ] 3
                            Constant Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Usage Page, data= [ 0x01 ] 1
                            Generic Desktop Controls
            Item(Local ): Usage, data= [ 0x30 ] 48
                            Direction-X
            Item(Global): Logical Maximum, data= [ 0xd8 0x0a ] 2776
            Item(Global): Physical Maximum, data= [ 0x70 0x6c ] 27760
            Item(Global): Unit, data= [ 0x11 ] 17
                            System: SI Linear, Unit: Centimeter
            Item(Global): Unit Exponent, data= [ 0x0d ] 13
                            Unit Exponent: 13
            Item(Global): Report Size, data= [ 0x10 ] 16
            Item(Global): Report Count, data= [ 0x01 ] 1
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0x31 ] 49
                            Direction-Y
            Item(Global): Logical Maximum, data= [ 0x21 0x06 ] 1569
            Item(Global): Physical Maximum, data= [ 0x4e 0x3d ] 15694
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Global): Physical Maximum, data= [ 0x00 ] 0
            Item(Global): Unit, data= [ 0x00 ] 0
                            System: None, Unit: (None)
            Item(Global): Unit Exponent, data= [ 0x00 ] 0
                            Unit Exponent: 0
            Item(Main  ): End Collection, data=none
            Item(Main  ): End Collection, data=none
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval               5
Device Status:     0x0001
  Self Powered

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support"
  2012-06-17 21:08             ` Nils Kanning
@ 2012-06-18  2:39               ` Chris Bagwell
  0 siblings, 0 replies; 15+ messages in thread
From: Chris Bagwell @ 2012-06-18  2:39 UTC (permalink / raw)
  To: Nils Kanning
  Cc: Jonathan Nieder, Ping Cheng, dmitry.torokhov, Bjørn Mork,
	linux-input, Jason Gerecke

On Sun, Jun 17, 2012 at 4:08 PM, Nils Kanning <nils@kanning.de> wrote:
> On Sat, 2012-06-16 at 19:43 -0500, Chris Bagwell wrote:
>> > The exact patch used is at [2].  That produced:
>
>> Can you "rmmod wacom" and this run "lsusb -vvv" and email me directly
>> or post to debian bug report the section for Wacom?  I'd like to look
>
> With this kernel I could not remove the wacom module using "rmmod
> wacom" (the options -f or -w do not help). Furthermore "lsusb -vvv"
> hangs at the wacom device and does not produce more then:
> Bus 002 Device 004: ID 056a:00e6 Wacom Co., Ltd
>
> The output of "lsusb -vvv" using the Debian kernel from linux-image
> 3.2.17 and after doing "rmmod wacom" is in the attached file.
>
> Nils
>

The HID report didn't help me yet; other then now knowing the i++ is correct.

Your dmesg log file from 3.5-rc2 gives best hint yet at problem.

[    2.159684] input: Wacom ISDv4 E6 Pen as
/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5/2-1.5:1.0/input/input5
[    2.164406] input: Wacom ISDv4 E6 Pen as
/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5/2-1.5:1.1/input/input6

Instead of opps, it loads 2 input devices.  That second device should
say "Finger" instead of "Pen".

Thats related to device_type that gets set while parsing the HID
report.  I'll need some more time to study your HID report to see if I
can figure out why its getting confused.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support"
  2012-06-16  4:01         ` Jonathan Nieder
@ 2012-06-19  0:06           ` Ping Cheng
  0 siblings, 0 replies; 15+ messages in thread
From: Ping Cheng @ 2012-06-19  0:06 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: dmitry.torokhov, Bjørn Mork, linux-input, Jason Gerecke,
	Chris Bagwell, nils

On Fri, Jun 15, 2012 at 9:01 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Ping Cheng wrote:
>
>> I downloaded, built and installed 3.5.-rc2 and 3.2.20 from kernel.org
>> without changing anything in the source. 3.5.-rc2 works all right. But
>> I can not boot 3.2.20 on my system (the error has nothing to do with
>> wacom driver).
>
> By the way, if you have time to describe the boot failure in more
> detail to stable@vger.kernel.org (feel free to cc me), that would be
> very useful.

Sorry for not getting back to you sooner.  I am off today. I made
3.2.20 work after rerunning "make config" on Friday.

With the output of lsusb and dmesg from Nils, looks like either
MAXCONTACTS, or device_type, or both are the root cause. MAXCONTACTS
is not 2. The problem is that I do not have an X220T (0xE6) system to
test with. My testing is on an 0xE3 system, which does not report
MAXCONTACTS. So, a patch for upstream is needed.

I'll make a patch tomorrow for Nils to test.

Ping

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

end of thread, other threads:[~2012-06-19  0:06 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-26  1:14 [PATCH 2/2] input: wacom - add 0xE5 (MT device) support Ping Cheng
2012-04-30  4:10 ` Dmitry Torokhov
2012-06-14 21:23 ` [RFC/PATCH] Revert "Input: wacom - add 0xE5 (MT device) support" Jonathan Nieder
2012-06-14 23:51   ` Ping Cheng
2012-06-15  0:27     ` Jonathan Nieder
2012-06-15 19:08       ` Ping Cheng
2012-06-16  3:39         ` Jonathan Nieder
2012-06-16  4:01         ` Jonathan Nieder
2012-06-19  0:06           ` Ping Cheng
2012-06-16 22:25         ` Jonathan Nieder
2012-06-17  0:43           ` Chris Bagwell
2012-06-17 21:08             ` Nils Kanning
2012-06-18  2:39               ` Chris Bagwell
  -- strict thread matches above, loose matches on Subject: below --
2012-04-15 22:50 [PATCH 0/2] Add E5 support chris
2012-04-15 22:50 ` [PATCH 2/2] input: wacom - add 0xE5 (MT device) support chris
2012-02-01  4:03 [PATCH 1/2] input : wacom - retrieve maximum number of touch points chris
2012-02-01  4:03 ` [PATCH 2/2] input: wacom - add 0xE5 (MT device) support chris

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