From a9606c01f7edfc21a3fce1f10152fbf266e74d4f Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Mon, 6 Sep 2010 09:59:01 +0200 Subject: Align with 2.6.37 This patch aligns wacom support with kernel 2.6.37. The tablet buttons have been remapped and the code has been prepared for adding the rest of the Bamboo family. Signed-off-by: Henrik Rydberg --- usr/src/dkms_source_tree/wacom.h | 1 + usr/src/dkms_source_tree/wacom_sys.c | 57 ++++++++++++------ usr/src/dkms_source_tree/wacom_wac.c | 108 +++++++++++++++++++++++------------ usr/src/dkms_source_tree/wacom_wac.h | 12 +++- 4 files changed, 124 insertions(+), 54 deletions(-) (limited to 'usr/src') diff --git a/usr/src/dkms_source_tree/wacom.h b/usr/src/dkms_source_tree/wacom.h index 284dfaa..de5adb1 100644 --- a/usr/src/dkms_source_tree/wacom.h +++ b/usr/src/dkms_source_tree/wacom.h @@ -118,6 +118,7 @@ struct wacom { 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); #endif diff --git a/usr/src/dkms_source_tree/wacom_sys.c b/usr/src/dkms_source_tree/wacom_sys.c index 42ba369..fc6fd53 100644 --- a/usr/src/dkms_source_tree/wacom_sys.c +++ b/usr/src/dkms_source_tree/wacom_sys.c @@ -195,17 +195,30 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi features->pktlen = WACOM_PKGLEN_TPC2FG; features->device_type = BTN_TOOL_TRIPLETAP; } - features->x_max = - get_unaligned_le16(&report[i + 3]); - features->x_phy = - get_unaligned_le16(&report[i + 6]); - features->unit = report[i + 9]; - features->unitExpo = report[i + 11]; - i += 12; + if (features->type == BAMBOO_PT) { + /* need to reset back */ + features->pktlen = WACOM_PKGLEN_BBTOUCH; + features->device_type = BTN_TOOL_TRIPLETAP; + features->x_phy = + get_unaligned_le16(&report[i + 5]); + features->x_max = + get_unaligned_le16(&report[i + 8]); + i += 15; + } else { + features->x_max = + get_unaligned_le16(&report[i + 3]); + features->x_phy = + get_unaligned_le16(&report[i + 6]); + features->unit = report[i + 9]; + features->unitExpo = report[i + 11]; + i += 12; + } } else if (pen) { /* penabled only accepts exact bytes of data */ if (features->type == TABLETPC2FG) features->pktlen = WACOM_PKGLEN_GRAPHIRE; + if (features->type == BAMBOO_PT) + features->pktlen = WACOM_PKGLEN_BBFUN; features->device_type = BTN_TOOL_PEN; features->x_max = get_unaligned_le16(&report[i + 3]); @@ -234,6 +247,15 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi 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; + features->device_type = BTN_TOOL_TRIPLETAP; + features->y_phy = + get_unaligned_le16(&report[i + 3]); + features->y_max = + get_unaligned_le16(&report[i + 6]); + i += 12; } else { features->y_max = features->x_max; @@ -245,6 +267,8 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi /* penabled only accepts exact bytes of data */ if (features->type == TABLETPC2FG) features->pktlen = WACOM_PKGLEN_GRAPHIRE; + if (features->type == BAMBOO_PT) + features->pktlen = WACOM_PKGLEN_BBFUN; features->device_type = BTN_TOOL_PEN; features->y_max = get_unaligned_le16(&report[i + 3]); @@ -333,11 +357,16 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, struct usb_host_interface *interface = intf->cur_altsetting; struct hid_descriptor *hid_desc; - /* default device to penabled */ + /* default features */ features->device_type = BTN_TOOL_PEN; + features->x_fuzz = 4; + features->y_fuzz = 4; + features->pressure_fuzz = 0; + features->distance_fuzz = 0; /* only Tablet PCs need to retrieve the info */ - if ((features->type != TABLETPC) && (features->type != TABLETPC2FG)) + if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) && + (features->type != BAMBOO_PT)) goto out; if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) { @@ -352,12 +381,6 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, if (error) goto out; - /* touch device found but size is not defined. use default */ - if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) { - features->x_max = 1023; - features->y_max = 1023; - } - out: return error; } @@ -493,9 +516,11 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i if (error) goto fail2; + wacom_setup_device_quirks(features); + strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); - if (features->type == TABLETPC || features->type == TABLETPC2FG) { + if (features->quirks & WACOM_QUIRK_MULTI_INPUT) { /* Append the device type to the name */ strlcat(wacom_wac->name, features->device_type == BTN_TOOL_PEN ? diff --git a/usr/src/dkms_source_tree/wacom_wac.c b/usr/src/dkms_source_tree/wacom_wac.c index d1c388e..fd2463c 100644 --- a/usr/src/dkms_source_tree/wacom_wac.c +++ b/usr/src/dkms_source_tree/wacom_wac.c @@ -855,12 +855,13 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) return retval; } -static int wacom_bbt_irq(struct wacom_wac *wacom, size_t len) +static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len) { - static int trkid; + struct wacom_features *features = &wacom->features; struct input_dev *input = wacom->input; unsigned char *data = wacom->data; - int i, sp = 0, sx = 0, sy = 0, count = 0; + int sp = 0, sx = 0, sy = 0, count = 0; + int i; if (len != WACOM_PKGLEN_BBTOUCH) return 0; @@ -871,14 +872,15 @@ static int wacom_bbt_irq(struct wacom_wac *wacom, size_t len) if (p) { int x = get_unaligned_be16(&data[9 * i + 3]) & 0x7ff; int y = get_unaligned_be16(&data[9 * i + 5]) & 0x7ff; - /* artificial scaling */ - x <<= 4; - y <<= 4; + if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) { + x <<= 5; + y <<= 5; + } input_report_abs(input, ABS_MT_PRESSURE, p); input_report_abs(input, ABS_MT_POSITION_X, x); input_report_abs(input, ABS_MT_POSITION_Y, y); if (wacom->id[i] < 0) - wacom->id[i] = trkid++ & MAX_TRACKING_ID; + wacom->id[i] = wacom->trk_id++ & MAX_TRACKING_ID; if (!count++) sp = p, sx = x, sy = y; } else { @@ -896,7 +898,8 @@ static int wacom_bbt_irq(struct wacom_wac *wacom, size_t len) input_report_abs(input, ABS_Y, sy); input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0); - input_report_key(input, BTN_MIDDLE, (data[1] & 0x06) != 0); + input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0); + input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0); input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0); input_sync(input); @@ -949,8 +952,8 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) sync = wacom_tpc_irq(wacom_wac, len); break; - case BAMBOO_TOUCH: - sync = wacom_bbt_irq(wacom_wac, len); + case BAMBOO_PT: + sync = wacom_bpt_irq(wacom_wac, len); break; default: @@ -994,6 +997,34 @@ static void wacom_setup_intuos(struct wacom_wac *wacom_wac) input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); } + +void wacom_setup_device_quirks(struct wacom_features *features) +{ + + /* touch device found but size is not defined. use default */ + if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) { + features->x_max = 1023; + features->y_max = 1023; + } + + /* these device have multiple inputs */ + if (features->type == TABLETPC || features->type == TABLETPC2FG || + features->type == BAMBOO_PT) + features->quirks |= WACOM_QUIRK_MULTI_INPUT; + + /* quirks for bamboo touch */ + if (features->type == BAMBOO_PT && + features->device_type == BTN_TOOL_TRIPLETAP) { + features->x_max <<= 5; + features->y_max <<= 5; + features->x_fuzz <<= 5; + features->y_fuzz <<= 5; + features->pressure_max = 256; + features->pressure_fuzz = 16; + features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES; + } +} + void wacom_setup_input_capabilities(struct input_dev *input_dev, struct wacom_wac *wacom_wac) { @@ -1004,9 +1035,12 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev, __set_bit(BTN_TOUCH, input_dev->keybit); - input_set_abs_params(input_dev, ABS_X, 0, features->x_max, 4, 0); - input_set_abs_params(input_dev, ABS_Y, 0, features->y_max, 4, 0); - input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, 0, 0); + input_set_abs_params(input_dev, ABS_X, 0, features->x_max, + features->x_fuzz, 0); + input_set_abs_params(input_dev, ABS_Y, 0, features->y_max, + features->y_fuzz, 0); + input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, + features->pressure_fuzz, 0); __set_bit(ABS_MISC, input_dev->absbit); @@ -1130,24 +1164,31 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev, __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); break; - case BAMBOO_TOUCH: + case BAMBOO_PT: __clear_bit(ABS_MISC, input_dev->absbit); - __set_bit(BTN_LEFT, input_dev->keybit); - __set_bit(BTN_MIDDLE, input_dev->keybit); - __set_bit(BTN_RIGHT, input_dev->keybit); - __set_bit(BTN_TOOL_FINGER, input_dev->keybit); - __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); + if (features->device_type == BTN_TOOL_TRIPLETAP) { + __set_bit(BTN_LEFT, input_dev->keybit); + __set_bit(BTN_FORWARD, input_dev->keybit); + __set_bit(BTN_BACK, input_dev->keybit); + __set_bit(BTN_RIGHT, input_dev->keybit); - input_set_abs_params(input_dev, ABS_X, 0, features->x_max, 32, 0); - input_set_abs_params(input_dev, ABS_Y, 0, features->y_max, 32, 0); - input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, 16, 0); + __set_bit(BTN_TOOL_FINGER, input_dev->keybit); + __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); - input_mt_create_slots(input_dev, 2); - input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, features->x_max, 32, 0); - input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, features->y_max, 32, 0); - input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, features->pressure_max, 16, 0); - input_set_abs_params(input_dev, ABS_MT_TRACKING_ID, 0, MAX_TRACKING_ID, 0, 0); + input_mt_create_slots(input_dev, 2); + 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); + input_set_abs_params(input_dev, ABS_MT_PRESSURE, + 0, features->pressure_max, + features->pressure_fuzz, 0); + input_set_abs_params(input_dev, ABS_MT_TRACKING_ID, 0, + MAX_TRACKING_ID, 0, 0); + } break; } } @@ -1286,19 +1327,13 @@ static const struct wacom_features wacom_features_0xE3 = { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }; static const struct wacom_features wacom_features_0x47 = { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }; -static const struct wacom_features wacom_features_0xD0_0 = - { "Wacom Bamboo Touch", WACOM_PKGLEN_BBTOUCH, 7680, 5120, 255, 0, BAMBOO_TOUCH }; -static const struct wacom_features wacom_features_0xD0_2 = - { "Wacom Bamboo Boot", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO }; +static struct wacom_features wacom_features_0xD0 = + { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; #define USB_DEVICE_WACOM(prod) \ USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \ .driver_info = (kernel_ulong_t)&wacom_features_##prod -#define USB_DEVICE_WACOM_PROTO(prod, pr) \ - USB_DEVICE_INTERFACE_PROTOCOL(USB_VENDOR_ID_WACOM, prod, pr), \ - .driver_info = (kernel_ulong_t)&wacom_features_##prod##_##pr - const struct usb_device_id wacom_ids[] = { { USB_DEVICE_WACOM(0x00) }, { USB_DEVICE_WACOM(0x10) }, @@ -1358,8 +1393,7 @@ const struct usb_device_id wacom_ids[] = { { USB_DEVICE_WACOM(0xC6) }, { USB_DEVICE_WACOM(0xC7) }, { USB_DEVICE_WACOM(0xCE) }, - { USB_DEVICE_WACOM_PROTO(0xD0, 0) }, - { USB_DEVICE_WACOM_PROTO(0xD0, 2) }, + { USB_DEVICE_WACOM(0xD0) }, { USB_DEVICE_WACOM(0xF0) }, { USB_DEVICE_WACOM(0xCC) }, { USB_DEVICE_WACOM(0x90) }, diff --git a/usr/src/dkms_source_tree/wacom_wac.h b/usr/src/dkms_source_tree/wacom_wac.h index 0c5a35d..00ca015 100644 --- a/usr/src/dkms_source_tree/wacom_wac.h +++ b/usr/src/dkms_source_tree/wacom_wac.h @@ -38,6 +38,10 @@ #define WACOM_REPORT_TPC1FG 6 #define WACOM_REPORT_TPC2FG 13 +/* device quirks */ +#define WACOM_QUIRK_MULTI_INPUT 0x0001 +#define WACOM_QUIRK_BBTOUCH_LOWRES 0x0002 + /* largest reported tracking id */ #define MAX_TRACKING_ID 0xfff @@ -48,6 +52,7 @@ enum { PTU, PL, DTU, + BAMBOO_PT, INTUOS, INTUOS3S, INTUOS3, @@ -61,7 +66,6 @@ enum { WACOM_MO, TABLETPC, TABLETPC2FG, - BAMBOO_TOUCH, MAX_TYPE }; @@ -78,6 +82,11 @@ struct wacom_features { int y_phy; unsigned char unit; unsigned char unitExpo; + int x_fuzz; + int y_fuzz; + int pressure_fuzz; + int distance_fuzz; + unsigned quirks; }; struct wacom_shared { @@ -91,6 +100,7 @@ struct wacom_wac { int id[3]; __u32 serial[2]; int last_finger; + int trk_id; struct wacom_features features; struct wacom_shared *shared; struct input_dev *input; -- cgit v1.2.3