diff options
author | Daniel Kurtz <djkurtz@chromium.org> | 2013-03-07 22:43:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-03-08 19:03:29 -0500 |
commit | 22dfab7fd7fd5a8a2c5556ca0a8fd35fc959abc8 (patch) | |
tree | 009b5cdf5cba8e20266861989d38bc777ef845f7 /drivers/input | |
parent | 67a865a40b46d4e5d2afd154303b10220202140f (diff) |
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>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index d04f810cb1dd..8ed279c56d27 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -181,6 +181,12 @@ | |||
181 | 181 | ||
182 | #define MXT_FWRESET_TIME 175 /* msec */ | 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 | /* Command to unlock bootloader */ | 190 | /* Command to unlock bootloader */ |
185 | #define MXT_UNLOCK_CMD_MSB 0xaa | 191 | #define MXT_UNLOCK_CMD_MSB 0xaa |
186 | #define MXT_UNLOCK_CMD_LSB 0xdc | 192 | #define MXT_UNLOCK_CMD_LSB 0xdc |
@@ -212,6 +218,8 @@ | |||
212 | /* Touchscreen absolute values */ | 218 | /* Touchscreen absolute values */ |
213 | #define MXT_MAX_AREA 0xff | 219 | #define MXT_MAX_AREA 0xff |
214 | 220 | ||
221 | #define MXT_PIXELS_PER_MM 20 | ||
222 | |||
215 | struct mxt_info { | 223 | struct mxt_info { |
216 | u8 family_id; | 224 | u8 family_id; |
217 | u8 variant_id; | 225 | u8 variant_id; |
@@ -243,6 +251,8 @@ struct mxt_data { | |||
243 | const struct mxt_platform_data *pdata; | 251 | const struct mxt_platform_data *pdata; |
244 | struct mxt_object *object_table; | 252 | struct mxt_object *object_table; |
245 | struct mxt_info info; | 253 | struct mxt_info info; |
254 | bool is_tp; | ||
255 | |||
246 | unsigned int irq; | 256 | unsigned int irq; |
247 | unsigned int max_x; | 257 | unsigned int max_x; |
248 | unsigned int max_y; | 258 | unsigned int max_y; |
@@ -251,6 +261,7 @@ struct mxt_data { | |||
251 | u8 T6_reportid; | 261 | u8 T6_reportid; |
252 | u8 T9_reportid_min; | 262 | u8 T9_reportid_min; |
253 | u8 T9_reportid_max; | 263 | u8 T9_reportid_max; |
264 | u8 T19_reportid; | ||
254 | }; | 265 | }; |
255 | 266 | ||
256 | static bool mxt_object_readable(unsigned int type) | 267 | static bool mxt_object_readable(unsigned int type) |
@@ -502,6 +513,21 @@ static int mxt_write_object(struct mxt_data *data, | |||
502 | return mxt_write_reg(data->client, reg + offset, val); | 513 | return mxt_write_reg(data->client, reg + offset, val); |
503 | } | 514 | } |
504 | 515 | ||
516 | static void mxt_input_button(struct mxt_data *data, struct mxt_message *message) | ||
517 | { | ||
518 | struct input_dev *input = data->input_dev; | ||
519 | bool button; | ||
520 | int i; | ||
521 | |||
522 | /* Active-low switch */ | ||
523 | for (i = 0; i < MXT_NUM_GPIO; i++) { | ||
524 | if (data->pdata->key_map[i] == KEY_RESERVED) | ||
525 | continue; | ||
526 | button = !(message->message[0] & MXT_GPIO0_MASK << i); | ||
527 | input_report_key(input, data->pdata->key_map[i], button); | ||
528 | } | ||
529 | } | ||
530 | |||
505 | static void mxt_input_touchevent(struct mxt_data *data, | 531 | static void mxt_input_touchevent(struct mxt_data *data, |
506 | struct mxt_message *message, int id) | 532 | struct mxt_message *message, int id) |
507 | { | 533 | { |
@@ -585,6 +611,9 @@ static irqreturn_t mxt_interrupt(int irq, void *dev_id) | |||
585 | int id = reportid - data->T9_reportid_min; | 611 | int id = reportid - data->T9_reportid_min; |
586 | mxt_input_touchevent(data, &message, id); | 612 | mxt_input_touchevent(data, &message, id); |
587 | update_input = true; | 613 | update_input = true; |
614 | } else if (message.reportid == data->T19_reportid) { | ||
615 | mxt_input_button(data, &message); | ||
616 | update_input = true; | ||
588 | } else { | 617 | } else { |
589 | mxt_dump_message(dev, &message); | 618 | mxt_dump_message(dev, &message); |
590 | } | 619 | } |
@@ -764,6 +793,9 @@ static int mxt_get_object_table(struct mxt_data *data) | |||
764 | data->T9_reportid_min = min_id; | 793 | data->T9_reportid_min = min_id; |
765 | data->T9_reportid_max = max_id; | 794 | data->T9_reportid_max = max_id; |
766 | break; | 795 | break; |
796 | case MXT_SPT_GPIOPWM_T19: | ||
797 | data->T19_reportid = min_id; | ||
798 | break; | ||
767 | } | 799 | } |
768 | } | 800 | } |
769 | 801 | ||
@@ -777,7 +809,7 @@ static void mxt_free_object_table(struct mxt_data *data) | |||
777 | data->T6_reportid = 0; | 809 | data->T6_reportid = 0; |
778 | data->T9_reportid_min = 0; | 810 | data->T9_reportid_min = 0; |
779 | data->T9_reportid_max = 0; | 811 | data->T9_reportid_max = 0; |
780 | 812 | data->T19_reportid = 0; | |
781 | } | 813 | } |
782 | 814 | ||
783 | static int mxt_initialize(struct mxt_data *data) | 815 | static int mxt_initialize(struct mxt_data *data) |
@@ -1115,9 +1147,13 @@ static int mxt_probe(struct i2c_client *client, | |||
1115 | goto err_free_mem; | 1147 | goto err_free_mem; |
1116 | } | 1148 | } |
1117 | 1149 | ||
1118 | input_dev->name = "Atmel maXTouch Touchscreen"; | 1150 | data->is_tp = pdata && pdata->is_tp; |
1151 | |||
1152 | input_dev->name = (data->is_tp) ? "Atmel maXTouch Touchpad" : | ||
1153 | "Atmel maXTouch Touchscreen"; | ||
1119 | snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0", | 1154 | snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0", |
1120 | client->adapter->nr, client->addr); | 1155 | client->adapter->nr, client->addr); |
1156 | |||
1121 | input_dev->phys = data->phys; | 1157 | input_dev->phys = data->phys; |
1122 | 1158 | ||
1123 | input_dev->id.bustype = BUS_I2C; | 1159 | input_dev->id.bustype = BUS_I2C; |
@@ -1140,6 +1176,29 @@ static int mxt_probe(struct i2c_client *client, | |||
1140 | __set_bit(EV_KEY, input_dev->evbit); | 1176 | __set_bit(EV_KEY, input_dev->evbit); |
1141 | __set_bit(BTN_TOUCH, input_dev->keybit); | 1177 | __set_bit(BTN_TOUCH, input_dev->keybit); |
1142 | 1178 | ||
1179 | if (data->is_tp) { | ||
1180 | int i; | ||
1181 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); | ||
1182 | __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit); | ||
1183 | |||
1184 | for (i = 0; i < MXT_NUM_GPIO; i++) | ||
1185 | if (pdata->key_map[i] != KEY_RESERVED) | ||
1186 | __set_bit(pdata->key_map[i], input_dev->keybit); | ||
1187 | |||
1188 | __set_bit(BTN_TOOL_FINGER, input_dev->keybit); | ||
1189 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); | ||
1190 | __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); | ||
1191 | __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); | ||
1192 | __set_bit(BTN_TOOL_QUINTTAP, input_dev->keybit); | ||
1193 | |||
1194 | input_abs_set_res(input_dev, ABS_X, MXT_PIXELS_PER_MM); | ||
1195 | input_abs_set_res(input_dev, ABS_Y, MXT_PIXELS_PER_MM); | ||
1196 | input_abs_set_res(input_dev, ABS_MT_POSITION_X, | ||
1197 | MXT_PIXELS_PER_MM); | ||
1198 | input_abs_set_res(input_dev, ABS_MT_POSITION_Y, | ||
1199 | MXT_PIXELS_PER_MM); | ||
1200 | } | ||
1201 | |||
1143 | /* For single touch */ | 1202 | /* For single touch */ |
1144 | input_set_abs_params(input_dev, ABS_X, | 1203 | input_set_abs_params(input_dev, ABS_X, |
1145 | 0, data->max_x, 0, 0); | 1204 | 0, data->max_x, 0, 0); |
@@ -1258,6 +1317,7 @@ static SIMPLE_DEV_PM_OPS(mxt_pm_ops, mxt_suspend, mxt_resume); | |||
1258 | static const struct i2c_device_id mxt_id[] = { | 1317 | static const struct i2c_device_id mxt_id[] = { |
1259 | { "qt602240_ts", 0 }, | 1318 | { "qt602240_ts", 0 }, |
1260 | { "atmel_mxt_ts", 0 }, | 1319 | { "atmel_mxt_ts", 0 }, |
1320 | { "atmel_mxt_tp", 0 }, | ||
1261 | { "mXT224", 0 }, | 1321 | { "mXT224", 0 }, |
1262 | { } | 1322 | { } |
1263 | }; | 1323 | }; |