Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ping Cheng and committed by
Dmitry Torokhov
02295e68 8c0e0a4f

+22 -61
+22 -60
drivers/input/tablet/wacom_wac.c
··· 785 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 788 static int int_dist(int x1, int y1, int x2, int y2) 808 789 { 809 790 int x = x2 - x1; ··· 814 833 for (i = 0; i < contacts_to_send; i++) { 815 834 int offset = (WACOM_BYTES_PER_24HDT_PACKET * i) + 1; 816 835 bool touch = data[offset] & 0x1 && !wacom->shared->stylus_in_proximity; 817 - int id = data[offset + 1]; 818 - int slot = find_slot_from_contactid(wacom, id); 836 + int slot = input_mt_get_slot_by_key(input, data[offset + 1]); 819 837 820 838 if (slot < 0) 821 839 continue; ··· 836 856 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h)); 837 857 input_report_abs(input, ABS_MT_ORIENTATION, w > h); 838 858 } 839 - wacom->slots[slot] = touch ? id : -1; 840 859 } 841 - 842 860 input_mt_report_pointer_emulation(input, true); 843 861 844 862 wacom->num_contacts_left -= contacts_to_send; ··· 873 895 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3; 874 896 bool touch = data[offset] & 0x1; 875 897 int id = le16_to_cpup((__le16 *)&data[offset + 1]); 876 - int slot = find_slot_from_contactid(wacom, id); 898 + int slot = input_mt_get_slot_by_key(input, id); 877 899 878 900 if (slot < 0) 879 901 continue; ··· 886 908 input_report_abs(input, ABS_MT_POSITION_X, x); 887 909 input_report_abs(input, ABS_MT_POSITION_Y, y); 888 910 } 889 - wacom->slots[slot] = touch ? id : -1; 890 911 } 891 - 892 912 input_mt_report_pointer_emulation(input, true); 893 913 894 914 wacom->num_contacts_left -= contacts_to_send; ··· 918 942 contact_with_no_pen_down_count++; 919 943 } 920 944 } 945 + input_mt_report_pointer_emulation(input, true); 921 946 922 947 /* keep touch state for pen event */ 923 948 wacom->shared->touch_down = (contact_with_no_pen_down_count > 0); 924 - 925 - input_mt_report_pointer_emulation(input, true); 926 949 927 950 return 1; 928 951 } ··· 1079 1104 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) 1080 1105 { 1081 1106 struct input_dev *input = wacom->input; 1082 - int slot_id = data[0] - 2; /* data[0] is between 2 and 17 */ 1083 1107 bool touch = data[1] & 0x80; 1108 + int slot = input_mt_get_slot_by_key(input, data[0]); 1109 + 1110 + if (slot < 0) 1111 + return; 1084 1112 1085 1113 touch = touch && !wacom->shared->stylus_in_proximity; 1086 1114 1087 - input_mt_slot(input, slot_id); 1115 + input_mt_slot(input, slot); 1088 1116 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); 1089 1117 1090 1118 if (touch) { ··· 1140 1162 wacom_bpt3_button_msg(wacom, data + offset); 1141 1163 1142 1164 } 1143 - 1144 1165 input_mt_report_pointer_emulation(input, true); 1145 1166 1146 1167 input_sync(input); ··· 1616 1639 } else if (features->device_type == BTN_TOOL_FINGER) { 1617 1640 __clear_bit(ABS_MISC, input_dev->absbit); 1618 1641 1619 - __set_bit(BTN_TOOL_FINGER, input_dev->keybit); 1620 - __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); 1621 - __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); 1622 - __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); 1623 - 1624 - input_mt_init_slots(input_dev, features->touch_max, 0); 1625 - 1626 1642 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 1627 1643 0, features->x_max, 0, 0); 1628 1644 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 1629 1645 0, features->y_max, 0, 0); 1646 + input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); 1630 1647 } 1631 1648 break; 1632 1649 ··· 1651 1680 1652 1681 case MTSCREEN: 1653 1682 case MTTPC: 1654 - if (features->device_type == BTN_TOOL_FINGER) { 1655 - wacom_wac->slots = kmalloc(features->touch_max * 1656 - sizeof(int), 1657 - GFP_KERNEL); 1658 - if (!wacom_wac->slots) 1659 - return -ENOMEM; 1660 - 1661 - for (i = 0; i < features->touch_max; i++) 1662 - wacom_wac->slots[i] = -1; 1663 - } 1664 - /* fall through */ 1665 - 1666 1683 case TABLETPC2FG: 1667 1684 if (features->device_type == BTN_TOOL_FINGER) { 1668 - input_mt_init_slots(input_dev, features->touch_max, 0); 1685 + unsigned int flags = INPUT_MT_DIRECT; 1686 + 1687 + if (wacom_wac->features.type == TABLETPC2FG) 1688 + flags = 0; 1689 + 1690 + input_mt_init_slots(input_dev, features->touch_max, flags); 1669 1691 } 1670 1692 /* fall through */ 1671 1693 ··· 1701 1737 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 1702 1738 1703 1739 if (features->device_type == BTN_TOOL_FINGER) { 1740 + unsigned int flags = INPUT_MT_POINTER; 1741 + 1704 1742 __set_bit(BTN_LEFT, input_dev->keybit); 1705 1743 __set_bit(BTN_FORWARD, input_dev->keybit); 1706 1744 __set_bit(BTN_BACK, input_dev->keybit); 1707 1745 __set_bit(BTN_RIGHT, input_dev->keybit); 1708 1746 1709 - __set_bit(BTN_TOOL_FINGER, input_dev->keybit); 1710 - __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); 1711 - input_mt_init_slots(input_dev, features->touch_max, 0); 1712 - 1713 1747 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { 1714 - __set_bit(BTN_TOOL_TRIPLETAP, 1715 - input_dev->keybit); 1716 - __set_bit(BTN_TOOL_QUADTAP, 1717 - input_dev->keybit); 1718 - 1719 1748 input_set_abs_params(input_dev, 1720 1749 ABS_MT_TOUCH_MAJOR, 1721 1750 0, features->x_max, 0, 0); 1722 1751 input_set_abs_params(input_dev, 1723 1752 ABS_MT_TOUCH_MINOR, 1724 1753 0, features->y_max, 0, 0); 1754 + } else { 1755 + __set_bit(BTN_TOOL_FINGER, input_dev->keybit); 1756 + __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); 1757 + flags = 0; 1725 1758 } 1759 + input_mt_init_slots(input_dev, features->touch_max, flags); 1726 1760 } else if (features->device_type == BTN_TOOL_PEN) { 1727 1761 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 1728 1762 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
-1
drivers/input/tablet/wacom_wac.h
··· 135 135 int pid; 136 136 int battery_capacity; 137 137 int num_contacts_left; 138 - int *slots; 139 138 }; 140 139 141 140 #endif