mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] input: Supersede input_key_get_status() with input_is_key_pressed()
@ 2026-05-07 11:10 Jonas Rebmann
  2026-05-07 11:10 ` [PATCH 1/2] input: add input_is_key_pressed() to read single key Jonas Rebmann
  2026-05-07 11:10 ` [PATCH 2/2] ARM: boards: protonic-imx6: use input_is_key_pressed() Jonas Rebmann
  0 siblings, 2 replies; 3+ messages in thread
From: Jonas Rebmann @ 2026-05-07 11:10 UTC (permalink / raw)
  To: Sascha Hauer, BAREBOX; +Cc: Jonas Rebmann

Reading a GPIO button via gpio-keys can be preferable over direct GPIO
access as gpio-keys abstracts away from GPIO hardware via the
devicetree, consistently across barebox and linux.

Trying to read a single key state analogous to prt_imx6_init_prtvt7
failed as input_key_get_status should have been provided with the
keycode in question plus one to ensure a large enough bitfield to
contain the desired key state.

The correct way of reading a single key state via the
input_key_get_status() interface is as complicated as

    bool is_button_pressed(int key) {
        unsigned long *keys;
        bool pressed;

        keys = bitmap_xzalloc(key + 1);
        input_key_get_status(keys, key + 1);

        pressed = test_bit(key, keys);

        free(keys);
        return pressed;
   }

This series implements a simple way to read the state of a single key
directly in the input driver.

As this can easily be invoked twice to check for a key combination,
replace this single occurence of input_key_get_status() with
input_is_key_pressed().

While those changes where thoroughly tested on a board with boardcode
very similar to protonic-imx6, the change to protonic-imx6 itself is
untested.

I suppose we have to keep input_key_get_status() for now for backwards
compatibility with downstream board code?

Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
---
Jonas Rebmann (2):
      input: add input_is_key_pressed() to read single key
      ARM: boards: protonic-imx6: use input_is_key_pressed()

 arch/arm/boards/protonic-imx6/board.c |  8 +-------
 drivers/input/input.c                 | 14 ++++++++++++++
 include/input/input.h                 |  1 +
 3 files changed, 16 insertions(+), 7 deletions(-)
---
base-commit: 7a178f01f6e25474a5eb6e071ca479076b8d4d92
change-id: 20260507-input_is_key_pressed-4472a8a29980

Best regards,
--  
Jonas Rebmann <jre@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-07 11:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-07 11:10 [PATCH 0/2] input: Supersede input_key_get_status() with input_is_key_pressed() Jonas Rebmann
2026-05-07 11:10 ` [PATCH 1/2] input: add input_is_key_pressed() to read single key Jonas Rebmann
2026-05-07 11:10 ` [PATCH 2/2] ARM: boards: protonic-imx6: use input_is_key_pressed() Jonas Rebmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox