From 9fee619505bdb202c9f54b58ec996884160cdbf2 Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Tue, 3 Apr 2012 15:47:22 -0700 Subject: Input: wacom - add basic Intuos5 support This patch adds support for the basic pen functions of Intuos5 tablets. Signed-off-by: Jason Gerecke Reviewed-by: Chris Bagwell Reviewed-by: Ping Cheng Tested-by: Timo Aaltonen Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_wac.c | 36 +++++++++++++++++++++++++++++++++--- drivers/input/tablet/wacom_wac.h | 3 +++ 2 files changed, 36 insertions(+), 3 deletions(-) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 99fb6fe..20ab364 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c @@ -452,6 +452,7 @@ static void wacom_intuos_general(struct wacom_wac *wacom) if ((data[1] & 0xb8) == 0xa0) { t = (data[6] << 2) | ((data[7] >> 6) & 3); if ((features->type >= INTUOS4S && features->type <= INTUOS4L) || + (features->type >= INTUOS5S && features->type <= INTUOS5L) || features->type == WACOM_21UX2 || features->type == WACOM_24HD) { t = (t << 1) | (data[1] & 1); } @@ -632,7 +633,9 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) (features->type == INTUOS3 || features->type == INTUOS3S || features->type == INTUOS4 || - features->type == INTUOS4S)) { + features->type == INTUOS4S || + features->type == INTUOS5 || + features->type == INTUOS5S)) { return 0; } @@ -685,7 +688,8 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) { /* I4 mouse */ - if (features->type >= INTUOS4S && features->type <= INTUOS4L) { + if ((features->type >= INTUOS4S && features->type <= INTUOS4L) || + (features->type >= INTUOS5S && features->type <= INTUOS5L)) { input_report_key(input, BTN_LEFT, data[6] & 0x01); input_report_key(input, BTN_MIDDLE, data[6] & 0x02); input_report_key(input, BTN_RIGHT, data[6] & 0x04); @@ -712,7 +716,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) } } } else if ((features->type < INTUOS3S || features->type == INTUOS3L || - features->type == INTUOS4L) && + features->type == INTUOS4L || features->type == INTUOS5L) && wacom->tool[idx] == BTN_TOOL_LENS) { /* Lens cursor packets */ input_report_key(input, BTN_LEFT, data[8] & 0x01); @@ -1107,6 +1111,9 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) case INTUOS4S: case INTUOS4: case INTUOS4L: + case INTUOS5S: + case INTUOS5: + case INTUOS5L: case CINTIQ: case WACOM_BEE: case WACOM_21UX2: @@ -1355,12 +1362,15 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev, wacom_setup_intuos(wacom_wac); break; + case INTUOS5: + case INTUOS5L: case INTUOS4: case INTUOS4L: __set_bit(BTN_7, input_dev->keybit); __set_bit(BTN_8, input_dev->keybit); /* fall through */ + case INTUOS5S: case INTUOS4S: for (i = 0; i < 7; i++) __set_bit(BTN_0 + i, input_dev->keybit); @@ -1629,6 +1639,21 @@ static const struct wacom_features wacom_features_0xBB = static const struct wacom_features wacom_features_0xBC = { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40840, 25400, 2047, 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; +static const struct wacom_features wacom_features_0x26 = + { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, + 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; +static const struct wacom_features wacom_features_0x27 = + { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, + 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; +static const struct wacom_features wacom_features_0x28 = + { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, + 63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; +static const struct wacom_features wacom_features_0x29 = + { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, + 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; +static const struct wacom_features wacom_features_0x2A = + { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, + 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; static const struct wacom_features wacom_features_0xF4 = { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047, 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; @@ -1801,6 +1826,11 @@ const struct usb_device_id wacom_ids[] = { { USB_DEVICE_WACOM(0xBA) }, { USB_DEVICE_WACOM(0xBB) }, { USB_DEVICE_WACOM(0xBC) }, + { USB_DEVICE_WACOM(0x26) }, + { USB_DEVICE_WACOM(0x27) }, + { USB_DEVICE_WACOM(0x28) }, + { USB_DEVICE_WACOM(0x29) }, + { USB_DEVICE_WACOM(0x2A) }, { USB_DEVICE_WACOM(0x3F) }, { USB_DEVICE_WACOM(0xC5) }, { USB_DEVICE_WACOM(0xC6) }, diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h index ba5a334..0aa00ce 100644 --- a/drivers/input/tablet/wacom_wac.h +++ b/drivers/input/tablet/wacom_wac.h @@ -65,6 +65,9 @@ enum { INTUOS4S, INTUOS4, INTUOS4L, + INTUOS5S, + INTUOS5, + INTUOS5L, WACOM_24HD, WACOM_21UX2, CINTIQ, -- cgit v1.1 From f860e581fd473250c6dcbd3e13d576b6197e4694 Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Tue, 3 Apr 2012 15:48:35 -0700 Subject: Input: wacom - add Intuos5 Touch Ring/ExpressKey support Intuos5 uses a new report type for Touch Ring and ExpressKey data. Note that data from the capacitive sensors present on the ExpressKeys will be ignored until a proper way is found to expose it. Signed-off-by: Jason Gerecke Reviewed-by: Chris Bagwell Reviewed-by: Ping Cheng Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_wac.c | 33 +++++++++++++++++++++++++++++++-- drivers/input/tablet/wacom_wac.h | 1 + 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 20ab364..f4a9efd 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c @@ -484,7 +484,8 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) int idx = 0, result; if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_INTUOSREAD - && data[0] != WACOM_REPORT_INTUOSWRITE && data[0] != WACOM_REPORT_INTUOSPAD) { + && data[0] != WACOM_REPORT_INTUOSWRITE && data[0] != WACOM_REPORT_INTUOSPAD + && data[0] != WACOM_REPORT_INTUOS5PAD) { dbg("wacom_intuos_irq: received unknown report #%d", data[0]); return 0; } @@ -494,7 +495,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) idx = data[1] & 0x01; /* pad packets. Works as a second tool and is always in prox */ - if (data[0] == WACOM_REPORT_INTUOSPAD) { + if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD) { if (features->type >= INTUOS4S && features->type <= INTUOS4L) { input_report_key(input, BTN_0, (data[2] & 0x01)); input_report_key(input, BTN_1, (data[3] & 0x01)); @@ -570,6 +571,34 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) input_report_key(input, wacom->tool[1], 0); input_report_abs(input, ABS_MISC, 0); } + } else if (features->type >= INTUOS5S && features->type <= INTUOS5L) { + int i; + + /* Touch ring mode switch has no capacitive sensor */ + input_report_key(input, BTN_0, (data[3] & 0x01)); + + /* + * ExpressKeys on Intuos5 have a capacitive sensor in + * addition to the mechanical switch. Switch data is + * stored in data[4], capacitive data in data[5]. + */ + for (i = 0; i < 8; i++) + input_report_key(input, BTN_1 + i, data[4] & (1 << i)); + + if (data[2] & 0x80) { + input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f)); + } else { + /* Out of proximity, clear wheel value. */ + input_report_abs(input, ABS_WHEEL, 0); + } + + if (data[2] | (data[3] & 0x01) | data[4]) { + input_report_key(input, wacom->tool[1], 1); + input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); + } else { + input_report_key(input, wacom->tool[1], 0); + input_report_abs(input, ABS_MISC, 0); + } } else { if (features->type == WACOM_21UX2) { input_report_key(input, BTN_0, (data[5] & 0x01)); diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h index 0aa00ce..17ba186 100644 --- a/drivers/input/tablet/wacom_wac.h +++ b/drivers/input/tablet/wacom_wac.h @@ -38,6 +38,7 @@ #define WACOM_REPORT_INTUOSREAD 5 #define WACOM_REPORT_INTUOSWRITE 6 #define WACOM_REPORT_INTUOSPAD 12 +#define WACOM_REPORT_INTUOS5PAD 3 #define WACOM_REPORT_TPC1FG 6 #define WACOM_REPORT_TPC2FG 13 #define WACOM_REPORT_TPCHID 15 -- cgit v1.1 From 9b5b95dd516a13d53ecf9217672d2116f05097bc Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Tue, 3 Apr 2012 15:50:37 -0700 Subject: Input: wacom - add Intuos5 Touch Ring LED support The Touch Ring LEDs on Intuos5 tablets use a different report format which supports only 4 levels of brightness. We remap the 7-bit value obtained from sysfs to an appropriate value for the tablet. Control of the crop mark LEDs (new to the I5) is left for a later patch. Signed-off-by: Jason Gerecke Reviewed-by: Ping Cheng Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_sys.c | 71 +++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 12 deletions(-) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 19ba586..d771338 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -574,23 +574,39 @@ static void wacom_remove_shared_data(struct wacom_wac *wacom) static int wacom_led_control(struct wacom *wacom) { unsigned char *buf; - int retval, led = 0; + int retval; buf = kzalloc(9, GFP_KERNEL); if (!buf) return -ENOMEM; - if (wacom->wacom_wac.features.type == WACOM_21UX2 || - wacom->wacom_wac.features.type == WACOM_24HD) - led = (wacom->led.select[1] << 4) | 0x40; - - led |= wacom->led.select[0] | 0x4; - - buf[0] = WAC_CMD_LED_CONTROL; - buf[1] = led; - buf[2] = wacom->led.llv; - buf[3] = wacom->led.hlv; - buf[4] = wacom->led.img_lum; + if (wacom->wacom_wac.features.type >= INTUOS5S && + wacom->wacom_wac.features.type <= INTUOS5L) { + /* + * Touch Ring and crop mark LED luminance may take on + * one of four values: + * 0 = Low; 1 = Medium; 2 = High; 3 = Off + */ + int ring_led = wacom->led.select[0] & 0x03; + int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03; + int crop_lum = 0; + + buf[0] = WAC_CMD_LED_CONTROL; + buf[1] = (crop_lum << 4) | (ring_lum << 2) | (ring_led); + } + else { + int led = wacom->led.select[0] | 0x4; + + if (wacom->wacom_wac.features.type == WACOM_21UX2 || + wacom->wacom_wac.features.type == WACOM_24HD) + led |= (wacom->led.select[1] << 4) | 0x40; + + buf[0] = WAC_CMD_LED_CONTROL; + buf[1] = led; + buf[2] = wacom->led.llv; + buf[3] = wacom->led.hlv; + buf[4] = wacom->led.img_lum; + } retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_LED_CONTROL, buf, 9, WAC_CMD_RETRIES); @@ -783,6 +799,17 @@ static struct attribute_group intuos4_led_attr_group = { .attrs = intuos4_led_attrs, }; +static struct attribute *intuos5_led_attrs[] = { + &dev_attr_status0_luminance.attr, + &dev_attr_status_led0_select.attr, + NULL +}; + +static struct attribute_group intuos5_led_attr_group = { + .name = "wacom_led", + .attrs = intuos5_led_attrs, +}; + static int wacom_initialize_leds(struct wacom *wacom) { int error; @@ -812,6 +839,19 @@ static int wacom_initialize_leds(struct wacom *wacom) &cintiq_led_attr_group); break; + case INTUOS5S: + case INTUOS5: + case INTUOS5L: + wacom->led.select[0] = 0; + wacom->led.select[1] = 0; + wacom->led.llv = 32; + wacom->led.hlv = 0; + wacom->led.img_lum = 0; + + error = sysfs_create_group(&wacom->intf->dev.kobj, + &intuos5_led_attr_group); + break; + default: return 0; } @@ -840,6 +880,13 @@ static void wacom_destroy_leds(struct wacom *wacom) sysfs_remove_group(&wacom->intf->dev.kobj, &cintiq_led_attr_group); break; + + case INTUOS5S: + case INTUOS5: + case INTUOS5L: + sysfs_remove_group(&wacom->intf->dev.kobj, + &intuos5_led_attr_group); + break; } } -- cgit v1.1 From ae584ca473289377dd7fd8c61439db4bfab5489a Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Tue, 3 Apr 2012 15:50:40 -0700 Subject: Input: wacom - add Intuos5 multitouch sensor support Intuos5 tablets with PTH-* model numbers include a multitouch sensor which use the same touch reports as the 3rd-generation Bamboo. No useful information is in the HID descriptor for the touch interface so hardcoded values are used during setup. Signed-off-by: Jason Gerecke Reviewed-by: Chris Bagwell Reviewed-by: Ping Cheng Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_sys.c | 25 ++++++++++++++++ drivers/input/tablet/wacom_wac.c | 64 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 5 deletions(-) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index d771338..1c874ad 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -233,6 +233,9 @@ static int wacom_parse_logical_collection(unsigned char *report, * 3rd gen Bamboo Touch no longer define a Digitizer-Finger Pysical * Collection. Instead they define a Logical Collection with a single * Logical Maximum for both X and Y. + * + * Intuos5 touch interface does not contain useful data. We deal with + * this after returning from this function. */ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc, @@ -1085,6 +1088,28 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i if (error) goto fail3; + /* + * Intuos5 has no useful data about its touch interface in its + * HID descriptor. If this is the touch interface (wMaxPacketSize + * of WACOM_PKGLEN_BBTOUCH3), override the table values. + */ + if (features->type >= INTUOS5S && features->type <= INTUOS5L) { + if (endpoint->wMaxPacketSize == WACOM_PKGLEN_BBTOUCH3) { + features->device_type = BTN_TOOL_FINGER; + features->pktlen = WACOM_PKGLEN_BBTOUCH3; + + features->x_phy = + (features->x_max * 100) / features->x_resolution; + features->y_phy = + (features->y_max * 100) / features->y_resolution; + + features->x_max = 4096; + features->y_max = 4096; + } else { + features->device_type = BTN_TOOL_PEN; + } + } + wacom_setup_device_quirks(features); strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index f4a9efd..a617343 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c @@ -321,6 +321,9 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) /* Enter report */ if ((data[1] & 0xfc) == 0xc0) { + if (features->type >= INTUOS5S && features->type <= INTUOS5L) + wacom->shared->stylus_in_proximity = true; + /* serial number of the tool */ wacom->serial[idx] = ((data[3] & 0x0f) << 28) + (data[4] << 20) + (data[5] << 12) + @@ -406,6 +409,9 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) /* Exit report */ if ((data[1] & 0xfe) == 0x80) { + if (features->type >= INTUOS5S && features->type <= INTUOS5L) + wacom->shared->stylus_in_proximity = false; + /* * Reset all states otherwise we lose the initial states * when in-prox next time @@ -1140,9 +1146,6 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) case INTUOS4S: case INTUOS4: case INTUOS4L: - case INTUOS5S: - case INTUOS5: - case INTUOS5L: case CINTIQ: case WACOM_BEE: case WACOM_21UX2: @@ -1150,6 +1153,15 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) sync = wacom_intuos_irq(wacom_wac); break; + case INTUOS5S: + case INTUOS5: + case INTUOS5L: + if (len == WACOM_PKGLEN_BBTOUCH3) + sync = wacom_bpt3_touch(wacom_wac); + else + sync = wacom_intuos_irq(wacom_wac); + break; + case TABLETPC: case TABLETPC2FG: sync = wacom_tpc_irq(wacom_wac, len); @@ -1224,7 +1236,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 == BAMBOO_PT || features->type == WIRELESS || + (features->type >= INTUOS5S && features->type <= INTUOS5L)) features->quirks |= WACOM_QUIRK_MULTI_INPUT; /* quirk for bamboo touch with 2 low res touches */ @@ -1393,13 +1406,54 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev, case INTUOS5: case INTUOS5L: + if (features->device_type == BTN_TOOL_PEN) { + __set_bit(BTN_7, input_dev->keybit); + __set_bit(BTN_8, input_dev->keybit); + } + /* fall through */ + + case INTUOS5S: + __set_bit(INPUT_PROP_POINTER, input_dev->propbit); + + if (features->device_type == BTN_TOOL_PEN) { + for (i = 0; i < 7; i++) + __set_bit(BTN_0 + i, input_dev->keybit); + + input_set_abs_params(input_dev, ABS_DISTANCE, 0, + features->distance_max, + 0, 0); + + input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); + + wacom_setup_intuos(wacom_wac); + } else if (features->device_type == BTN_TOOL_FINGER) { + __clear_bit(ABS_MISC, input_dev->absbit); + + __set_bit(BTN_TOOL_FINGER, input_dev->keybit); + __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); + __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); + __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); + + input_mt_init_slots(input_dev, 16); + + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, + 0, 255, 0, 0); + + input_set_abs_params(input_dev, ABS_MT_POSITION_X, + 0, features->x_max, + features->x_fuzz, 0); + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, + 0, features->y_max, + features->y_fuzz, 0); + } + break; + case INTUOS4: case INTUOS4L: __set_bit(BTN_7, input_dev->keybit); __set_bit(BTN_8, input_dev->keybit); /* fall through */ - case INTUOS5S: case INTUOS4S: for (i = 0; i < 7; i++) __set_bit(BTN_0 + i, input_dev->keybit); -- cgit v1.1 From 482d74ceb09db45b5d19fd1ae3810b38afbc0518 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 23 Apr 2012 22:26:58 -0700 Subject: Input: aiptek - adjust error-handling code label At the point of this error-handling code, aiptek->urb has been allocated, and it does not appear to be less necessary to free it here than in the error-handling code just below. Signed-off-by: Julia Lawall Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/aiptek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c index 205d16a..a33d347 100644 --- a/drivers/input/tablet/aiptek.c +++ b/drivers/input/tablet/aiptek.c @@ -1856,7 +1856,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) if (i == ARRAY_SIZE(speeds)) { dev_info(&intf->dev, "Aiptek tried all speeds, no sane response\n"); - goto fail2; + goto fail3; } /* Associate this driver's struct with the usb interface. -- cgit v1.1 From f393ee2b814e3291c12565000210b3cf10aa5c1d Mon Sep 17 00:00:00 2001 From: Ping Cheng Date: Sun, 29 Apr 2012 21:09:17 -0700 Subject: Input: wacom - retrieve maximum number of touch points From the HID usage table when it is supported. Tested-by: Jason Gerecke Signed-off-by: Chris Bagwell Signed-off-by: Ping Cheng Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_sys.c | 29 +++++++++++++++++++- drivers/input/tablet/wacom_wac.c | 59 ++++++++++++++++++++++++---------------- drivers/input/tablet/wacom_wac.h | 1 + 3 files changed, 65 insertions(+), 24 deletions(-) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 98e9dd6..be13223 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -28,6 +28,7 @@ #define HID_USAGE_Y_TILT 0x3e #define HID_USAGE_FINGER 0x22 #define HID_USAGE_STYLUS 0x20 +#define HID_USAGE_CONTACTMAX 0x55 #define HID_COLLECTION 0xa1 #define HID_COLLECTION_LOGICAL 0x02 #define HID_COLLECTION_END 0xc0 @@ -201,6 +202,27 @@ static int wacom_parse_logical_collection(unsigned char *report, return length; } +static void wacom_retrieve_report_data(struct usb_interface *intf, + struct wacom_features *features) +{ + int result = 0; + unsigned char *rep_data; + + rep_data = kmalloc(2, GFP_KERNEL); + if (rep_data) { + + rep_data[0] = 12; + result = wacom_get_report(intf, WAC_HID_FEATURE_REPORT, + rep_data[0], &rep_data, 2, + WAC_MSG_RETRIES); + + if (result >= 0 && rep_data[1] > 2) + features->touch_max = rep_data[1]; + + kfree(rep_data); + } +} + /* * Interface Descriptor of wacom devices can be incomplete and * inconsistent so wacom_features table is used to store stylus @@ -377,6 +399,11 @@ static int wacom_parse_hid(struct usb_interface *intf, pen = 1; i++; break; + + case HID_USAGE_CONTACTMAX: + wacom_retrieve_report_data(intf, features); + i++; + break; } break; @@ -1085,7 +1112,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i endpoint = &intf->cur_altsetting->endpoint[0].desc; - /* Retrieve the physical and logical size for OEM devices */ + /* Retrieve the physical and logical size for touch devices */ error = wacom_retrieve_hid_descriptor(intf, features); if (error) goto fail3; diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index d96e186..e5cd0e5 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c @@ -1434,7 +1434,7 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev, __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); - input_mt_init_slots(input_dev, 16); + input_mt_init_slots(input_dev, features->touch_max); input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); @@ -1467,7 +1467,7 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev, case TABLETPC2FG: if (features->device_type == BTN_TOOL_FINGER) { - input_mt_init_slots(input_dev, 2); + 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); input_set_abs_params(input_dev, ABS_MT_POSITION_X, @@ -1522,6 +1522,7 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev, __set_bit(BTN_TOOL_FINGER, input_dev->keybit); __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); + input_mt_init_slots(input_dev, features->touch_max); if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { __set_bit(BTN_TOOL_TRIPLETAP, @@ -1529,13 +1530,9 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev, __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); - input_mt_init_slots(input_dev, 16); - input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); - } else { - input_mt_init_slots(input_dev, 2); } input_set_abs_params(input_dev, ABS_MT_POSITION_X, @@ -1724,13 +1721,16 @@ static const struct wacom_features wacom_features_0xBC = 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; static const struct wacom_features wacom_features_0x26 = { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, - 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; + 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, + .touch_max = 16 }; static const struct wacom_features wacom_features_0x27 = { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, - 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; + 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, + .touch_max = 16 }; static const struct wacom_features wacom_features_0x28 = { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, - 63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; + 63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, + .touch_max = 16 }; static const struct wacom_features wacom_features_0x29 = { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; @@ -1778,13 +1778,16 @@ static const struct wacom_features wacom_features_0x9F = 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; static const struct wacom_features wacom_features_0xE2 = { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, - 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; + 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 2 }; 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 }; + 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 2 }; 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 }; + 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 2 }; static const struct wacom_features wacom_features_0xEC = { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255, 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; @@ -1793,19 +1796,22 @@ static const struct wacom_features wacom_features_0x47 = 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; static const struct wacom_features wacom_features_0x84 = { "Wacom Wireless Receiver", WACOM_PKGLEN_WIRELESS, 0, 0, 0, - 0, WIRELESS, 0, 0 }; + 0, WIRELESS, 0, 0, .touch_max = 16 }; static const struct wacom_features wacom_features_0xD0 = { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 2 }; static const struct wacom_features wacom_features_0xD1 = { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 2 }; static const struct wacom_features wacom_features_0xD2 = { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; static const struct wacom_features wacom_features_0xD3 = { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023, - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 2 }; static const struct wacom_features wacom_features_0xD4 = { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; @@ -1814,28 +1820,35 @@ static const struct wacom_features wacom_features_0xD5 = 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; static const struct wacom_features wacom_features_0xD6 = { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 2 }; static const struct wacom_features wacom_features_0xD7 = { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 2 }; static const struct wacom_features wacom_features_0xD8 = { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023, - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 2 }; static const struct wacom_features wacom_features_0xDA = { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 2 }; static struct wacom_features wacom_features_0xDB = { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023, - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 2 }; static const struct wacom_features wacom_features_0xDD = { "Wacom Bamboo Connect", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023, 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; static const struct wacom_features wacom_features_0xDE = { "Wacom Bamboo 16FG 4x5", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023, - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 16 }; static const struct wacom_features wacom_features_0xDF = { "Wacom Bamboo 16FG 6x8", WACOM_PKGLEN_BBPEN, 21648, 13700, 1023, - 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, + .touch_max = 16 }; static const struct wacom_features wacom_features_0x6004 = { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255, 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h index 17ba186..321269c 100644 --- a/drivers/input/tablet/wacom_wac.h +++ b/drivers/input/tablet/wacom_wac.h @@ -99,6 +99,7 @@ struct wacom_features { int pressure_fuzz; int distance_fuzz; unsigned quirks; + unsigned touch_max; }; struct wacom_shared { -- cgit v1.1 From 1963518b9b1b8019d33b4b08deee6f873ffa2730 Mon Sep 17 00:00:00 2001 From: Ping Cheng Date: Sun, 29 Apr 2012 21:09:18 -0700 Subject: Input: wacom - add 0xE5 (MT device) support 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 Signed-off-by: Chris Bagwell Signed-off-by: Ping Cheng Signed-off-by: Dmitry Torokhov --- 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, 157 insertions(+), 45 deletions(-) (limited to 'drivers/input/tablet') 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 be13223..86b96f9 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,29 @@ 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) { @@ -477,7 +481,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; @@ -505,10 +509,13 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, } } - /* only Tablet PCs and Bamboo P&T need to retrieve the info */ - if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) && - (features->type != BAMBOO_PT)) + /* only devices that support touch need to retrieve the info */ + if (features->type != TABLETPC && + features->type != TABLETPC2FG && + features->type != BAMBOO_PT && + features->type != MTSCREEN) { goto out; + } if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) { if (usb_get_extra_descriptor(&interface->endpoint[0], @@ -978,8 +985,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 +998,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..10e5cf8 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c @@ -768,6 +768,72 @@ 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; @@ -806,6 +872,9 @@ 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 +942,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 +954,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 +1236,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 +1310,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 +1342,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 +1539,18 @@ 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 +1636,7 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev, } break; } + return 0; } static const struct wacom_features wacom_features_0x00 = @@ -1784,6 +1869,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 +2050,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..78fbd3f 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; + int num_contacts_left; + int *slots; }; #endif -- cgit v1.1 From 0c9e300adec668fd323b0e79c85b9136fccab649 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 2 May 2012 00:13:38 -0700 Subject: Input: wacom - fix sparse warning This fixes the following warning from sparse warning: Using plain integer as NULL pointer Reviewed-by: Chris Bagwell Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_sys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 86b96f9..364f2c3 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -1030,13 +1030,13 @@ static void wacom_wireless_work(struct work_struct *work) wacom = usb_get_intfdata(usbdev->config->interface[1]); if (wacom->wacom_wac.input) input_unregister_device(wacom->wacom_wac.input); - wacom->wacom_wac.input = 0; + wacom->wacom_wac.input = NULL; /* Touch interface */ wacom = usb_get_intfdata(usbdev->config->interface[2]); if (wacom->wacom_wac.input) input_unregister_device(wacom->wacom_wac.input); - wacom->wacom_wac.input = 0; + wacom->wacom_wac.input = NULL; if (wacom_wac->pid == 0) { printk(KERN_INFO "wacom: wireless tablet disconnected\n"); -- cgit v1.1 From a882c932a628cbab17752fc8b1c94692f95bbf9a Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 2 May 2012 00:13:38 -0700 Subject: Input: wacom - return proper error if usb_get_extra_descriptor() fails Instead of returning 1 (which is not even negative) let's capture and return error codde returned by usb_get_extra_descriptor(). Reviewed-by: Chris Bagwell Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_sys.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 364f2c3..8f3b30b 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -517,11 +517,12 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, goto out; } - if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) { - if (usb_get_extra_descriptor(&interface->endpoint[0], - HID_DEVICET_REPORT, &hid_desc)) { - printk("wacom: can not retrieve extra class descriptor\n"); - error = 1; + error = usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc); + if (error) { + error = usb_get_extra_descriptor(&interface->endpoint[0], + HID_DEVICET_REPORT, &hid_desc); + if (error) { + printk(KERN_ERR "wacom: can not retrieve extra class descriptor\n"); goto out; } } -- cgit v1.1 From eb71d1bb270ef6b2a9c1bfaa7818e1e75b3d4546 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 2 May 2012 00:13:38 -0700 Subject: Input: wacom - use dev_xxx() instead of naked printk()s and dbg()s Reviewed-by: Chris Bagwell Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_sys.c | 15 ++++++++------- drivers/input/tablet/wacom_wac.c | 29 +++++++++++++++++++---------- 2 files changed, 27 insertions(+), 17 deletions(-) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 8f3b30b..b3a8bd3 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -522,7 +522,8 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, error = usb_get_extra_descriptor(&interface->endpoint[0], HID_DEVICET_REPORT, &hid_desc); if (error) { - printk(KERN_ERR "wacom: can not retrieve extra class descriptor\n"); + dev_err(&intf->dev, + "can not retrieve extra class descriptor\n"); goto out; } } @@ -1040,13 +1041,13 @@ static void wacom_wireless_work(struct work_struct *work) wacom->wacom_wac.input = NULL; if (wacom_wac->pid == 0) { - printk(KERN_INFO "wacom: wireless tablet disconnected\n"); + dev_info(&wacom->intf->dev, "wireless tablet disconnected\n"); } else { const struct usb_device_id *id = wacom_ids; - printk(KERN_INFO - "wacom: wireless tablet connected with PID %x\n", - wacom_wac->pid); + dev_info(&wacom->intf->dev, + "wireless tablet connected with PID %x\n", + wacom_wac->pid); while (id->match_flags) { if (id->idVendor == USB_VENDOR_ID_WACOM && @@ -1056,8 +1057,8 @@ static void wacom_wireless_work(struct work_struct *work) } if (!id->match_flags) { - printk(KERN_INFO - "wacom: ignorning unknown PID.\n"); + dev_info(&wacom->intf->dev, + "ignoring unknown PID.\n"); return; } diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 10e5cf8..004bc1b 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c @@ -61,7 +61,8 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom) break; default: - printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]); + dev_dbg(input->dev.parent, + "%s: received unknown report #%d\n", __func__, data[0]); return 0; } @@ -76,7 +77,8 @@ static int wacom_pl_irq(struct wacom_wac *wacom) int prox, pressure; if (data[0] != WACOM_REPORT_PENABLED) { - dbg("wacom_pl_irq: received unknown report #%d", data[0]); + dev_dbg(input->dev.parent, + "%s: received unknown report #%d\n", __func__, data[0]); return 0; } @@ -146,7 +148,8 @@ static int wacom_ptu_irq(struct wacom_wac *wacom) struct input_dev *input = wacom->input; if (data[0] != WACOM_REPORT_PENABLED) { - printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]); + dev_dbg(input->dev.parent, + "%s: received unknown report #%d\n", __func__, data[0]); return 0; } @@ -175,7 +178,8 @@ static int wacom_dtu_irq(struct wacom_wac *wacom) struct input_dev *input = wacom->input; int prox = data[1] & 0x20, pressure; - dbg("wacom_dtu_irq: received report #%d", data[0]); + dev_dbg(input->dev.parent, + "%s: received report #%d", __func__, data[0]); if (prox) { /* Going into proximity select tool */ @@ -211,7 +215,8 @@ static int wacom_graphire_irq(struct wacom_wac *wacom) int retval = 0; if (data[0] != WACOM_REPORT_PENABLED) { - dbg("wacom_graphire_irq: received unknown report #%d", data[0]); + dev_dbg(input->dev.parent, + "%s: received unknown report #%d\n", __func__, data[0]); goto exit; } @@ -489,10 +494,13 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) unsigned int t; int idx = 0, result; - if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_INTUOSREAD - && data[0] != WACOM_REPORT_INTUOSWRITE && data[0] != WACOM_REPORT_INTUOSPAD - && data[0] != WACOM_REPORT_INTUOS5PAD) { - dbg("wacom_intuos_irq: received unknown report #%d", data[0]); + if (data[0] != WACOM_REPORT_PENABLED && + data[0] != WACOM_REPORT_INTUOSREAD && + data[0] != WACOM_REPORT_INTUOSWRITE && + data[0] != WACOM_REPORT_INTUOSPAD && + data[0] != WACOM_REPORT_INTUOS5PAD) { + dev_dbg(input->dev.parent, + "%s: received unknown report #%d\n", __func__, data[0]); return 0; } @@ -938,7 +946,8 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) { char *data = wacom->data; - dbg("wacom_tpc_irq: received report #%d", data[0]); + dev_dbg(wacom->input->dev.parent, + "%s: received report #%d\n", __func__, data[0]); switch (len) { case WACOM_PKGLEN_TPC1FG: -- cgit v1.1