* [PATCH v6 0/3] Input: matrix-keypad: Various performance improvements
@ 2025-02-26 15:28 Markus Burri
2025-02-26 15:28 ` [PATCH v6 1/3] Input: matrix_keypad - add function for reading row state Markus Burri
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Markus Burri @ 2025-02-26 15:28 UTC (permalink / raw)
To: linux-kernel
Cc: Markus Burri, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Marek Vasut, linux-input, devicetree, Markus Burri,
Manuel Traut
This series is needed to avoid key-loss if the GPIOs are connected via a
I2C GPIO MUX that introduces additional latencies between key change and
matrix scan.
This series applies on 6.14-rc4
---
Changes in V6:
* adapt dt-bindings description for gpio-activelow
* remove applied patches (https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git/log/)
Changes in V5:
* formatting and typo
Changes in V4:
* deprecate gpio-activelow in gpio-matrix-keypad.yaml
* change reference to linux,keymap in gpio-matrix-keypad.yaml
Changes in V3:
* fix 'references a file that doesn't exist' in wakeup-source.txt
* remove copied and deprecated properties from gpio-matrix-keypad.yaml
* extend patch description to clarify the changes
* rebase to 6.13-rc6
Changes in V2:
* added patch to convert dt-bindings to YAML
* added missing dt-bindings properties description
* removed [PATCH 1/6] Input: matrix_keypad - move gpio-row init to the init
it would revert 01c84b03d80aab9f04c4e3e1f9085f4202ff7c29
* removed internally given Tested-by and Reviewed-by tags
[V5] https://lore.kernel.org/lkml/20250110054906.354296-1-markus.burri@mt.com/
[V4] https://lore.kernel.org/lkml/20250108134507.257268-1-markus.burri@mt.com/
[V3] https://lore.kernel.org/lkml/20250107135659.185293-1-markus.burri@mt.com/
[V2] https://lore.kernel.org/lkml/20241105130322.213623-1-markus.burri@mt.com/
[V1] https://lore.kernel.org/lkml/20241031063004.69956-1-markus.burri@mt.com/
Markus Burri (3):
Input: matrix_keypad - add function for reading row state
dt-bindings: input: matrix_keypad - add missing property
Input: matrix_keypad - detect change during scan
.../bindings/input/gpio-matrix-keypad.yaml | 5 ++++
drivers/input/keyboard/matrix_keypad.c | 30 +++++++++++++++++--
2 files changed, 32 insertions(+), 3 deletions(-)
base-commit: d082ecbc71e9e0bf49883ee4afd435a77a5101b6
prerequisite-patch-id: bb305aaedfe8c51a577a4995259b03dbc918e22f
prerequisite-patch-id: 952ec63bb9d0c7a79f87d9e47386eb87e2a0075c
prerequisite-patch-id: 6e4d765fc9f3ca7bd204b9b461f64adcafb815c0
prerequisite-patch-id: bf32190799d208ecee6e241204278ebd5835270e
--
2.39.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v6 1/3] Input: matrix_keypad - add function for reading row state
2025-02-26 15:28 [PATCH v6 0/3] Input: matrix-keypad: Various performance improvements Markus Burri
@ 2025-02-26 15:28 ` Markus Burri
2025-02-26 15:28 ` [PATCH v6 2/3] dt-bindings: input: matrix_keypad - add missing property Markus Burri
2025-02-26 15:28 ` [PATCH v6 3/3] Input: matrix_keypad - detect change during scan Markus Burri
2 siblings, 0 replies; 5+ messages in thread
From: Markus Burri @ 2025-02-26 15:28 UTC (permalink / raw)
To: linux-kernel
Cc: Markus Burri, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Marek Vasut, linux-input, devicetree, Markus Burri,
Manuel Traut
Move the evaluation of a row state into separate function.
It will be also used by a change later in this series.
Signed-off-by: Markus Burri <markus.burri@mt.com>
---
drivers/input/keyboard/matrix_keypad.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index e46473cb8..fdb349966 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -104,6 +104,16 @@ static void disable_row_irqs(struct matrix_keypad *keypad)
disable_irq_nosync(keypad->row_irqs[i]);
}
+static uint32_t read_row_state(struct matrix_keypad *keypad)
+{
+ int row;
+ u32 row_state = 0;
+
+ for (row = 0; row < keypad->num_row_gpios; row++)
+ row_state |= row_asserted(keypad, row) ? BIT(row) : 0;
+ return row_state;
+}
+
/*
* This gets the keys from keyboard and reports it to input subsystem
*/
@@ -129,9 +139,7 @@ static void matrix_keypad_scan(struct work_struct *work)
activate_col(keypad, col, true);
- for (row = 0; row < keypad->num_row_gpios; row++)
- new_state[col] |=
- row_asserted(keypad, row) ? BIT(row) : 0;
+ new_state[col] = read_row_state(keypad);
activate_col(keypad, col, false);
}
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v6 2/3] dt-bindings: input: matrix_keypad - add missing property
2025-02-26 15:28 [PATCH v6 0/3] Input: matrix-keypad: Various performance improvements Markus Burri
2025-02-26 15:28 ` [PATCH v6 1/3] Input: matrix_keypad - add function for reading row state Markus Burri
@ 2025-02-26 15:28 ` Markus Burri
2025-02-28 1:07 ` Dmitry Torokhov
2025-02-26 15:28 ` [PATCH v6 3/3] Input: matrix_keypad - detect change during scan Markus Burri
2 siblings, 1 reply; 5+ messages in thread
From: Markus Burri @ 2025-02-26 15:28 UTC (permalink / raw)
To: linux-kernel
Cc: Markus Burri, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Marek Vasut, linux-input, devicetree, Markus Burri,
Manuel Traut
The property is implemented in the driver but not described in dt-bindings.
Add missing property 'gpio-activelow' to DT schema.
Signed-off-by: Markus Burri <markus.burri@mt.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
---
.../devicetree/bindings/input/gpio-matrix-keypad.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/input/gpio-matrix-keypad.yaml b/Documentation/devicetree/bindings/input/gpio-matrix-keypad.yaml
index 4a5893edf..73bb153ed 100644
--- a/Documentation/devicetree/bindings/input/gpio-matrix-keypad.yaml
+++ b/Documentation/devicetree/bindings/input/gpio-matrix-keypad.yaml
@@ -40,6 +40,11 @@ properties:
type: boolean
description: Do not enable autorepeat feature.
+ gpio-activelow:
+ type: boolean
+ description:
+ Force GPIO polarity to active low.
+ In the absence of this property GPIOs are treated as active high.
debounce-delay-ms:
description: Debounce interval in milliseconds.
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v6 3/3] Input: matrix_keypad - detect change during scan
2025-02-26 15:28 [PATCH v6 0/3] Input: matrix-keypad: Various performance improvements Markus Burri
2025-02-26 15:28 ` [PATCH v6 1/3] Input: matrix_keypad - add function for reading row state Markus Burri
2025-02-26 15:28 ` [PATCH v6 2/3] dt-bindings: input: matrix_keypad - add missing property Markus Burri
@ 2025-02-26 15:28 ` Markus Burri
2 siblings, 0 replies; 5+ messages in thread
From: Markus Burri @ 2025-02-26 15:28 UTC (permalink / raw)
To: linux-kernel
Cc: Markus Burri, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Marek Vasut, linux-input, devicetree, Markus Burri,
Manuel Traut
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 | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index fdb349966..e50a6fea9 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,18 @@ 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) {
+ 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)
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v6 2/3] dt-bindings: input: matrix_keypad - add missing property
2025-02-26 15:28 ` [PATCH v6 2/3] dt-bindings: input: matrix_keypad - add missing property Markus Burri
@ 2025-02-28 1:07 ` Dmitry Torokhov
0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2025-02-28 1:07 UTC (permalink / raw)
To: Markus Burri
Cc: linux-kernel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Marek Vasut, linux-input, devicetree, Markus Burri, Manuel Traut
On Wed, Feb 26, 2025 at 04:28:42PM +0100, Markus Burri wrote:
> The property is implemented in the driver but not described in dt-bindings.
> Add missing property 'gpio-activelow' to DT schema.
>
> Signed-off-by: Markus Burri <markus.burri@mt.com>
> Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Applied but dropped Rob's reviewed-by because the patch is different
from what he has reviewed.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-28 1:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 15:28 [PATCH v6 0/3] Input: matrix-keypad: Various performance improvements Markus Burri
2025-02-26 15:28 ` [PATCH v6 1/3] Input: matrix_keypad - add function for reading row state Markus Burri
2025-02-26 15:28 ` [PATCH v6 2/3] dt-bindings: input: matrix_keypad - add missing property Markus Burri
2025-02-28 1:07 ` Dmitry Torokhov
2025-02-26 15:28 ` [PATCH v6 3/3] Input: matrix_keypad - detect change during scan Markus Burri
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).