Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5830490ybv; Wed, 12 Feb 2020 00:51:37 -0800 (PST) X-Google-Smtp-Source: APXvYqxJd7HQzNYX7LkNAVry8UEX+ZJ6oXXMxEoVHezV3wkPRfRgBu0L6c7P/7zusmIHvpsIOnsz X-Received: by 2002:aca:100e:: with SMTP id 14mr5556460oiq.88.1581497497540; Wed, 12 Feb 2020 00:51:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581497497; cv=none; d=google.com; s=arc-20160816; b=KC0XRomH5/6Rpq9Gk4F57AEfkBCGDvs1WAlttvQZKRbks7nApFxtjcOBGE6PMzdr4n wv3v7FzloKTPh+I+IRppGp/ohRYE81svcTWiXyaAD8tJyx6rv3ve+l70z8IRo/YrBlFJ byHa2xjXLqzli1pjBnj2CuItpflqwp/y9DxlY/DWte/j9Lm1wkC15ZP9/7SBLLatTxDF DhEpce6lXQfXdzVNGZWacr8n9ykqOAmHkMe9bO3mk3kp9E3WVxc/jMYw0yEGMSScTbkc 5B972PkZnOBfKfNYuAtgc+KCtEONE5llrzzTpR/tBMyGGlyYHvK0ptEN0NyF3hhCV/SB 0DVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=LUwuQanJdR7LbBcqm6Xq0evlFupzQcnpazVGubA8OFg=; b=WCBClH/q0AqeV4eoW0gyIYoL19tC6HlAMtYhcP3XHXn7idEk4lh0BXiZnYHZbNtiY0 WRBdbXM5uPZGMFHDgREMxHnIu/y2RsrMDGmQSEGQmASBepvt9v92ZvryciQdfvAjNGXj uK6W+lpe12f+s1fCXSJjh3k76qI5nC+fuM+6i9pi61WxVJgCTwMahCWq67qRYwvCvARC CBSTTjeJMglIOaNBfQ/nx+BRzR6T8+UCQWTSJ4/zz1sM3el0r9q7y1gZSHTB0KNtJaoK lpaA3V04qcqX2njFDfCO4M6l8B5QbQdUsHaFvZc05zK5DxH/1IpDh5iG2BBrt24pFVzZ 3SHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3si3455699otp.230.2020.02.12.00.51.25; Wed, 12 Feb 2020 00:51:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728799AbgBLIvL (ORCPT + 99 others); Wed, 12 Feb 2020 03:51:11 -0500 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:20103 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728650AbgBLIvL (ORCPT ); Wed, 12 Feb 2020 03:51:11 -0500 IronPort-SDR: ypXWsRUpNLh0b5egqYGfw6ykEFIQpcMdUf+OtQgx2rUKWkEgqxhqubnZD0oJw43e/yUiGNszGq saWEM+9ViHvZVUeWd4q5luzvhtJRj7aFlyZ+OWHC456wlkNz9fTXbyhccZOrOTPqU4eyKAVyOn 86uxc/Ljl5xFG+Yq3U+Ni3wfafGajNEboqBkUKFyYABTo7CuYO3HzOtJFdRWyxbIFcsOBp+w2P dBxiqyL/4EnyLe54qjCGgr5tlsQ2PICzj0X8dUxQyh3g9gZUtP+t6Y1s898wSVZhTmyHD1+dPn jA8= X-IronPort-AV: E=Sophos;i="5.70,428,1574150400"; d="scan'208";a="45799301" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 12 Feb 2020 00:44:04 -0800 IronPort-SDR: CPsj5TNxjYY0z+R8RzyJ8Xvnj8BRltlvIFLz4m61oGQG6TlIpMy1SQAEQPj4cv2ovYTSA60eoN CWbXcFr+ZNStsywiYU4jWoclFsMcOe55prmEzotoEZH1HVtkZUw1MAi0QckN21jv5i14s4CSpm vrGoiTu6ZzgrxWQmtsaFSAomJxWb8krRXWWEU5yOEKlUvHKEbLnjvtKNh05GEgd89yrZJ43Ia5 VApCQWFY03zPenMTefD11kQwogQXyuvZqQV+qQF0bcmGS4RmWetN8QDgAx9jCznSNAnVoz9Z/0 kpM= From: Jiada Wang To: , , , , , CC: , , , , Subject: [PATCH v7 12/48] Input: atmel_mxt_ts - release touch state during suspend Date: Wed, 12 Feb 2020 00:41:42 -0800 Message-ID: <20200212084218.32344-13-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200212084218.32344-1-jiada_wang@mentor.com> References: <20200212084218.32344-1-jiada_wang@mentor.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nick Dyer 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 Acked-by: Benson Leung Acked-by: Yufeng Shen (cherry picked from ndyer/linux/for-upstream commit 26794433086dbc7dea18d2f6a1c8d61ab25bcfda) [gdavis: Resolve forward port conflicts due to applying upstream commit 96a938aa214e ("Input: atmel_mxt_ts - remove platform data support").] Signed-off-by: George G. Davis [gdavis: Squash fix from Dirk Behme: - Input: atmel_mxt_ts - remove superfluous data->suspended] Signed-off-by: Dirk Behme --- drivers/input/touchscreen/atmel_mxt_ts.c | 52 ++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index b6286b1f4a1a..2bc34c14dbbf 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -372,6 +372,9 @@ struct mxt_data { unsigned int t19_num_keys; enum mxt_suspend_mode suspend_mode; + + /* Indicates whether device is in suspend */ + bool suspended; }; struct mxt_vb2_buffer { @@ -1151,10 +1154,10 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message) mxt_proc_t42_messages(data, message); } else if (report_id == data->T48_reportid) { mxt_proc_t48_messages(data, message); - } else if (!data->input_dev) { + } else if (!data->input_dev || data->suspended) { /* - * Do not report events if input device - * is not yet registered. + * Do not report events if input device is not + * yet registered or returning from suspend */ mxt_dump_message(data, message); } else if (report_id >= data->T9_reportid_min && @@ -3135,6 +3138,11 @@ static int mxt_load_fw(struct device *dev, const char *fn) if (ret) goto release_firmware; + if (data->suspended) { + enable_irq(data->irq); + data->suspended = false; + } + if (!data->in_bootloader) { /* Change to the bootloader mode */ data->in_bootloader = true; @@ -3306,8 +3314,27 @@ static void mxt_sysfs_remove(struct mxt_data *data) sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); } +static void mxt_reset_slots(struct mxt_data *data) +{ + struct input_dev *input_dev = data->input_dev; + int id; + + if (!input_dev) + return; + + for (id = 0; id < data->num_touchids; id++) { + input_mt_slot(input_dev, id); + input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, 0); + } + + mxt_input_sync(data); +} + static void mxt_start(struct mxt_data *data) { + if (!data->suspended || data->in_bootloader) + return; + switch (data->suspend_mode) { case MXT_SUSPEND_T9_CTRL: mxt_soft_reset(data); @@ -3320,16 +3347,29 @@ static void mxt_start(struct mxt_data *data) case MXT_SUSPEND_DEEP_SLEEP: default: + /* + * Discard any touch messages still in message buffer + * from before chip went to sleep + */ + mxt_process_messages_until_invalid(data); + mxt_set_t7_power_cfg(data, MXT_POWER_CFG_RUN); /* Recalibrate since chip has been in deep sleep */ mxt_t6_command(data, MXT_COMMAND_CALIBRATE, 1, false); + + mxt_acquire_irq(data); break; } + + data->suspended = false; } static void mxt_stop(struct mxt_data *data) { + if (data->suspended || data->in_bootloader) + return; + switch (data->suspend_mode) { case MXT_SUSPEND_T9_CTRL: /* Touch disable */ @@ -3339,9 +3379,15 @@ static void mxt_stop(struct mxt_data *data) case MXT_SUSPEND_DEEP_SLEEP: default: + disable_irq(data->irq); + mxt_set_t7_power_cfg(data, MXT_POWER_CFG_DEEPSLEEP); + + mxt_reset_slots(data); break; } + + data->suspended = true; } static int mxt_input_open(struct input_dev *dev) -- 2.17.1