From 3699dd7e16a9f68586a44e1efeb9708359f9c2a6 Mon Sep 17 00:00:00 2001 From: Ping Cheng Date: Sat, 3 Nov 2012 12:16:13 -0700 Subject: Input: wacom - clean up device type code Use switch instead of if statement to verify device types Signed-off-by: Ping Cheng Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_sys.c | 53 ++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 15 deletions(-) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 858ad446de91..67442f409174 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -386,23 +386,36 @@ static int wacom_parse_hid(struct usb_interface *intf, if (usage == WCM_DESKTOP) { if (finger) { features->device_type = BTN_TOOL_FINGER; - if (features->type == TABLETPC2FG) { - /* need to reset back */ + + switch (features->type) { + case TABLETPC2FG: features->pktlen = WACOM_PKGLEN_TPC2FG; - } + break; - if (features->type == MTSCREEN || features->type == WACOM_24HDT) + case MTSCREEN: + case WACOM_24HDT: features->pktlen = WACOM_PKGLEN_MTOUCH; + break; - if (features->type == BAMBOO_PT) { - /* need to reset back */ + case BAMBOO_PT: features->pktlen = WACOM_PKGLEN_BBTOUCH; + break; + + default: + features->pktlen = WACOM_PKGLEN_GRAPHIRE; + break; + } + + switch (features->type) { + case BAMBOO_PT: features->x_phy = get_unaligned_le16(&report[i + 5]); features->x_max = get_unaligned_le16(&report[i + 8]); i += 15; - } else if (features->type == WACOM_24HDT) { + break; + + case WACOM_24HDT: features->x_max = get_unaligned_le16(&report[i + 3]); features->x_phy = @@ -410,7 +423,9 @@ static int wacom_parse_hid(struct usb_interface *intf, features->unit = report[i - 1]; features->unitExpo = report[i - 3]; i += 12; - } else { + break; + + default: features->x_max = get_unaligned_le16(&report[i + 3]); features->x_phy = @@ -418,10 +433,11 @@ static int wacom_parse_hid(struct usb_interface *intf, features->unit = report[i + 9]; features->unitExpo = report[i + 11]; i += 12; + break; } } else if (pen) { /* penabled only accepts exact bytes of data */ - if (features->type == TABLETPC2FG) + if (features->type >= TABLETPC) features->pktlen = WACOM_PKGLEN_GRAPHIRE; features->device_type = BTN_TOOL_PEN; features->x_max = @@ -434,32 +450,39 @@ 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) { + switch (features->type) { + case TABLETPC2FG: + case MTSCREEN: features->y_max = get_unaligned_le16(&report[i + 3]); features->y_phy = get_unaligned_le16(&report[i + 6]); i += 7; - } else if (type == WACOM_24HDT) { + break; + + case WACOM_24HDT: features->y_max = get_unaligned_le16(&report[i + 3]); features->y_phy = get_unaligned_le16(&report[i - 2]); i += 7; - } else if (type == BAMBOO_PT) { + break; + + case BAMBOO_PT: features->y_phy = get_unaligned_le16(&report[i + 3]); features->y_max = get_unaligned_le16(&report[i + 6]); i += 12; - } else { + break; + + default: features->y_max = features->x_max; features->y_phy = get_unaligned_le16(&report[i + 3]); i += 4; + break; } } else if (pen) { features->y_max = -- cgit v1.2.3 From 6afdc289c984451a6202a687fe6af727e051a784 Mon Sep 17 00:00:00 2001 From: Ping Cheng Date: Sat, 3 Nov 2012 12:16:15 -0700 Subject: Input: wacom - add support for 2 new multi-touch tablets (0x100 and 0x101) This adds support for the two new multi-touch tablets. Signed-off-by: Ping Cheng Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_sys.c | 5 +++++ drivers/input/tablet/wacom_wac.c | 21 ++++++++++++++++++--- drivers/input/tablet/wacom_wac.h | 2 ++ 3 files changed, 25 insertions(+), 3 deletions(-) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 67442f409174..f92d34f45a1c 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -397,6 +397,10 @@ static int wacom_parse_hid(struct usb_interface *intf, features->pktlen = WACOM_PKGLEN_MTOUCH; break; + case MTTPC: + features->pktlen = WACOM_PKGLEN_MTTPC; + break; + case BAMBOO_PT: features->pktlen = WACOM_PKGLEN_BBTOUCH; break; @@ -453,6 +457,7 @@ static int wacom_parse_hid(struct usb_interface *intf, switch (features->type) { case TABLETPC2FG: case MTSCREEN: + case MTTPC: features->y_max = get_unaligned_le16(&report[i + 3]); features->y_phy = diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 0a67031ffc13..7554a043ee46 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c @@ -877,6 +877,11 @@ static int wacom_mt_touch(struct wacom_wac *wacom) int i; int current_num_contacts = data[2]; int contacts_to_send = 0; + int x_offset = 0; + + /* MTTPC does not support Height and Width */ + if (wacom->features.type == MTTPC) + x_offset = -4; /* * First packet resets the counter since only the first @@ -889,7 +894,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom) 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; + int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3; bool touch = data[offset] & 0x1; int id = le16_to_cpup((__le16 *)&data[offset + 1]); int slot = find_slot_from_contactid(wacom, id); @@ -900,8 +905,8 @@ static int wacom_mt_touch(struct wacom_wac *wacom) 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]); + int x = le16_to_cpup((__le16 *)&data[offset + x_offset + 7]); + int y = le16_to_cpup((__le16 *)&data[offset + x_offset + 9]); input_report_abs(input, ABS_MT_POSITION_X, x); input_report_abs(input, ABS_MT_POSITION_Y, y); } @@ -1336,6 +1341,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) case TABLETPCE: case TABLETPC2FG: case MTSCREEN: + case MTTPC: sync = wacom_tpc_irq(wacom_wac, len); break; @@ -1657,6 +1663,7 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, /* fall through */ case MTSCREEN: + case MTTPC: if (features->device_type == BTN_TOOL_FINGER) { wacom_wac->slots = kmalloc(features->touch_max * sizeof(int), @@ -2018,6 +2025,12 @@ static const struct wacom_features wacom_features_0xED = static const struct wacom_features wacom_features_0xEF = { "Wacom ISDv4 EF", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; +static const struct wacom_features wacom_features_0x100 = + { "Wacom ISDv4 100", WACOM_PKGLEN_MTTPC, 26202, 16325, 255, + 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; +static const struct wacom_features wacom_features_0x101 = + { "Wacom ISDv4 101", WACOM_PKGLEN_MTTPC, 26202, 16325, 255, + 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; static const struct wacom_features wacom_features_0x47 = { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; @@ -2194,6 +2207,8 @@ const struct usb_device_id wacom_ids[] = { { USB_DEVICE_WACOM(0xEC) }, { USB_DEVICE_WACOM(0xED) }, { USB_DEVICE_WACOM(0xEF) }, + { USB_DEVICE_WACOM(0x100) }, + { USB_DEVICE_WACOM(0x101) }, { USB_DEVICE_WACOM(0x47) }, { USB_DEVICE_WACOM(0xF4) }, { USB_DEVICE_WACOM(0xF8) }, diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h index 345f1e76975e..9396d7769f86 100644 --- a/drivers/input/tablet/wacom_wac.h +++ b/drivers/input/tablet/wacom_wac.h @@ -26,6 +26,7 @@ #define WACOM_PKGLEN_BBPEN 10 #define WACOM_PKGLEN_WIRELESS 32 #define WACOM_PKGLEN_MTOUCH 62 +#define WACOM_PKGLEN_MTTPC 40 /* wacom data size per MT contact */ #define WACOM_BYTES_PER_MT_PACKET 11 @@ -88,6 +89,7 @@ enum { TABLETPCE, TABLETPC2FG, MTSCREEN, + MTTPC, MAX_TYPE }; -- cgit v1.2.3 From 2ad5169c762e56e4c7a76f517256ce853eb53ad0 Mon Sep 17 00:00:00 2001 From: Ping Cheng Date: Wed, 21 Nov 2012 13:12:16 -0800 Subject: Input: wacom - simplify type check for newer V5 devices The updated type enum enables this implementation. Signed-off-by: Ping Cheng Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_wac.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 7554a043ee46..a257212ad640 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c @@ -467,9 +467,7 @@ static void wacom_intuos_general(struct wacom_wac *wacom) /* general pen packet */ 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)) { + if (features->type >= INTUOS4S && features->type <= WACOM_24HD) { t = (t << 1) | (data[1] & 1); } input_report_abs(input, ABS_PRESSURE, t); -- cgit v1.2.3 From edbe265d245b0fe05c43e96e52554dacae5dcc70 Mon Sep 17 00:00:00 2001 From: Ping Cheng Date: Wed, 21 Nov 2012 13:12:50 -0800 Subject: Input: wacom - add support for a new MT device (0x4001) It supports 10 fingers. Signed-off-by: Ping Cheng Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom_wac.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/input/tablet') diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index a257212ad640..c0f3e9104832 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c @@ -2029,6 +2029,9 @@ static const struct wacom_features wacom_features_0x100 = static const struct wacom_features wacom_features_0x101 = { "Wacom ISDv4 101", WACOM_PKGLEN_MTTPC, 26202, 16325, 255, 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; +static const struct wacom_features wacom_features_0x4001 = + { "Wacom ISDv4 4001", WACOM_PKGLEN_MTTPC, 26202, 16325, 255, + 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; static const struct wacom_features wacom_features_0x47 = { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; @@ -2207,6 +2210,7 @@ const struct usb_device_id wacom_ids[] = { { USB_DEVICE_WACOM(0xEF) }, { USB_DEVICE_WACOM(0x100) }, { USB_DEVICE_WACOM(0x101) }, + { USB_DEVICE_WACOM(0x4001) }, { USB_DEVICE_WACOM(0x47) }, { USB_DEVICE_WACOM(0xF4) }, { USB_DEVICE_WACOM(0xF8) }, -- cgit v1.2.3