diff options
Diffstat (limited to 'drivers/hid/wacom_wac.c')
-rw-r--r-- | drivers/hid/wacom_wac.c | 100 |
1 files changed, 97 insertions, 3 deletions
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) }, |