Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

gpio_keys how to ? / Armbian Legacy Jessie

Featured Replies

All of the docs that I see on how to use the kernel gpio_keys refers to dts (device tree).   

 

The kernel module is present in Armbian legacy 5.20 Jessie Desktop.   /lib/modules/3.4.112...../gpio_keys.ko

 

I understand it should map gpio inputs to keystrokes.   But all usage/configuration info I can find refers to entries made in Device Tree --

gpio-keys {        compatible = "gpio-keys";        left-key {            label = "Left key";            gpios = <&gpio0 17 0>;            linux,code = <69>; /* KEY_LEFT */        };    }

This refers to some other underlying hardware, but it is an example...

 

So my question... I don't believe Armbian legacy handles device tree.  So what would I need to do to map a gpio pin to a keystroke in kernel space.   Or is there a sysfs option I'm missing also missing?

 

I can write a kernel module if needed, but I'd prefer not to actually modify/compile the armbian kernel as provided.

 

Thanks,

Kevin

 

 

 

 

Depending on number of buttons that you need, you could

  • write your own implementation of gpio_keys_get_devtree_pdata (in drivers/input/keyboard/gpio_keys.c or drivers/input/keyboard/gpio_keys_polled.c) that would use fex file instead of DT for data
  • check out sunxi-keyboard.c and sunxi-keypad.c in the same directory. Looking at the code, sunxi-keyboard is LRADC based, and sunxi-keypad is for matrix keypads, but they are using predefined pins for LRADC and keypad controllers, you'll have to check datasheet and schematics to see if these pins are available on pin headers.
  • Author

Thank you for the quick response.

 

sunxi-keyboard and sunxi-keypad seem to be too specific for my use....  I'm just looking for one or two push buttons, and something that can be dynamically set (kernel module params or sysfs or fex)

 

I like your idea of taking gpio_keys.c and making a new kernel module and having read the fex file.   That may be the route I take.

 

Have you ever heard of a kernel module which takes settings from sysfs and performs gpio to keyboard input?

 

Thanks,

Kevin

Have you ever heard of a kernel module which takes settings from sysfs and performs gpio to keyboard input?

No, this is too specific to be included in the kernel IMO. Single buttons (like "Suspend/Wake" button on Orange Pi boards) have its own driver, and keypads or keyboards with big number of buttons are designed to work with specific controllers or with generic drivers like gpio_keys.

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.