Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2723099pxb; Thu, 3 Feb 2022 12:47:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJyyYb/vqef0li0B26LRilhOYf79ZiohxfQBlvFOikz7u9M9Pxd2UQPvMvVIZisOf7CnaABz X-Received: by 2002:aa7:8582:: with SMTP id w2mr36159602pfn.3.1643921247015; Thu, 03 Feb 2022 12:47:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643921247; cv=none; d=google.com; s=arc-20160816; b=K3k58IkZP9ZhUb1xVbJWAnlz3qidS3ZQl+6PZFB+8E+CeKwK5H/D/mgNl/eih7/web jA0723Bemi58jUvj8jwDM8lVLZwF/xyxExf3bgcVfYb2Uu6dl4MjD2VgIPkk30gojTbF 0Bctmm92740qPgizhAsFZAU/yl8CQ4CUQphM9TK4WT/58M6avLs7tb7QmxLLb3dWk4M6 eLBU4LJ76NwaAOyG6QkB27RfEU1htSHaGX7fWteXWXOIePq7dzl/UiBzZVtEbJFShEZW HK9L7JoaLc/TXxRFB/A5HLBjksS4vCUzo088IFFaUbxdkj92L2Zn4MIYd3omYrz9LFdg IHpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9ry5DqGO4sfxgYyBx1F9gF74PDP6w3LUdx+PSxKFPyY=; b=d+DND8RmS9589uWvkkJ1gmv+3Zu+6/Cqmj1cS25PoHFDNqD1Hw1paeXk8rYuGG/s+G KX/mqsqP3EdOrN2cD7MNuf9uoRrHaFjE0rmBkfz7LrLV/V0xFxJWPrGaYU98LeDOGBPg HwVIx30jqFiSkW1ZJWof4Nc3tlvWKN//grk6nqPVWz8J2JVa+/dS7xNHrww792Mr4E1M itR4s+f4eLler2FR1lcZJzP4gMhPbZTvPFpPKk8/Fa7+X3FNBbSecpxpX6udh8RmOffm EhB0/ZidChsbVVhgIhlbMv6eFOFnlfq4JF6MWWvmTzQpUvpcdHsKsqxwDiz2TuJhL3LK g7lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=livwPhXl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6si25108352plx.362.2022.02.03.12.47.15; Thu, 03 Feb 2022 12:47:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=livwPhXl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348797AbiBCBJn (ORCPT + 99 others); Wed, 2 Feb 2022 20:09:43 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:19092 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233416AbiBCBJm (ORCPT ); Wed, 2 Feb 2022 20:09:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1643850582; x=1675386582; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9ry5DqGO4sfxgYyBx1F9gF74PDP6w3LUdx+PSxKFPyY=; b=livwPhXlckLB+Bpg5Nnm0T8KI/2C9tVF2rTvfxVDztonoIYtg5GVCC1n HJj3Xg/kpvXbu9sxdbmlWoNBn2HxzRzTrleohmik0XMQnaRtByD/2DhZu 1Kewmw/ej0ud2ZnvdlFEWycgjmHZjZ69/rFeQ6o0a8R/dtpNMuh84WO4S g=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-02.qualcomm.com with ESMTP; 02 Feb 2022 17:09:42 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2022 17:09:41 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Wed, 2 Feb 2022 17:09:41 -0800 Received: from hu-amelende-lv.qualcomm.com (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Wed, 2 Feb 2022 17:09:40 -0800 From: Anjelique Melendez To: CC: , , , , , , , Anjelique Melendez Subject: [PATCH v3 4/4] input: misc: pm8941-pwrkey: simulate missed key press events Date: Wed, 2 Feb 2022 17:08:09 -0800 Message-ID: <20220203010804.20883-5-quic_amelende@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220203010804.20883-2-quic_amelende@quicinc.com> References: <20220203010804.20883-2-quic_amelende@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Collins The status of the keys connected to the KPDPWR_N and RESIN_N pins is identified by reading corresponding bits in the interrupt real time status register. If the status has changed by the time that the interrupt is handled then a press event will be missed. Maintain a last known status variable to find unbalanced release events and simulate press events for each accordingly. Signed-off-by: David Collins Signed-off-by: Anjelique Melendez --- drivers/input/misc/pm8941-pwrkey.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c index 4768a542777d..60de6581af21 100644 --- a/drivers/input/misc/pm8941-pwrkey.c +++ b/drivers/input/misc/pm8941-pwrkey.c @@ -76,6 +76,7 @@ struct pm8941_pwrkey { u32 code; u32 sw_debounce_time_us; ktime_t sw_debounce_end_time; + bool last_status; const struct pm8941_data *data; }; @@ -162,6 +163,16 @@ static irqreturn_t pm8941_pwrkey_irq(int irq, void *_data) pwrkey->sw_debounce_end_time = ktime_add_us(ktime_get(), pwrkey->sw_debounce_time_us); + /* + * Simulate a press event in case a release event occurred without a + * corresponding press event. + */ + if (!pwrkey->last_status && !sts) { + input_report_key(pwrkey->input, pwrkey->code, 1); + input_sync(pwrkey->input); + } + pwrkey->last_status = sts; + input_report_key(pwrkey->input, pwrkey->code, sts); input_sync(pwrkey->input); -- 2.34.1