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 for touchpad variant

This same driver can be used by atmel based touchscreens and touchpads
(buttonpads). Platform data may specify a device is a touchpad
using the is_tp flag.

This will cause the driver to perform some touchpad specific
initializations, such as:
* register input device name "Atmel maXTouch Touchpad" instead of
Touchscreen.
* register BTN_LEFT & BTN_TOOL_* event types.
* register axis resolution (as a fixed constant, for now)
* register BUTTONPAD property
* process GPIO buttons using reportid T19

Input event GPIO mapping is done by the platform data key_map array.

key_map[x] should contain the KEY or BTN code to send when processing
GPIOx from T19. To specify a GPIO as not an input source, populate
with KEY_RESERVED, or 0.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Benson Leung <bleung@chromium.org>
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
Tested-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Daniel Kurtz and committed by
Linus Torvalds
22dfab7f 67a865a4

+67 -2
+62 -2
drivers/input/touchscreen/atmel_mxt_ts.c
··· 181 181 182 182 #define MXT_FWRESET_TIME 175 /* msec */ 183 183 184 + /* MXT_SPT_GPIOPWM_T19 field */ 185 + #define MXT_GPIO0_MASK 0x04 186 + #define MXT_GPIO1_MASK 0x08 187 + #define MXT_GPIO2_MASK 0x10 188 + #define MXT_GPIO3_MASK 0x20 189 + 184 190 /* Command to unlock bootloader */ 185 191 #define MXT_UNLOCK_CMD_MSB 0xaa 186 192 #define MXT_UNLOCK_CMD_LSB 0xdc ··· 217 211 218 212 /* Touchscreen absolute values */ 219 213 #define MXT_MAX_AREA 0xff 214 + 215 + #define MXT_PIXELS_PER_MM 20 220 216 221 217 struct mxt_info { 222 218 u8 family_id; ··· 251 243 const struct mxt_platform_data *pdata; 252 244 struct mxt_object *object_table; 253 245 struct mxt_info info; 246 + bool is_tp; 247 + 254 248 unsigned int irq; 255 249 unsigned int max_x; 256 250 unsigned int max_y; ··· 261 251 u8 T6_reportid; 262 252 u8 T9_reportid_min; 263 253 u8 T9_reportid_max; 254 + u8 T19_reportid; 264 255 }; 265 256 266 257 static bool mxt_object_readable(unsigned int type) ··· 513 502 return mxt_write_reg(data->client, reg + offset, val); 514 503 } 515 504 505 + static void mxt_input_button(struct mxt_data *data, struct mxt_message *message) 506 + { 507 + struct input_dev *input = data->input_dev; 508 + bool button; 509 + int i; 510 + 511 + /* Active-low switch */ 512 + for (i = 0; i < MXT_NUM_GPIO; i++) { 513 + if (data->pdata->key_map[i] == KEY_RESERVED) 514 + continue; 515 + button = !(message->message[0] & MXT_GPIO0_MASK << i); 516 + input_report_key(input, data->pdata->key_map[i], button); 517 + } 518 + } 519 + 516 520 static void mxt_input_touchevent(struct mxt_data *data, 517 521 struct mxt_message *message, int id) 518 522 { ··· 610 584 } else if (mxt_is_T9_message(data, &message)) { 611 585 int id = reportid - data->T9_reportid_min; 612 586 mxt_input_touchevent(data, &message, id); 587 + update_input = true; 588 + } else if (message.reportid == data->T19_reportid) { 589 + mxt_input_button(data, &message); 613 590 update_input = true; 614 591 } else { 615 592 mxt_dump_message(dev, &message); ··· 793 764 data->T9_reportid_min = min_id; 794 765 data->T9_reportid_max = max_id; 795 766 break; 767 + case MXT_SPT_GPIOPWM_T19: 768 + data->T19_reportid = min_id; 769 + break; 796 770 } 797 771 } 798 772 ··· 809 777 data->T6_reportid = 0; 810 778 data->T9_reportid_min = 0; 811 779 data->T9_reportid_max = 0; 812 - 780 + data->T19_reportid = 0; 813 781 } 814 782 815 783 static int mxt_initialize(struct mxt_data *data) ··· 1147 1115 goto err_free_mem; 1148 1116 } 1149 1117 1150 - input_dev->name = "Atmel maXTouch Touchscreen"; 1118 + data->is_tp = pdata && pdata->is_tp; 1119 + 1120 + input_dev->name = (data->is_tp) ? "Atmel maXTouch Touchpad" : 1121 + "Atmel maXTouch Touchscreen"; 1151 1122 snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0", 1152 1123 client->adapter->nr, client->addr); 1124 + 1153 1125 input_dev->phys = data->phys; 1154 1126 1155 1127 input_dev->id.bustype = BUS_I2C; ··· 1175 1139 __set_bit(EV_ABS, input_dev->evbit); 1176 1140 __set_bit(EV_KEY, input_dev->evbit); 1177 1141 __set_bit(BTN_TOUCH, input_dev->keybit); 1142 + 1143 + if (data->is_tp) { 1144 + int i; 1145 + __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 1146 + __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit); 1147 + 1148 + for (i = 0; i < MXT_NUM_GPIO; i++) 1149 + if (pdata->key_map[i] != KEY_RESERVED) 1150 + __set_bit(pdata->key_map[i], input_dev->keybit); 1151 + 1152 + __set_bit(BTN_TOOL_FINGER, input_dev->keybit); 1153 + __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); 1154 + __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); 1155 + __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); 1156 + __set_bit(BTN_TOOL_QUINTTAP, input_dev->keybit); 1157 + 1158 + input_abs_set_res(input_dev, ABS_X, MXT_PIXELS_PER_MM); 1159 + input_abs_set_res(input_dev, ABS_Y, MXT_PIXELS_PER_MM); 1160 + input_abs_set_res(input_dev, ABS_MT_POSITION_X, 1161 + MXT_PIXELS_PER_MM); 1162 + input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 1163 + MXT_PIXELS_PER_MM); 1164 + } 1178 1165 1179 1166 /* For single touch */ 1180 1167 input_set_abs_params(input_dev, ABS_X, ··· 1317 1258 static const struct i2c_device_id mxt_id[] = { 1318 1259 { "qt602240_ts", 0 }, 1319 1260 { "atmel_mxt_ts", 0 }, 1261 + { "atmel_mxt_tp", 0 }, 1320 1262 { "mXT224", 0 }, 1321 1263 { } 1322 1264 };
+5
include/linux/i2c/atmel_mxt_ts.h
··· 15 15 16 16 #include <linux/types.h> 17 17 18 + /* For key_map array */ 19 + #define MXT_NUM_GPIO 4 20 + 18 21 /* Orient */ 19 22 #define MXT_NORMAL 0x0 20 23 #define MXT_DIAGONAL 0x1 ··· 42 39 unsigned int voltage; 43 40 unsigned char orient; 44 41 unsigned long irqflags; 42 + bool is_tp; 43 + const unsigned int key_map[MXT_NUM_GPIO]; 45 44 }; 46 45 47 46 #endif /* __LINUX_ATMEL_MXT_TS_H */