Skip to content

Register virtual GPIO keys for VNC

[email protected] linux-devicetree linux-input 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2dt-bindings vnc virtual inputDocumentation/devicetree/bindings/input/vnc-virtual-input.txt Documentation/devicetree/bindings/input/vnc-virtual-input.yaml MAINTAINERS+246 -01 reply
2/2ARM: dts: Add virtual GPIO input for VNC keyboardMAINTAINERS arch/arm/boot/dts/vnc-virtual-input.dtsi+570 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] Register virtual GPIO keys for VNC

From: Menglong Wu <[email protected]>

Test platform
-------------
Kernel: 4.14.98
Rootfs: BusyBox 1.29
QT: 4.7
x11vnc: 0.9.16

Purpose
-------------

To emulate a full ANSI keyboard on embedded devices without physical keyboards.
The server responds to key events via x11vnc.
This resolves the limitation where embedded systems only register a few GPIO keys, making them unable to process full keyboard inputs.

documented in Documentation/devicetree/bindings/input/vnc-virtual-input.yaml

Scenario
-------------

- /dev/input/event1: Physical GPIO buttons

- /dev/input/event2: Physical touchscreen

Assume my-pcb.dts defines two GPIO-based hardware keys (A and B). When the VNC server x11vnc is started, a remote PC connects via a VNC client and attempts to send key inputs.
Since the Linux kernel only recognizes two keys, the UI on the embedded device only responds to ‘A’ and ‘B’.

Start x11vnc server:

```
    x11vnc -noipv6 -rawfb /dev/fb0 -forever -clip 640x480+0+0 \
      -pipeinput UINPUT:touch,tslib_cal=/etc/pointercal,\
      direct_key=/dev/input/event1,\
      direct_abs=/dev/input/event2
```

Monitor key events:

```
    hexdump /dev/input/event1
```

Original my-pcb.dts:

```
    gpio_keys {
        compatible = "gpio-keys";
        pinctrl-0 = <&pinctrl_gpio_keys>;

        key-a {
            label = "btn-key-a";
            gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
            linux,code = <KEY_A>;
        };
        key-b {
            label = "btn-key-b";
            gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
            linux,code = <KEY_A>;
        };
    };
```

Solution
-------------

Modify my-pcb.dts to support a virtual ANSI keyboard:

```
    #include "vnc-virtual-input.dtsi"

    // Originally, the DTS relied on physical GPIO keys
    gpio_keys {
        // Disable the original physical key node
        status = "disable";
    };

    // The virtual GPIO DTS node now integrates physical GPIO
    vnc_key {
        compatible = "gpio-keys";
        pinctrl-0 = <&pinctrl_gpio_keys>;
        
        key-a {
            label = "btn-key-a";
            gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
            linux,code = <KEY_A>;
        };
        key-b {
            label = "btn-key-b";
            gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
            linux,code = <KEY_A>;
        };
    }
```

Menglong Wu (2):
dt-bindings vnc virtual input
ARM: dts: Add virtual GPIO input for VNC keyboard

 .../bindings/input/vnc-virtual-input.txt      | 153 +++++
 .../bindings/input/vnc-virtual-input.yaml     |  86 +++
 MAINTAINERS                                   |   8 +
 arch/arm/boot/dts/vnc-virtual-input.dtsi      | 569 ++++++++++++++++++
 4 files changed, 816 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/vnc-virtual-input.txt
 create mode 100644 Documentation/devicetree/bindings/input/vnc-virtual-input.yaml
 create mode 100644 arch/arm/boot/dts/vnc-virtual-input.dtsi
Signature · 1 line
2.39.5