Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1368464ybj; Thu, 7 May 2020 23:01:51 -0700 (PDT) X-Google-Smtp-Source: APiQypLOL270gx80SxHWp5j1c0J+4REsBAGGFAKXV8FAiW+FC5gVhrZxJW3m5i5cyuoJWZx48VWa X-Received: by 2002:a17:906:34c8:: with SMTP id h8mr502006ejb.321.1588917711166; Thu, 07 May 2020 23:01:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588917711; cv=none; d=google.com; s=arc-20160816; b=l2HlvMetxHqAv5H/+T7E5aBWi/+Pap+HPVGWbsKLN0fF7DBmhoN2uGatE5lO0ZihCw UXgsVP2glhfNHrdqQMg3KMtOGwK1oz0pPEYwfFLiznwDtMKogG/FUfIfQ3OMpnFwtD/z dNbWiL52Z3pSSa4OSp/c0yerinrGhIWgd9IOUCmCQCRk5OdvI7gGBjndbgVd7EBP1LAV JEC000ePWJJ5BrUOqO1XJACHJeGf13ynuU0KeUz+jh2gXYXLwfsqhJWT1XOK3XGuntn3 yYwSc966R1JBHpo9kFm7djL7FFfwdAlSxSwW1wis7WvKZM0OltFiyA1kHiVtSBqYXk8j Tq+g== 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=5Um+oqd/0+hEXdpvaIQ48DYqyZRFsfmXi5GyYFW/FQM=; b=SkzieZ9VHgP0cbwheUyzWB7D6wzqXA3dTAoJvZgmEDzlg2gMFBw3GYnfHqzD4ePLY/ l+U4suv454cpSfWOxpCyiVFD4aKzSG2hp00QtEOHpbTDmNRreObGv/MHYBayKahK7s6C 8kB6Nbom6/7Z8u52ln8q5Yg+k5kULAZyvJwlXzDMfpxCJkMCJZFlhTOizKIgHXEvDEfs VUUNt57Qpl+fvXfRr6MGwfo/euqNpar5AW6FaZ5O+4/mD502/tUuhHy1q8dH+C39QB1n 8kpWOyPS8mRsCxrlm098puHPGosknPcw9RBJ/YZS34m8hjGIxpQRRk10jVT66keLgKBk VDqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o26si353481eja.150.2020.05.07.23.01.28; Thu, 07 May 2020 23:01:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727804AbgEHF5v (ORCPT + 99 others); Fri, 8 May 2020 01:57:51 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:45878 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727778AbgEHF5t (ORCPT ); Fri, 8 May 2020 01:57:49 -0400 IronPort-SDR: kX6JCWvDVW0VN1nCTsUudgKqQQZ0jAVhrVz/crWGm4YPGd2uExirw3jpMgydyAa4r0Czv4A/Pz BB6N1Ng/KwIrP1p/MBh7AyyuUu8gkuGLJ431M9jaJW+855Ypy9svXe3/unb+VvrgfDJ1IFOEPH mj9t/q0bzzjl4tQgVj4ypR5bqMzPTGrkDEKqRWk40jF3Kedd3wJo4l9Ergb2DzWZwy2rIxxbl/ fadqPSRKTJwOUXsIgkWkuW2e0xQDdM6T91ojP+OTgaVKZ0SAeUbDv1pqF2l7hryrXZNvdDJaYs LDg= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48710574" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 07 May 2020 21:57:48 -0800 IronPort-SDR: ZW2wFzsxEUQnQNnXPaEOTT6B1gWmvefbhow17aKRHW//13MXJH24cUbBSCZ24WsZpz1m+owZ/8 DjKtL1fqbS0f1b3sSD5ln6mRFgJt5QqS4CCuKoEcUMMVh5Qj1PA209/W+TtpFferxMIWMtfYBr SLUG1QuIg9dSL7hHns6owsaNfV112SLRJdwurj0kzDf9vmR6k0XkGNPEutpymPNxw9ID8y/abP LkouvykyaU/2MS5WcW6wKqQAWZuVYVUisoyjg4dfXtgCv7MDMnAdty2wLkfaCXqVVQhSw6FF/n hX0= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 12/56] Input: atmel_mxt_ts - release touch state during suspend Date: Thu, 7 May 2020 22:56:12 -0700 Message-ID: <20200508055656.96389-13-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-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 6126bb8a7acc..9aafed92db9c 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