From: Xiong Nandi <xndchn@gmail.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Xiong Nandi <xndchn@gmail.com>,
Gatien Chevallier <gatien.chevallier@foss.st.com>,
Marco Crivellari <marco.crivellari@suse.com>,
Thomas Gleixner <tglx@kernel.org>,
Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Subject: [PATCH v2 1/3] Input: gpio-keys - set EV_ABS axis parameters at setup time
Date: Sun, 22 Mar 2026 19:35:06 +0800 [thread overview]
Message-ID: <20260322113513.9380-2-xndchn@gmail.com> (raw)
In-Reply-To: <ab5CXO6Fk7lhGazv@google.com>
The driver calls input_set_capability() for EV_ABS axes but never
sets the actual axis parameters, so the input subsystem sees
unbounded ranges.
Add a helper that scans buttons sharing the same axis code, works
out the min/max values, and calls input_set_abs_params().
Signed-off-by: Xiong Nandi <xndchn@gmail.com>
---
drivers/input/keyboard/gpio_keys.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index e19617485679..f97ca8dd073a 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -493,6 +493,27 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id)
return IRQ_HANDLED;
}
+static void gpio_keys_set_abs_params(struct input_dev *input,
+ struct gpio_keys_drvdata *ddata,
+ unsigned int code)
+{
+ int i, min = 0, max = 0;
+
+ for (i = 0; i < ddata->pdata->nbuttons; i++) {
+ const struct gpio_keys_button *button = &ddata->pdata->buttons[i];
+
+ if (button->type != EV_ABS || button->code != code)
+ continue;
+
+ if (button->value < min)
+ min = button->value;
+ if (button->value > max)
+ max = button->value;
+ }
+
+ input_set_abs_params(input, code, min, max, 0, 0);
+}
+
static int gpio_keys_setup_key(struct platform_device *pdev,
struct input_dev *input,
struct gpio_keys_drvdata *ddata,
@@ -651,6 +672,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
bdata->code = &ddata->keymap[idx];
*bdata->code = button->code;
input_set_capability(input, button->type ?: EV_KEY, *bdata->code);
+ if ((button->type ?: EV_KEY) == EV_ABS)
+ gpio_keys_set_abs_params(input, ddata, button->code);
/*
* Install custom action to cancel release timer and
--
2.25.1
next prev parent reply other threads:[~2026-03-22 11:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 14:52 [PATCH] Input: gpio-keys - add full support of EV_REL and EV_ABS Xiong Nandi
2026-03-21 7:06 ` Dmitry Torokhov
2026-03-22 11:35 ` [PATCH v2 0/3] " Xiong Nandi
2026-03-22 11:35 ` Xiong Nandi [this message]
2026-03-22 11:35 ` [PATCH v2 2/3] Input: gpio-keys - use shared axis counter for EV_ABS events Xiong Nandi
2026-03-22 11:35 ` [PATCH v2 3/3] Input: gpio-keys - add EV_REL event type support Xiong Nandi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260322113513.9380-2-xndchn@gmail.com \
--to=xndchn@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=fabrice.gasnier@foss.st.com \
--cc=gatien.chevallier@foss.st.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marco.crivellari@suse.com \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.