diff options
| author | Ping Cheng <pinglinux@gmail.com> | 2013-01-05 02:56:00 -0500 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-01-06 04:11:02 -0500 |
| commit | 02295e68cf6ae81e94fbcfa61afde299ded593b1 (patch) | |
| tree | a4780191d3694569ae4fae8bea86470f5f093ff9 | |
| parent | 8c0e0a4fa88f53d80ae8c410a9e2e364a96941a4 (diff) | |
Input: wacom - use new input-mt routines
This patch brings wacom driver in-sync with input-mt changes
made in release 3.7.
Signed-off-by: Ping Cheng <pingc@wacom.com>
Reviewed-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
| -rw-r--r-- | drivers/input/tablet/wacom_wac.c | 82 | ||||
| -rw-r--r-- | drivers/input/tablet/wacom_wac.h | 1 |
2 files changed, 22 insertions, 61 deletions
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 097b559ea838..a318bf4ada05 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c | |||
| @@ -785,25 +785,6 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) | |||
| 785 | return 1; | 785 | return 1; |
| 786 | } | 786 | } |
| 787 | 787 | ||
| 788 | static int find_slot_from_contactid(struct wacom_wac *wacom, int contactid) | ||
| 789 | { | ||
| 790 | int touch_max = wacom->features.touch_max; | ||
| 791 | int i; | ||
| 792 | |||
| 793 | if (!wacom->slots) | ||
| 794 | return -1; | ||
| 795 | |||
| 796 | for (i = 0; i < touch_max; ++i) { | ||
| 797 | if (wacom->slots[i] == contactid) | ||
| 798 | return i; | ||
| 799 | } | ||
| 800 | for (i = 0; i < touch_max; ++i) { | ||
| 801 | if (wacom->slots[i] == -1) | ||
| 802 | return i; | ||
| 803 | } | ||
| 804 | return -1; | ||
| 805 | } | ||
| 806 | |||
| 807 | static int int_dist(int x1, int y1, int x2, int y2) | 788 | static int int_dist(int x1, int y1, int x2, int y2) |
| 808 | { | 789 | { |
| 809 | int x = x2 - x1; | 790 | int x = x2 - x1; |
| @@ -833,8 +814,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom) | |||
| 833 | for (i = 0; i < contacts_to_send; i++) { | 814 | for (i = 0; i < contacts_to_send; i++) { |
| 834 | int offset = (WACOM_BYTES_PER_24HDT_PACKET * i) + 1; | 815 | int offset = (WACOM_BYTES_PER_24HDT_PACKET * i) + 1; |
| 835 | bool touch = data[offset] & 0x1 && !wacom->shared->stylus_in_proximity; | 816 | bool touch = data[offset] & 0x1 && !wacom->shared->stylus_in_proximity; |
| 836 | int id = data[offset + 1]; | 817 | int slot = input_mt_get_slot_by_key(input, data[offset + 1]); |
| 837 | int slot = find_slot_from_contactid(wacom, id); | ||
| 838 | 818 | ||
| 839 | if (slot < 0) | 819 | if (slot < 0) |
| 840 | continue; | 820 | continue; |
| @@ -856,9 +836,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom) | |||
| 856 | input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h)); | 836 | input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h)); |
| 857 | input_report_abs(input, ABS_MT_ORIENTATION, w > h); | 837 | input_report_abs(input, ABS_MT_ORIENTATION, w > h); |
| 858 | } | 838 | } |
| 859 | wacom->slots[slot] = touch ? id : -1; | ||
| 860 | } | 839 | } |
| 861 | |||
| 862 | input_mt_report_pointer_emulation(input, true); | 840 | input_mt_report_pointer_emulation(input, true); |
| 863 | 841 | ||
| 864 | wacom->num_contacts_left -= contacts_to_send; | 842 | wacom->num_contacts_left -= contacts_to_send; |
| @@ -895,7 +873,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom) | |||
| 895 | int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3; | 873 | int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3; |
| 896 | bool touch = data[offset] & 0x1; | 874 | bool touch = data[offset] & 0x1; |
| 897 | int id = le16_to_cpup((__le16 *)&data[offset + 1]); | 875 | int id = le16_to_cpup((__le16 *)&data[offset + 1]); |
| 898 | int slot = find_slot_from_contactid(wacom, id); | 876 | int slot = input_mt_get_slot_by_key(input, id); |
| 899 | 877 | ||
| 900 | if (slot < 0) | 878 | if (slot < 0) |
| 901 | continue; | 879 | continue; |
| @@ -908,9 +886,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom) | |||
| 908 | input_report_abs(input, ABS_MT_POSITION_X, x); | 886 | input_report_abs(input, ABS_MT_POSITION_X, x); |
| 909 | input_report_abs(input, ABS_MT_POSITION_Y, y); | 887 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
| 910 | } | 888 | } |
| 911 | wacom->slots[slot] = touch ? id : -1; | ||
| 912 | } | 889 | } |
| 913 | |||
| 914 | input_mt_report_pointer_emulation(input, true); | 890 | input_mt_report_pointer_emulation(input, true); |
| 915 | 891 | ||
| 916 | wacom->num_contacts_left -= contacts_to_send; | 892 | wacom->num_contacts_left -= contacts_to_send; |
| @@ -942,12 +918,11 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom) | |||
| 942 | contact_with_no_pen_down_count++; | 918 | contact_with_no_pen_down_count++; |
| 943 | } | 919 | } |
| 944 | } | 920 | } |
| 921 | input_mt_report_pointer_emulation(input, true); | ||
| 945 | 922 | ||
| 946 | /* keep touch state for pen event */ | 923 | /* keep touch state for pen event */ |
| 947 | wacom->shared->touch_down = (contact_with_no_pen_down_count > 0); | 924 | wacom->shared->touch_down = (contact_with_no_pen_down_count > 0); |
| 948 | 925 | ||
| 949 | input_mt_report_pointer_emulation(input, true); | ||
| 950 | |||
| 951 | return 1; | 926 | return 1; |
| 952 | } | 927 | } |
| 953 | 928 | ||
| @@ -1104,12 +1079,15 @@ static int wacom_bpt_touch(struct wacom_wac *wacom) | |||
| 1104 | static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) | 1079 | static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) |
| 1105 | { | 1080 | { |
| 1106 | struct input_dev *input = wacom->input; | 1081 | struct input_dev *input = wacom->input; |
| 1107 | int slot_id = data[0] - 2; /* data[0] is between 2 and 17 */ | ||
| 1108 | bool touch = data[1] & 0x80; | 1082 | bool touch = data[1] & 0x80; |
| 1083 | int slot = input_mt_get_slot_by_key(input, data[0]); | ||
| 1084 | |||
| 1085 | if (slot < 0) | ||
| 1086 | return; | ||
| 1109 | 1087 | ||
| 1110 | touch = touch && !wacom->shared->stylus_in_proximity; | 1088 | touch = touch && !wacom->shared->stylus_in_proximity; |
| 1111 | 1089 | ||
| 1112 | input_mt_slot(input, slot_id); | 1090 | input_mt_slot(input, slot); |
| 1113 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); | 1091 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
| 1114 | 1092 | ||
| 1115 | if (touch) { | 1093 | if (touch) { |
| @@ -1162,7 +1140,6 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom) | |||
| 1162 | wacom_bpt3_button_msg(wacom, data + offset); | 1140 | wacom_bpt3_button_msg(wacom, data + offset); |
| 1163 | 1141 | ||
| 1164 | } | 1142 | } |
| 1165 | |||
| 1166 | input_mt_report_pointer_emulation(input, true); | 1143 | input_mt_report_pointer_emulation(input, true); |
| 1167 | 1144 | ||
| 1168 | input_sync(input); | 1145 | input_sync(input); |
| @@ -1639,17 +1616,11 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
| 1639 | } else if (features->device_type == BTN_TOOL_FINGER) { | 1616 | } else if (features->device_type == BTN_TOOL_FINGER) { |
| 1640 | __clear_bit(ABS_MISC, input_dev->absbit); | 1617 | __clear_bit(ABS_MISC, input_dev->absbit); |
| 1641 | 1618 | ||
| 1642 | __set_bit(BTN_TOOL_FINGER, input_dev->keybit); | ||
| 1643 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); | ||
| 1644 | __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); | ||
| 1645 | __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); | ||
| 1646 | |||
| 1647 | input_mt_init_slots(input_dev, features->touch_max, 0); | ||
| 1648 | |||
| 1649 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, | 1619 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, |
| 1650 | 0, features->x_max, 0, 0); | 1620 | 0, features->x_max, 0, 0); |
| 1651 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, | 1621 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, |
| 1652 | 0, features->y_max, 0, 0); | 1622 | 0, features->y_max, 0, 0); |
| 1623 | input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); | ||
| 1653 | } | 1624 | } |
| 1654 | break; | 1625 | break; |
| 1655 | 1626 | ||
| @@ -1680,21 +1651,14 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
| 1680 | 1651 | ||
| 1681 | case MTSCREEN: | 1652 | case MTSCREEN: |
| 1682 | case MTTPC: | 1653 | case MTTPC: |
| 1683 | if (features->device_type == BTN_TOOL_FINGER) { | ||
| 1684 | wacom_wac->slots = kmalloc(features->touch_max * | ||
| 1685 | sizeof(int), | ||
| 1686 | GFP_KERNEL); | ||
| 1687 | if (!wacom_wac->slots) | ||
| 1688 | return -ENOMEM; | ||
| 1689 | |||
| 1690 | for (i = 0; i < features->touch_max; i++) | ||
| 1691 | wacom_wac->slots[i] = -1; | ||
| 1692 | } | ||
| 1693 | /* fall through */ | ||
| 1694 | |||
| 1695 | case TABLETPC2FG: | 1654 | case TABLETPC2FG: |
| 1696 | if (features->device_type == BTN_TOOL_FINGER) { | 1655 | if (features->device_type == BTN_TOOL_FINGER) { |
| 1697 | input_mt_init_slots(input_dev, features->touch_max, 0); | 1656 | unsigned int flags = INPUT_MT_DIRECT; |
| 1657 | |||
| 1658 | if (wacom_wac->features.type == TABLETPC2FG) | ||
| 1659 | flags = 0; | ||
| 1660 | |||
| 1661 | input_mt_init_slots(input_dev, features->touch_max, flags); | ||
| 1698 | } | 1662 | } |
| 1699 | /* fall through */ | 1663 | /* fall through */ |
| 1700 | 1664 | ||
| @@ -1737,28 +1701,26 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
| 1737 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); | 1701 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); |
| 1738 | 1702 | ||
| 1739 | if (features->device_type == BTN_TOOL_FINGER) { | 1703 | if (features->device_type == BTN_TOOL_FINGER) { |
| 1704 | unsigned int flags = INPUT_MT_POINTER; | ||
| 1705 | |||
| 1740 | __set_bit(BTN_LEFT, input_dev->keybit); | 1706 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 1741 | __set_bit(BTN_FORWARD, input_dev->keybit); | 1707 | __set_bit(BTN_FORWARD, input_dev->keybit); |
| 1742 | __set_bit(BTN_BACK, input_dev->keybit); | 1708 | __set_bit(BTN_BACK, input_dev->keybit); |
| 1743 | __set_bit(BTN_RIGHT, input_dev->keybit); | 1709 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 1744 | 1710 | ||
| 1745 | __set_bit(BTN_TOOL_FINGER, input_dev->keybit); | ||
| 1746 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); | ||
| 1747 | input_mt_init_slots(input_dev, features->touch_max, 0); | ||
| 1748 | |||
| 1749 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { | 1711 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { |
| 1750 | __set_bit(BTN_TOOL_TRIPLETAP, | ||
| 1751 | input_dev->keybit); | ||
| 1752 | __set_bit(BTN_TOOL_QUADTAP, | ||
| 1753 | input_dev->keybit); | ||
| 1754 | |||
| 1755 | input_set_abs_params(input_dev, | 1712 | input_set_abs_params(input_dev, |
| 1756 | ABS_MT_TOUCH_MAJOR, | 1713 | ABS_MT_TOUCH_MAJOR, |
| 1757 | 0, features->x_max, 0, 0); | 1714 | 0, features->x_max, 0, 0); |
| 1758 | input_set_abs_params(input_dev, | 1715 | input_set_abs_params(input_dev, |
| 1759 | ABS_MT_TOUCH_MINOR, | 1716 | ABS_MT_TOUCH_MINOR, |
| 1760 | 0, features->y_max, 0, 0); | 1717 | 0, features->y_max, 0, 0); |
| 1718 | } else { | ||
| 1719 | __set_bit(BTN_TOOL_FINGER, input_dev->keybit); | ||
| 1720 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); | ||
| 1721 | flags = 0; | ||
| 1761 | } | 1722 | } |
| 1723 | input_mt_init_slots(input_dev, features->touch_max, flags); | ||
| 1762 | } else if (features->device_type == BTN_TOOL_PEN) { | 1724 | } else if (features->device_type == BTN_TOOL_PEN) { |
| 1763 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); | 1725 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
| 1764 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); | 1726 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h index 9396d7769f86..06410fe6425f 100644 --- a/drivers/input/tablet/wacom_wac.h +++ b/drivers/input/tablet/wacom_wac.h | |||
| @@ -135,7 +135,6 @@ struct wacom_wac { | |||
| 135 | int pid; | 135 | int pid; |
| 136 | int battery_capacity; | 136 | int battery_capacity; |
| 137 | int num_contacts_left; | 137 | int num_contacts_left; |
| 138 | int *slots; | ||
| 139 | }; | 138 | }; |
| 140 | 139 | ||
| 141 | #endif | 140 | #endif |
