Page MenuHomeFreeBSD

74HC153 multiplexer input support for evdev on gpiobus
AbandonedPublic

Authored by yamori813_yahoo.co.jp on May 14 2017, 11:58 PM.

Details

Summary

router button and slide switch support on evdev

Test Plan

on Buffalo WZR-HP-G300NH

Diff Detail

Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 9329
Build 9793: arc lint + arc unit

Event Timeline

This is hints for Buffalo WZR-HP-G300NH.

hint.hc153key.0.at="gpiobus0"
hint.hc153key.0.pins=0x00005a00
hint.hc153key.0.pina=0
hint.hc153key.0.pinb=1
hint.hc153key.0.pin1y=2
hint.hc153key.0.pin2y=3
hint.hc153key.0.swmask=0xf0

IMO, this driver can be written in generic way

sys/dev/gpio/hc153key.c
109

EV_KEY events should be used here unless you have to be compatible with already existing software written in broken way.

191

EV_SYN event support should be enabled unconditionally.

193

As before, EV_KEY should be used. If KEY codes needs to be customized from userland, EVIOCSKEYCODE_V2 ioctl exists but using of it requires some extra evdev hacking

227

If you do not need these events, I can extend KPI so it will be possible change internal state directly.

232

Evdev provides ev_open and ev_close callbacks for starting/stopping polling or interrupts on demand. You can use sys/arm/broadcom/bcm2835/bcm2835_ft5406.c as sample. In that case it is better to associate both evdev and callout instances to same mutex to avoid races.

sys/dev/gpio/hc153key.c
162

Tracking for button state edges is not needed here. Evdev does it for you.

163–164

You can not push key with 0(zero) code as it is reserved for evdev internals. I would add BTN_MISC offset here as you are reporting state of buttons rather than keys. (Keys are the part of a keyboard).

273

err = evdev_register_mtx(sc->sc_evdev, &sc->sc_mtx);

276

mtx_destroy ?

This code have compile error now. I will check, but now abandon.