Message ID | 20250107135659.185293-8-markus.burri@mt.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show
Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2084.outbound.protection.outlook.com [40.107.22.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E733B1F9A84; Tue, 7 Jan 2025 14:03:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736258643; cv=fail; b=FD+hEpdmGMSW4crcM+cTB1tE42aOZPd8RSRpwyIHyXPOdNSt9+GBPKU6MK8zqpcP1oYU+/e00q/9ISu0TLwZaKUgvYdwrgXxalB1aJXPhdCmErn6EKgTfO7mUeDQOjXgWncozfboRAKDo5p7He7ay+pmUi/m73B3nxSlka5FFQI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736258643; c=relaxed/simple; bh=wZKztcSCxUa1Q0/2iO88ZANFu8JTsEu5QBy5/sq+cHc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=N2ZqQc86ZzZHyiCr+5oa0SylUi7aYbuVTK8AI2p6dhW5kw1y9UC9+KX92JDJq5yiNMoywDK0XaluwHmM1P9BfhPRPXVrXISr/12Rl0kmkoCCK16J/AsZvU11UTJY0O7Wx7+NS8SGUPQtOKyvmV2askwOdjcMomNqan55urr4gGw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mt.com; spf=pass smtp.mailfrom=mt.com; dkim=pass (2048-bit key) header.d=mt.com header.i=@mt.com header.b=SVFN/g97; arc=fail smtp.client-ip=40.107.22.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mt.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mt.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mt.com header.i=@mt.com header.b="SVFN/g97" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F23z1+Fkfaxa33Dzjfy5W/BJOq1Vs15GWDV14GQteiOvLncaEUxFeMckwSemydjVX/SWiQ4PjpcvUklN7FYocOdXRXGExCsqckr3iFDY+RP5mTqzSh7LLhc+qeYiPL2sTot64LnzKvVsrWdDrDpkh0yl07GhDEGKrnWK4hv2f1E08N0iu/FH8vpWd/PZs95Qie1Iyt8ZB2L0D7A3x2UNtwAl0UYegI+NYxSA0vahl/RXsbbg7DhqgE04z/D4dJUetrFb9L+FpgAyVSpd3OO2n5Lz8xdMKwgy+TJG2SPwsXdvDn6GiA7rD+JfsB2z5pn1auauX89QyT1lHiRFcswnQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EdIlIoIZIKlDFiBC7W2CODcO88jqW/eEFkDLvDhehGk=; b=pMRVXuyFqZHdZmP2HsI94KNX5y3hQs+aCNNrYOY5vgyWgLqsxDdOz+8acp114pporTdYLc9j7MFUFjRWlXm5bZoITIKQ9tjZVAZTUUtG2BaUsxfa8A3FmEHWNAi50MafH3fx22oKGwfOqXoQntL70cfZalIXphQXfpPIf5PCHIhgQ1OfvKFY9STSj/k0S0e6NxMLdb7pQ2uqxwgfjSuh3IbjOVLYrz05RmmxjvbPvca9CCiqRwVK2/lPEuX/uzgWMt9PtK0+apEX2h2zreadeuEvFmSkQ/Ilb+vy3C8FSrG+saeTWlNLR3BwoCXskU+tS6o+E3blotpqQ+X9GTiEKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mt.com; dmarc=pass action=none header.from=mt.com; dkim=pass header.d=mt.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mt.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EdIlIoIZIKlDFiBC7W2CODcO88jqW/eEFkDLvDhehGk=; b=SVFN/g97V0Ha96GLwMUfoAzvOh9RhEMxsqYApil0VUzDmwUnh3e+eoa12L2QhNC/iruWPnBk6DsPHJcwRNQEPwkseTttSZkYonaN5cOm2zni2BX2JR+NAPbABg1lRsBSpTG0t9Uyku/9jVHL58zqzom/dq6V2mHzLcR2prtdIwWuaSsdEswyB5fRVxra3IZYDCvqcb3mEW9RlWVdFYmerpM0HAI7MZpt0JV6DUSObGuFILtwjbcmTIE241/b7BTINdZG7zSnFzG0hKEAt/M6Pv23u1eZSz5dLv2gYGlJdp7+CSolPt0W32BWgOgRtZLnrENfWAdDeDDjr5cAzAwpyA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=mt.com; Received: from DBBPR03MB5399.eurprd03.prod.outlook.com (2603:10a6:10:f5::22) by VI1PR03MB6544.eurprd03.prod.outlook.com (2603:10a6:800:19c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.16; Tue, 7 Jan 2025 14:03:32 +0000 Received: from DBBPR03MB5399.eurprd03.prod.outlook.com ([fe80::2fec:64f5:1893:f53a]) by DBBPR03MB5399.eurprd03.prod.outlook.com ([fe80::2fec:64f5:1893:f53a%3]) with mapi id 15.20.8314.018; Tue, 7 Jan 2025 14:03:32 +0000 From: Markus Burri <markus.burri@mt.com> To: linux-kernel@vger.kernel.org Cc: Markus Burri <markus.burri@mt.com>, Dmitry Torokhov <dmitry.torokhov@gmail.com>, Rob Herring <robh@kernel.org>, Krzysztof Kozlowski <krzk+dt@kernel.org>, Conor Dooley <conor+dt@kernel.org>, Marek Vasut <marek.vasut@gmail.com>, linux-input@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v3 7/7] Input: matrix_keypad - detect change during scan Date: Tue, 7 Jan 2025 14:56:59 +0100 Message-Id: <20250107135659.185293-8-markus.burri@mt.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107135659.185293-1-markus.burri@mt.com> References: <20250107135659.185293-1-markus.burri@mt.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: ZR2P278CA0022.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:46::7) To DBBPR03MB5399.eurprd03.prod.outlook.com (2603:10a6:10:f5::22) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: <linux-input.vger.kernel.org> List-Subscribe: <mailto:linux-input+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-input+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DBBPR03MB5399:EE_|VI1PR03MB6544:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f2bd340-9d65-4363-2f92-08dd2f2411e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: qvri4j3t2n7nddTaPMn6PZb9VxyMQdQq5JTM3ZsFheVRhssqbRXF/KIHEaAK70daX29B+WNq8K1oaTt2DG/EkLRy6aaGHrzVgyUm1tZ8NlbgGnsUADr9AYt0a5GfmN/KLmFFvdHkFKRq0uVgMPIJFWcswkSqoWJZl6qQvrtWHlGtlXPGFNXXWQpRaHcVP7RpkmMDqjO2PJn229TptSocEFKn/swKAEozfY5AjhAUVIODMNPFHeWJKg6lOq2XgxYKS1WAPz+dMmferBPh6bkKEWhHxnRRnZPD6TW9WTM3PVPsKwnoy+2DoJc+9Iy3DWXWY7+ADQqx9J/lQ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SscDbqwT9bYn2zKtghwFRr/uZsm9yTpYM7ihkz3rrYaZwlpPIAIosOzhCBm6ofaDWPR1sskc X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DBBPR03MB5399.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: znCn+JRiEemlprdGv132SqNS9j3nB0gCixpzlaOfWTCMCQCB43CWkhS0sBTU6TT0t0a6yeITQBMd8yN+WYza+627v6sJtGfzftD0IbUjZzn8S1d5/M0i4e12mN1RQk9o9px4bSINajdC7kUf35eJbsJB0ZTLhJEMp7XiTVclxCEvufbaefYgCdU3u0lreyP68DfjYVUZiGlmPG7WaOLcI32pv1cXQtOyCjPed3nYSYFd00kGtsprbgU5bnZFfMW//EQpxVZWXX+dc9W6knPcC5DRfhDRJeKMpSQKeog/XnqHe/VhnIQ932FSc/GjS+wvFuc67KNpv4Pk1Pw/4p36Ci+SRT93f6IpqQYa2XRgWf2+2Mzt24Jk8KEiVQo8zRAkbwGYxcL+87gEcBbUy2eoWFp3bGP7KUqTB3H+Qhui7gUF5YuspB8PU/EznX4SZA018336N7tudKuC90c+kDteMLU48gcaUaIaRl39GDogmV60QHzblesGGbTpFe4TLGcTrqg3rz5R7HBxU+pGe7uRTP0xRpUlsizYH1rtwkqWXG2zH+hu6qIUMUIYNFatVCOeu0iRz+DgT+pI8yyfIQJVKZq+r5kQRUpF8aahHpG2yB5wCTfES39MlkuoG7zYwZTdCAvKLQThqKoWxhqW7obX8g/TRK+HYEgj3zT/MAHzFxkQfHU8zxdbn6PBsmzKpkTOLQJxHcWhtuzWLQwWf2aXK7xlCPh18oWUodcwfGJrnXTA4iQD/EJ5etzZFzAp2In0UgZCeUkJnURiI25CnIrfCGK99xRpYDpRsVo1ouHo2Y3sckLmkle49vj6ohqkYxs2RrSIsiOUZL9ZE+3S7SOcdnmjl/1q+G19axScklaWLzJGd+mkbnN9gdFJ8FOLzrIYRnuOPf+Xw+DNeB0sz9/HkgajTEtO9PO+GlpM6/tvig64h8QWOLhBNJJnWUW6ldrADh8/dryc4YkSwuHd13fI+rHR2KXI/F4nO3VAWNuIYhGbNaAaigNQ3Ay2Sd+w/vnbrZzQyRWtzcWjQmQ3QsvoaHjR0WGWP2tjpU95XE8MvwRo6PCQG15MjJLTIm9+nIccWf0AAy7z2jVQnKv/w2T3wuuy+RlvbvreUdAaDA9nNEPkxecUjnh54F6M+ilXAkrQh4nS8J0oHLmnZijAtFyAjR3aGoeSZwy2a7XL+WFVaVm6c4GYXHWW1CLA+/gcVKm148xnRD7ZKtTSLSzkFwm5uSSA7AyP7Wcxug2X8pUGnnJjRvD0BdEIlRUU7MXHJs3V/vpKamQC6XOwU89yQYtd7Qfz5BW9kS9SHrR5zzIA/dKTE+7NItI1hl0r8rZDZor42JGbKm7L9jfefd4Txi8uRWrxjejE8Y7dFMfbeoyuJqjm7p4NG3IL4cpfMku1Yuyt3tGS9/b32oufisjrgBQbYnGA10wTP6fuSE7XotD9lyNSEjfgOQJmIFFS99fMNR5RKBJfu4XRRnZL/Z0C2Ay6Me2LWBLgm0FsFdN8bG4ngaQidoZaTS8H/nup1R1Ig+Wk43woGKFJbpYTnq31cm8xF0yqskTaH+iu9W7qoIN3cNUVvNqhRYLdM5yIaMgRplvZ X-OriginatorOrg: mt.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f2bd340-9d65-4363-2f92-08dd2f2411e2 X-MS-Exchange-CrossTenant-AuthSource: DBBPR03MB5399.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:03:32.2965 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fb4c0aee-6cd2-482f-a1a5-717e7c02496b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WJXdlJhSfuFPGzV+lAHFtLro03/teUm5HqkHBZViMw9hCVxOnMtdp+D8NPX3Ouh6FkuUpv/qsNcY/UpRSi+xJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB6544 |
Series |
Input: matrix-keypad: Various performance improvements
|
expand
|
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c index fdb3499..ddf2672 100644 --- a/drivers/input/keyboard/matrix_keypad.c +++ b/drivers/input/keyboard/matrix_keypad.c @@ -125,6 +125,10 @@ static void matrix_keypad_scan(struct work_struct *work) const unsigned short *keycodes = input_dev->keycode; uint32_t new_state[MATRIX_MAX_COLS]; int row, col, code; + u32 init_row_state, new_row_state; + + /* read initial row state to detect changes between scan */ + init_row_state = read_row_state(keypad); /* de-activate all columns for scanning */ activate_all_cols(keypad, false); @@ -173,6 +177,19 @@ static void matrix_keypad_scan(struct work_struct *work) keypad->scan_pending = false; enable_row_irqs(keypad); } + + /* read new row state and detect if value has changed */ + new_row_state = read_row_state(keypad); + if (init_row_state != new_row_state) { + scoped_guard(spinlock_irq, &keypad->lock) { + if (unlikely(keypad->scan_pending || keypad->stopped)) + return; + disable_row_irqs(keypad); + keypad->scan_pending = true; + schedule_delayed_work(&keypad->work, + msecs_to_jiffies(keypad->debounce_ms)); + } + } } static irqreturn_t matrix_keypad_interrupt(int irq, void *id)
For a setup where the matrix keypad is connected over a slow interface (e.g. a gpio-expansion over i2c), the scan can take a longer time to read. Interrupts need to be disabled during scan. And therefore changes in this period are not detected. To improve this situation, scan the matrix again if the row state changed during interrupts disabled. The rescan is repeated until no change is detected anymore. Signed-off-by: Markus Burri <markus.burri@mt.com> --- drivers/input/keyboard/matrix_keypad.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)