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

Configure Feed

Select the types of activity you want to include in your feed.

Input: atmel_mxt_ts - support capacitive keys

Add support for touch keys found in some Atmel touch controller
configurations.

Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: André Apitzsch <git@apitzsch.eu>
Link: https://lore.kernel.org/r/20230407-atmel_keys-v2-2-92446a4343cb@apitzsch.eu
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

André Apitzsch and committed by
Dmitry Torokhov
97804321 272a2618

+85
+85
drivers/input/touchscreen/atmel_mxt_ts.c
··· 55 55 #define MXT_TOUCH_KEYARRAY_T15 15 56 56 #define MXT_TOUCH_PROXIMITY_T23 23 57 57 #define MXT_TOUCH_PROXKEY_T52 52 58 + #define MXT_TOUCH_PTC_KEYS_T97 97 58 59 #define MXT_PROCI_GRIPFACE_T20 20 59 60 #define MXT_PROCG_NOISE_T22 22 60 61 #define MXT_PROCI_ONETOUCH_T24 24 ··· 327 326 u16 T71_address; 328 327 u8 T9_reportid_min; 329 328 u8 T9_reportid_max; 329 + u8 T15_reportid_min; 330 + u8 T15_reportid_max; 330 331 u16 T18_address; 331 332 u8 T19_reportid; 332 333 u16 T44_address; 334 + u8 T97_reportid_min; 335 + u8 T97_reportid_max; 333 336 u8 T100_reportid_min; 334 337 u8 T100_reportid_max; 335 338 ··· 348 343 349 344 u32 *t19_keymap; 350 345 unsigned int t19_num_keys; 346 + 347 + u32 *t15_keymap; 348 + unsigned int t15_num_keys; 351 349 352 350 enum mxt_suspend_mode suspend_mode; 353 351 ··· 383 375 case MXT_TOUCH_KEYARRAY_T15: 384 376 case MXT_TOUCH_PROXIMITY_T23: 385 377 case MXT_TOUCH_PROXKEY_T52: 378 + case MXT_TOUCH_PTC_KEYS_T97: 386 379 case MXT_TOUCH_MULTITOUCHSCREEN_T100: 387 380 case MXT_PROCI_GRIPFACE_T20: 388 381 case MXT_PROCG_NOISE_T22: ··· 900 891 data->update_input = true; 901 892 } 902 893 894 + static void mxt_proc_t15_messages(struct mxt_data *data, u8 *message) 895 + { 896 + struct input_dev *input_dev = data->input_dev; 897 + unsigned long keystates = get_unaligned_le32(&message[2]); 898 + int key; 899 + 900 + for (key = 0; key < data->t15_num_keys; key++) 901 + input_report_key(input_dev, data->t15_keymap[key], 902 + keystates & BIT(key)); 903 + 904 + data->update_input = true; 905 + } 906 + 907 + static void mxt_proc_t97_messages(struct mxt_data *data, u8 *message) 908 + { 909 + mxt_proc_t15_messages(data, message); 910 + } 911 + 903 912 static void mxt_proc_t100_message(struct mxt_data *data, u8 *message) 904 913 { 905 914 struct device *dev = &data->client->dev; ··· 1044 1017 } else if (report_id >= data->T9_reportid_min && 1045 1018 report_id <= data->T9_reportid_max) { 1046 1019 mxt_proc_t9_message(data, message); 1020 + } else if (report_id >= data->T15_reportid_min && 1021 + report_id <= data->T15_reportid_max) { 1022 + mxt_proc_t15_messages(data, message); 1023 + } else if (report_id >= data->T97_reportid_min && 1024 + report_id <= data->T97_reportid_max) { 1025 + mxt_proc_t97_messages(data, message); 1047 1026 } else if (report_id >= data->T100_reportid_min && 1048 1027 report_id <= data->T100_reportid_max) { 1049 1028 mxt_proc_t100_message(data, message); ··· 1722 1689 data->T71_address = 0; 1723 1690 data->T9_reportid_min = 0; 1724 1691 data->T9_reportid_max = 0; 1692 + data->T15_reportid_min = 0; 1693 + data->T15_reportid_max = 0; 1725 1694 data->T18_address = 0; 1726 1695 data->T19_reportid = 0; 1727 1696 data->T44_address = 0; 1697 + data->T97_reportid_min = 0; 1698 + data->T97_reportid_max = 0; 1728 1699 data->T100_reportid_min = 0; 1729 1700 data->T100_reportid_max = 0; 1730 1701 data->max_reportid = 0; ··· 1801 1764 object->num_report_ids - 1; 1802 1765 data->num_touchids = object->num_report_ids; 1803 1766 break; 1767 + case MXT_TOUCH_KEYARRAY_T15: 1768 + data->T15_reportid_min = min_id; 1769 + data->T15_reportid_max = max_id; 1770 + break; 1804 1771 case MXT_SPT_COMMSCONFIG_T18: 1805 1772 data->T18_address = object->start_address; 1806 1773 break; ··· 1813 1772 break; 1814 1773 case MXT_SPT_GPIOPWM_T19: 1815 1774 data->T19_reportid = min_id; 1775 + break; 1776 + case MXT_TOUCH_PTC_KEYS_T97: 1777 + data->T97_reportid_min = min_id; 1778 + data->T97_reportid_max = max_id; 1816 1779 break; 1817 1780 case MXT_TOUCH_MULTITOUCHSCREEN_T100: 1818 1781 data->multitouch = MXT_TOUCH_MULTITOUCHSCREEN_T100; ··· 2095 2050 int error; 2096 2051 unsigned int num_mt_slots; 2097 2052 unsigned int mt_flags = 0; 2053 + int i; 2098 2054 2099 2055 switch (data->multitouch) { 2100 2056 case MXT_TOUCH_MULTI_T9: ··· 2140 2094 input_dev->dev.parent = dev; 2141 2095 input_dev->open = mxt_input_open; 2142 2096 input_dev->close = mxt_input_close; 2097 + 2098 + input_dev->keycode = data->t15_keymap; 2099 + input_dev->keycodemax = data->t15_num_keys; 2100 + input_dev->keycodesize = sizeof(data->t15_keymap[0]); 2143 2101 2144 2102 input_set_capability(input_dev, EV_KEY, BTN_TOUCH); 2145 2103 ··· 2210 2160 data->t100_aux_vect) { 2211 2161 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 2212 2162 0, 255, 0, 0); 2163 + } 2164 + 2165 + /* For T15 and T97 Key Array */ 2166 + if (data->T15_reportid_min || data->T97_reportid_min) { 2167 + for (i = 0; i < data->t15_num_keys; i++) 2168 + input_set_capability(input_dev, 2169 + EV_KEY, data->t15_keymap[i]); 2213 2170 } 2214 2171 2215 2172 input_set_drvdata(input_dev, data); ··· 3137 3080 static int mxt_parse_device_properties(struct mxt_data *data) 3138 3081 { 3139 3082 static const char keymap_property[] = "linux,gpio-keymap"; 3083 + static const char buttons_property[] = "linux,keycodes"; 3140 3084 struct device *dev = &data->client->dev; 3141 3085 u32 *keymap; 3086 + u32 *buttonmap; 3142 3087 int n_keys; 3143 3088 int error; 3144 3089 ··· 3168 3109 3169 3110 data->t19_keymap = keymap; 3170 3111 data->t19_num_keys = n_keys; 3112 + } 3113 + 3114 + if (device_property_present(dev, buttons_property)) { 3115 + n_keys = device_property_count_u32(dev, buttons_property); 3116 + if (n_keys <= 0) { 3117 + error = n_keys < 0 ? n_keys : -EINVAL; 3118 + dev_err(dev, "invalid/malformed '%s' property: %d\n", 3119 + buttons_property, error); 3120 + return error; 3121 + } 3122 + 3123 + buttonmap = devm_kmalloc_array(dev, n_keys, sizeof(*buttonmap), 3124 + GFP_KERNEL); 3125 + if (!buttonmap) 3126 + return -ENOMEM; 3127 + 3128 + error = device_property_read_u32_array(dev, buttons_property, 3129 + buttonmap, n_keys); 3130 + if (error) { 3131 + dev_err(dev, "failed to parse '%s' property: %d\n", 3132 + buttons_property, error); 3133 + return error; 3134 + } 3135 + 3136 + data->t15_keymap = buttonmap; 3137 + data->t15_num_keys = n_keys; 3171 3138 } 3172 3139 3173 3140 return 0;