diff options
author | Benjamin Tissoires <benjamin.tissoires@redhat.com> | 2014-08-06 16:52:56 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-08-06 17:18:11 -0400 |
commit | 387142bb8fcb263771e1fa6b1a96e6a7ca36e820 (patch) | |
tree | ef23bfa3991b5d35c7fec71c767d5bf5de2f5217 /drivers | |
parent | f81a1295cd9b6d3d3d7d7126e522d80917134b41 (diff) |
Input: wacom - handle Graphire BT tablets in wacom.ko
First, merge the Graphire BT tablet.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: Ping Cheng <pingc@wacom.com>
Tested-by: Przemo Firszt <przemo@firszt.eu>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hid/hid-core.c | 1 | ||||
-rw-r--r-- | drivers/hid/hid-wacom.c | 1 | ||||
-rw-r--r-- | drivers/hid/wacom_sys.c | 33 | ||||
-rw-r--r-- | drivers/hid/wacom_wac.c | 100 | ||||
-rw-r--r-- | drivers/hid/wacom_wac.h | 2 |
5 files changed, 132 insertions, 5 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 1ce751db5a7a..cbabd8786e71 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1942,7 +1942,6 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1942 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) }, | 1942 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO) }, |
1943 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) }, | 1943 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_DUAL_BOX_PRO) }, |
1944 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) }, | 1944 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO) }, |
1945 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, | ||
1946 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, | 1945 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, |
1947 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, | 1946 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, |
1948 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, | 1947 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, |
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 4874f4ec43f5..967c457a2785 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c | |||
@@ -952,7 +952,6 @@ static void wacom_remove(struct hid_device *hdev) | |||
952 | } | 952 | } |
953 | 953 | ||
954 | static const struct hid_device_id wacom_devices[] = { | 954 | static const struct hid_device_id wacom_devices[] = { |
955 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, | ||
956 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, | 955 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, |
957 | 956 | ||
958 | { } | 957 | { } |
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 18154a5459b5..c21e58ba0693 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c | |||
@@ -265,6 +265,39 @@ static int wacom_set_device_mode(struct hid_device *hdev, int report_id, | |||
265 | static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed, | 265 | static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed, |
266 | struct wacom_features *features) | 266 | struct wacom_features *features) |
267 | { | 267 | { |
268 | struct wacom *wacom = hid_get_drvdata(hdev); | ||
269 | int ret; | ||
270 | u8 rep_data[2]; | ||
271 | |||
272 | switch (features->type) { | ||
273 | case GRAPHIRE_BT: | ||
274 | rep_data[0] = 0x03; | ||
275 | rep_data[1] = 0x00; | ||
276 | ret = wacom_set_report(hdev, HID_FEATURE_REPORT, | ||
277 | rep_data[0], rep_data, 2, 3); | ||
278 | |||
279 | if (ret >= 0) { | ||
280 | rep_data[0] = speed == 0 ? 0x05 : 0x06; | ||
281 | rep_data[1] = 0x00; | ||
282 | |||
283 | ret = wacom_set_report(hdev, HID_FEATURE_REPORT, | ||
284 | rep_data[0], rep_data, 2, 3); | ||
285 | |||
286 | if (ret >= 0) { | ||
287 | wacom->wacom_wac.bt_high_speed = speed; | ||
288 | return 0; | ||
289 | } | ||
290 | } | ||
291 | |||
292 | /* | ||
293 | * Note that if the raw queries fail, it's not a hard failure | ||
294 | * and it is safe to continue | ||
295 | */ | ||
296 | hid_warn(hdev, "failed to poke device, command %d, err %d\n", | ||
297 | rep_data[0], ret); | ||
298 | break; | ||
299 | } | ||
300 | |||
268 | return 0; | 301 | return 0; |
269 | } | 302 | } |
270 | 303 | ||
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 71646b311867..fa16a5bf3df3 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c | |||
@@ -25,11 +25,18 @@ | |||
25 | #define WACOM_INTUOS_RES 100 | 25 | #define WACOM_INTUOS_RES 100 |
26 | #define WACOM_INTUOS3_RES 200 | 26 | #define WACOM_INTUOS3_RES 200 |
27 | 27 | ||
28 | /* Scale factor relating reported contact size to logical contact area. | 28 | /* |
29 | * Scale factor relating reported contact size to logical contact area. | ||
29 | * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo | 30 | * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo |
30 | */ | 31 | */ |
31 | #define WACOM_CONTACT_AREA_SCALE 2607 | 32 | #define WACOM_CONTACT_AREA_SCALE 2607 |
32 | 33 | ||
34 | /* | ||
35 | * Percent of battery capacity for Graphire. | ||
36 | * 8th value means AC online and show 100% capacity. | ||
37 | */ | ||
38 | static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 }; | ||
39 | |||
33 | static int wacom_penpartner_irq(struct wacom_wac *wacom) | 40 | static int wacom_penpartner_irq(struct wacom_wac *wacom) |
34 | { | 41 | { |
35 | unsigned char *data = wacom->data; | 42 | unsigned char *data = wacom->data; |
@@ -263,11 +270,19 @@ static int wacom_graphire_irq(struct wacom_wac *wacom) | |||
263 | unsigned char *data = wacom->data; | 270 | unsigned char *data = wacom->data; |
264 | struct input_dev *input = wacom->input; | 271 | struct input_dev *input = wacom->input; |
265 | struct input_dev *pad_input = wacom->pad_input; | 272 | struct input_dev *pad_input = wacom->pad_input; |
273 | int battery_capacity, ps_connected; | ||
266 | int prox; | 274 | int prox; |
267 | int rw = 0; | 275 | int rw = 0; |
268 | int retval = 0; | 276 | int retval = 0; |
269 | 277 | ||
270 | if (data[0] != WACOM_REPORT_PENABLED) { | 278 | if (features->type == GRAPHIRE_BT) { |
279 | if (data[0] != WACOM_REPORT_PENABLED_BT) { | ||
280 | dev_dbg(input->dev.parent, | ||
281 | "%s: received unknown report #%d\n", __func__, | ||
282 | data[0]); | ||
283 | goto exit; | ||
284 | } | ||
285 | } else if (data[0] != WACOM_REPORT_PENABLED) { | ||
271 | dev_dbg(input->dev.parent, | 286 | dev_dbg(input->dev.parent, |
272 | "%s: received unknown report #%d\n", __func__, data[0]); | 287 | "%s: received unknown report #%d\n", __func__, data[0]); |
273 | goto exit; | 288 | goto exit; |
@@ -301,7 +316,12 @@ static int wacom_graphire_irq(struct wacom_wac *wacom) | |||
301 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); | 316 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
302 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); | 317 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
303 | if (wacom->tool[0] != BTN_TOOL_MOUSE) { | 318 | if (wacom->tool[0] != BTN_TOOL_MOUSE) { |
304 | input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x03) << 8)); | 319 | if (features->type == GRAPHIRE_BT) |
320 | input_report_abs(input, ABS_PRESSURE, data[6] | | ||
321 | (((__u16) (data[1] & 0x08)) << 5)); | ||
322 | else | ||
323 | input_report_abs(input, ABS_PRESSURE, data[6] | | ||
324 | ((data[7] & 0x03) << 8)); | ||
305 | input_report_key(input, BTN_TOUCH, data[1] & 0x01); | 325 | input_report_key(input, BTN_TOUCH, data[1] & 0x01); |
306 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); | 326 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
307 | input_report_key(input, BTN_STYLUS2, data[1] & 0x04); | 327 | input_report_key(input, BTN_STYLUS2, data[1] & 0x04); |
@@ -312,6 +332,20 @@ static int wacom_graphire_irq(struct wacom_wac *wacom) | |||
312 | features->type == WACOM_MO) { | 332 | features->type == WACOM_MO) { |
313 | input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f); | 333 | input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f); |
314 | rw = (data[7] & 0x04) - (data[7] & 0x03); | 334 | rw = (data[7] & 0x04) - (data[7] & 0x03); |
335 | } else if (features->type == GRAPHIRE_BT) { | ||
336 | /* Compute distance between mouse and tablet */ | ||
337 | rw = 44 - (data[6] >> 2); | ||
338 | rw = clamp_val(rw, 0, 31); | ||
339 | input_report_abs(input, ABS_DISTANCE, rw); | ||
340 | if (((data[1] >> 5) & 3) == 2) { | ||
341 | /* Mouse with wheel */ | ||
342 | input_report_key(input, BTN_MIDDLE, | ||
343 | data[1] & 0x04); | ||
344 | rw = (data[6] & 0x01) ? -1 : | ||
345 | (data[6] & 0x02) ? 1 : 0; | ||
346 | } else { | ||
347 | rw = 0; | ||
348 | } | ||
315 | } else { | 349 | } else { |
316 | input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f); | 350 | input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f); |
317 | rw = -(signed char)data[6]; | 351 | rw = -(signed char)data[6]; |
@@ -358,6 +392,31 @@ static int wacom_graphire_irq(struct wacom_wac *wacom) | |||
358 | retval = 1; | 392 | retval = 1; |
359 | } | 393 | } |
360 | break; | 394 | break; |
395 | case GRAPHIRE_BT: | ||
396 | prox = data[7] & 0x03; | ||
397 | if (prox || wacom->id[1]) { | ||
398 | wacom->id[1] = PAD_DEVICE_ID; | ||
399 | input_report_key(pad_input, BTN_0, (data[7] & 0x02)); | ||
400 | input_report_key(pad_input, BTN_1, (data[7] & 0x01)); | ||
401 | if (!prox) | ||
402 | wacom->id[1] = 0; | ||
403 | input_report_abs(pad_input, ABS_MISC, wacom->id[1]); | ||
404 | retval = 1; | ||
405 | } | ||
406 | break; | ||
407 | } | ||
408 | |||
409 | /* Store current battery capacity and power supply state */ | ||
410 | if (features->type == GRAPHIRE_BT) { | ||
411 | rw = (data[7] >> 2 & 0x07); | ||
412 | battery_capacity = batcap_gr[rw]; | ||
413 | ps_connected = rw == 7; | ||
414 | if ((wacom->battery_capacity != battery_capacity) || | ||
415 | (wacom->ps_connected != ps_connected)) { | ||
416 | wacom->battery_capacity = battery_capacity; | ||
417 | wacom->ps_connected = ps_connected; | ||
418 | wacom_notify_battery(wacom); | ||
419 | } | ||
361 | } | 420 | } |
362 | exit: | 421 | exit: |
363 | return retval; | 422 | return retval; |
@@ -1418,6 +1477,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) | |||
1418 | 1477 | ||
1419 | case WACOM_G4: | 1478 | case WACOM_G4: |
1420 | case GRAPHIRE: | 1479 | case GRAPHIRE: |
1480 | case GRAPHIRE_BT: | ||
1421 | case WACOM_MO: | 1481 | case WACOM_MO: |
1422 | sync = wacom_graphire_irq(wacom_wac); | 1482 | sync = wacom_graphire_irq(wacom_wac); |
1423 | break; | 1483 | break; |
@@ -1654,6 +1714,27 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
1654 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); | 1714 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); |
1655 | break; | 1715 | break; |
1656 | 1716 | ||
1717 | case GRAPHIRE_BT: | ||
1718 | __clear_bit(ABS_MISC, input_dev->absbit); | ||
1719 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, | ||
1720 | features->distance_max, | ||
1721 | 0, 0); | ||
1722 | |||
1723 | input_set_capability(input_dev, EV_REL, REL_WHEEL); | ||
1724 | |||
1725 | __set_bit(BTN_LEFT, input_dev->keybit); | ||
1726 | __set_bit(BTN_RIGHT, input_dev->keybit); | ||
1727 | __set_bit(BTN_MIDDLE, input_dev->keybit); | ||
1728 | |||
1729 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); | ||
1730 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); | ||
1731 | __set_bit(BTN_TOOL_MOUSE, input_dev->keybit); | ||
1732 | __set_bit(BTN_STYLUS, input_dev->keybit); | ||
1733 | __set_bit(BTN_STYLUS2, input_dev->keybit); | ||
1734 | |||
1735 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); | ||
1736 | break; | ||
1737 | |||
1657 | case WACOM_24HD: | 1738 | case WACOM_24HD: |
1658 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); | 1739 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); |
1659 | input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0); | 1740 | input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0); |
@@ -1862,6 +1943,11 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, | |||
1862 | input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0); | 1943 | input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0); |
1863 | 1944 | ||
1864 | switch (features->type) { | 1945 | switch (features->type) { |
1946 | case GRAPHIRE_BT: | ||
1947 | __set_bit(BTN_0, input_dev->keybit); | ||
1948 | __set_bit(BTN_1, input_dev->keybit); | ||
1949 | break; | ||
1950 | |||
1865 | case WACOM_MO: | 1951 | case WACOM_MO: |
1866 | __set_bit(BTN_BACK, input_dev->keybit); | 1952 | __set_bit(BTN_BACK, input_dev->keybit); |
1867 | __set_bit(BTN_LEFT, input_dev->keybit); | 1953 | __set_bit(BTN_LEFT, input_dev->keybit); |
@@ -2031,6 +2117,9 @@ static const struct wacom_features wacom_features_0x00 = | |||
2031 | static const struct wacom_features wacom_features_0x10 = | 2117 | static const struct wacom_features wacom_features_0x10 = |
2032 | { "Wacom Graphire", 10206, 7422, 511, 63, | 2118 | { "Wacom Graphire", 10206, 7422, 511, 63, |
2033 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; | 2119 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
2120 | static const struct wacom_features wacom_features_0x81 = | ||
2121 | { "Wacom Graphire BT", 16704, 12064, 511, 32, | ||
2122 | GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; | ||
2034 | static const struct wacom_features wacom_features_0x11 = | 2123 | static const struct wacom_features wacom_features_0x11 = |
2035 | { "Wacom Graphire2 4x5", 10206, 7422, 511, 63, | 2124 | { "Wacom Graphire2 4x5", 10206, 7422, 511, 63, |
2036 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; | 2125 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
@@ -2429,6 +2518,10 @@ static const struct wacom_features wacom_features_0x309 = | |||
2429 | HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ | 2518 | HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ |
2430 | .driver_data = (kernel_ulong_t)&wacom_features_##prod | 2519 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
2431 | 2520 | ||
2521 | #define BT_DEVICE_WACOM(prod) \ | ||
2522 | HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ | ||
2523 | .driver_data = (kernel_ulong_t)&wacom_features_##prod | ||
2524 | |||
2432 | #define USB_DEVICE_LENOVO(prod) \ | 2525 | #define USB_DEVICE_LENOVO(prod) \ |
2433 | HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \ | 2526 | HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \ |
2434 | .driver_data = (kernel_ulong_t)&wacom_features_##prod | 2527 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
@@ -2486,6 +2579,7 @@ const struct hid_device_id wacom_ids[] = { | |||
2486 | { USB_DEVICE_WACOM(0x69) }, | 2579 | { USB_DEVICE_WACOM(0x69) }, |
2487 | { USB_DEVICE_WACOM(0x6A) }, | 2580 | { USB_DEVICE_WACOM(0x6A) }, |
2488 | { USB_DEVICE_WACOM(0x6B) }, | 2581 | { USB_DEVICE_WACOM(0x6B) }, |
2582 | { BT_DEVICE_WACOM(0x81) }, | ||
2489 | { USB_DEVICE_WACOM(0x84) }, | 2583 | { USB_DEVICE_WACOM(0x84) }, |
2490 | { USB_DEVICE_WACOM(0x90) }, | 2584 | { USB_DEVICE_WACOM(0x90) }, |
2491 | { USB_DEVICE_WACOM(0x93) }, | 2585 | { USB_DEVICE_WACOM(0x93) }, |
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 6cefa1e8c14b..4f0178b9a789 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h | |||
@@ -46,6 +46,7 @@ | |||
46 | 46 | ||
47 | /* wacom data packet report IDs */ | 47 | /* wacom data packet report IDs */ |
48 | #define WACOM_REPORT_PENABLED 2 | 48 | #define WACOM_REPORT_PENABLED 2 |
49 | #define WACOM_REPORT_PENABLED_BT 3 | ||
49 | #define WACOM_REPORT_INTUOSREAD 5 | 50 | #define WACOM_REPORT_INTUOSREAD 5 |
50 | #define WACOM_REPORT_INTUOSWRITE 6 | 51 | #define WACOM_REPORT_INTUOSWRITE 6 |
51 | #define WACOM_REPORT_INTUOSPAD 12 | 52 | #define WACOM_REPORT_INTUOSPAD 12 |
@@ -73,6 +74,7 @@ | |||
73 | enum { | 74 | enum { |
74 | PENPARTNER = 0, | 75 | PENPARTNER = 0, |
75 | GRAPHIRE, | 76 | GRAPHIRE, |
77 | GRAPHIRE_BT, | ||
76 | WACOM_G4, | 78 | WACOM_G4, |
77 | PTU, | 79 | PTU, |
78 | PL, | 80 | PL, |