[Letux-kernel] RFC: iio input bridge

H. Nikolaus Schaller hns at goldelico.com
Fri Dec 16 14:59:10 CET 2016

we still had some trouble on the GTA04 with the accelerometer
input driver (evtest /dev/input/accel). The reason is that it
is some misc driver for the BMA150 and we have mis-used it for
the bma180 although we didn't recognise that the bma180 has
different registers. Recently it was even proposed to remove the
(wrong) bma180 support completely.

Additionally, for the Pyra and GTA04A5 with BMC150 accelerometer
we even have no input compatible driver.

Writing new input accelerometer drivers isn't a good strategy
since this feature is considered old by kernel maintainers because
there are already good iio drivers around and they suggest to
use those.

This is easy for new designs where user-space is also easily

But the problem is that some (older) user spaces (e.g. Replicant)
assumes that device position is reported through /dev/input.
And Linus say: "we never break user space...". Therefore
simply dropping the bma180 support and using iio only is no
working solution.

A new idea was to add an iio-input bridge driver into the
iio core framework which simply looks for iio accelerometers
and takes the first 3 channels as X, Y and Z. It then registers
a new /dev/input device, reads the iio channels every 1/10th
second, scales the values and sends input events.

An important design choice was to implement it in a way that
we don't need any DT updates and that it is self-configuring,
at least for boards with a single 3-axis accelerometer. And
that the extension is completely disabled if not configured into
the kernel.

The result of hacking a little around is that we now have the
/dev/input/accel for all devices (GTA04 with BMA180, GTA04A5
and Pyra with BMC150 - if installed - and BNO055 should also
work if configured for accelerometer).

Code isn't clean but works:


Comments are welcome.


More information about the Letux-kernel mailing list