Skip to content

Commit 758120f

Browse files
ndyerehristev
authored andcommitted
Input: atmel_mxt_ts - release touch state during suspend
If fingers are down as the MXT chip goes into suspend it does not send a lift message. In addition, it may not complete its final measurement cycle immediately, which means touch messages may be received by the interrupt handler after mxt_stop() has completed. So: - disable irq during suspend - flush any messages created after suspend - tell app layer that slots were released at suspend Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk> Acked-by: Benson Leung <bleung@chromium.org> Acked-by: Yufeng Shen <miletus@chromium.org> [cyrille.pitchen@atmel.com: adapt original patch to mainline] Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
1 parent 56b25a0 commit 758120f

1 file changed

Lines changed: 48 additions & 3 deletions

File tree

drivers/input/touchscreen/atmel_mxt_ts.c

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ struct mxt_data {
325325

326326
/* for config update handling */
327327
struct completion crc_completion;
328+
329+
/* Indicates whether device is in suspend */
330+
bool suspended;
328331
};
329332

330333
struct mxt_vb2_buffer {
@@ -947,10 +950,10 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message)
947950

948951
if (report_id == data->T6_reportid) {
949952
mxt_proc_t6_messages(data, message);
950-
} else if (!data->input_dev) {
953+
} else if (!data->input_dev || data->suspended) {
951954
/*
952-
* Do not report events if input device
953-
* is not yet registered.
955+
* Do not report events if input device is not
956+
* yet registered or returning from suspend.
954957
*/
955958
mxt_dump_message(data, message);
956959
} else if (report_id >= data->T9_reportid_min &&
@@ -2761,6 +2764,11 @@ static int mxt_load_fw(struct device *dev, const char *fn)
27612764
if (ret)
27622765
goto release_firmware;
27632766

2767+
if (data->suspended) {
2768+
enable_irq(data->irq);
2769+
data->suspended = false;
2770+
}
2771+
27642772
if (!data->in_bootloader) {
27652773
/* Change to the bootloader mode */
27662774
data->in_bootloader = true;
@@ -2875,6 +2883,8 @@ static ssize_t mxt_update_fw_store(struct device *dev,
28752883
} else {
28762884
dev_info(dev, "The firmware update succeeded\n");
28772885

2886+
data->suspended = false;
2887+
28782888
error = mxt_initialize(data);
28792889
if (error)
28802890
return error;
@@ -2900,8 +2910,33 @@ static const struct attribute_group mxt_attr_group = {
29002910
.attrs = mxt_attrs,
29012911
};
29022912

2913+
static void mxt_reset_slots(struct mxt_data *data)
2914+
{
2915+
struct input_dev *input_dev = data->input_dev;
2916+
int id;
2917+
2918+
if (!input_dev)
2919+
return;
2920+
2921+
for (id = 0; id < data->num_touchids; id++) {
2922+
input_mt_slot(input_dev, id);
2923+
input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 0);
2924+
}
2925+
2926+
mxt_input_sync(data);
2927+
}
2928+
29032929
static void mxt_start(struct mxt_data *data)
29042930
{
2931+
if (!data->suspended || data->in_bootloader)
2932+
return;
2933+
2934+
/*
2935+
* Discard any touch messages still in message buffer
2936+
* from before chip went to sleep
2937+
*/
2938+
mxt_process_messages_until_invalid(data);
2939+
29052940
switch (data->pdata->suspend_mode) {
29062941
case MXT_SUSPEND_T9_CTRL:
29072942
mxt_soft_reset(data);
@@ -2921,10 +2956,17 @@ static void mxt_start(struct mxt_data *data)
29212956
break;
29222957
}
29232958

2959+
mxt_acquire_irq(data);
2960+
data->suspended = false;
29242961
}
29252962

29262963
static void mxt_stop(struct mxt_data *data)
29272964
{
2965+
if (data->suspended || data->in_bootloader)
2966+
return;
2967+
2968+
disable_irq(data->irq);
2969+
29282970
switch (data->pdata->suspend_mode) {
29292971
case MXT_SUSPEND_T9_CTRL:
29302972
/* Touch disable */
@@ -2937,6 +2979,9 @@ static void mxt_stop(struct mxt_data *data)
29372979
mxt_set_t7_power_cfg(data, MXT_POWER_CFG_DEEPSLEEP);
29382980
break;
29392981
}
2982+
2983+
mxt_reset_slots(data);
2984+
data->suspended = true;
29402985
}
29412986

29422987
static int mxt_input_open(struct input_dev *dev)

0 commit comments

Comments
 (0)