Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp856350pxb; Fri, 28 Jan 2022 11:33:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUvuzW6jdkcvqlbmrwBwjup1DZ43GMIz8gp27ky+l6dYkcePYA8cwwDDbzmyzC+PioyRSs X-Received: by 2002:a17:906:1e14:: with SMTP id g20mr7657163ejj.251.1643398388670; Fri, 28 Jan 2022 11:33:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643398388; cv=none; d=google.com; s=arc-20160816; b=FbbwIj8UHKWxPcuI7KyO9DTD5xM9s3NAyJ2rzISf0dQu4+ktbi9i96uLdMM1+byiI5 uKX8iYLTZ3NTGk2h2Qn6G1Sx17RKXOjL/S/rqvI9FmpDeltTwNu4hdxit730+/PGDv5E GnPJEnPpJ+G15+PuaVm+TCp4Rf1PrberpNqmSsTBNq1Bt6aG5GegOsYhQO5phhnX9NcZ tnAGol+RExyGBrRnqu9loVbm2SdI3v9rBsFSnZVNztOP1kHCzqKWilYxAPBycQgapQnV XoxxyeZ04AIR57GiRj8TBSsb1eIeb+dg+52s8KwgkYoTtcn2najURYSKqSoMolnO0E2b bHbQ== 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=OXRAZ4ZbAiGfh4OhUn2p/TK/Z5xaiNitvZb8Ee+RiIw=; b=DTsOvCNIxGits0B2cV6Rn5tKG2updApE4oGZHO/wLFQt95tAD1ZqpBC+4Gh64Q3b+8 YfmEh6Yo4YDGKPyvZMvAmw2Q4rjsib1NSEuRWnd2kvk4uPIQJn94RmM77N51Z02eykza W2mRK4+szTWMsrXgsuBjE/klmDQ1AUpeKmTQF94wIsyMQk2DvMuFae4yblDk/jn0jn/p Yb6Pa5hcKafeIEPsCOF6674XltdFn98E3Wrgj88BV6C4eJeuHIgJ+ue4REDyyb16k8hh M+70DRutzhT0ku4tngwIp9EBLu0l3jxieXeg+pFd1At1wZzrjzSXkbXfbLFxsNN7TdD3 k1VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=tOqFrcLs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id au23si3091392ejc.145.2022.01.28.11.32.43; Fri, 28 Jan 2022 11:33:08 -0800 (PST) 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; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=tOqFrcLs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242554AbiA0VDD (ORCPT + 99 others); Thu, 27 Jan 2022 16:03:03 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:18292 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344206AbiA0VDA (ORCPT ); Thu, 27 Jan 2022 16:03:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1643317380; x=1674853380; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OXRAZ4ZbAiGfh4OhUn2p/TK/Z5xaiNitvZb8Ee+RiIw=; b=tOqFrcLs87Gi7yG4SKpEeKjvu79v2fgAfc78i+1LfmHLECKocY9Si7Tf gq2Uo5V302RNiqLsZbahcQkCCAr00HvjAE06blYkEnl5w/0Hg4rbljgZi 2eTVEisRQfN6uuDbHHOI4xDl6Fh7IVTibY29fDJ23ePWvd0jutpjaCHjv Q=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-02.qualcomm.com with ESMTP; 27 Jan 2022 13:03:00 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2022 13:02:59 -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; Thu, 27 Jan 2022 13:02:59 -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; Thu, 27 Jan 2022 13:02:58 -0800 From: Anjelique Melendez To: CC: , , , , , , , Anjelique Melendez Subject: [PATCH v2 4/4] input: misc: pm8941-pwrkey: simulate missed key press events Date: Thu, 27 Jan 2022 13:00:29 -0800 Message-ID: <20220127210024.25597-5-quic_amelende@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220127210024.25597-1-quic_amelende@quicinc.com> References: <20220127210024.25597-1-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: nalasex01b.na.qualcomm.com (10.47.209.197) 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 bcdbe260b684..99ef2ff92eb1 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