linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* accelerometer orientation
@ 2016-09-12 15:25 Hans de Goede
  2016-09-12 15:39 ` Bastien Nocera
  0 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2016-09-12 15:25 UTC (permalink / raw)
  To: Bastien Nocera, linux-iio

Hi Bastien,

So as I guess you sorta know in my spare time I work on Linux
(mainline) support for Allwinner SoC based ARM devices, including
a whole lot of cheap Chinese tablets.

Recently I've begun looking into supporting the accelerometers
on these devices and I'm making good progress on getting the
kernel bits working using iio drivers (including a few new
ones I've written recently).

Yesterday I realized there is a bit of a catch though, all
these iio drivers report results assuming that the accelerometer
is mounted on the top side of the PCB and with its X/Y
coordination properly taken info account.

Unfortunately neither is necessarily true. Almost all
tablet PCBS are mounted upside down (with an empty PCB
backside against the lcd-panel. Meaning that the Z axis
reads -1G when the tablet is lying on its back instead
of the expected +1G and some need X/Y axis swapping and/or
inversion too.

So there are 3 problems here:

1) Where do we store the orientation of the chip

For the allwinner tablets I'm working on the answer is
easy: In devicetree

2) Where do we correct the readings for the orientation

AFAIK the iio framework does not offer a way to fix the readings
up in the kernel (please correct me if I'm wrong), I'm seeing
something called an mount_matrix in iio which seems to be
able to convey the necessary info from the kernel to userspace.

So Bastien, would you be open to a (future) patch to
iio-sensor-proxy for reading and using this info,
or even better yet be willing to write one ?

In device tree it looks like this:

                 mount-matrix = "-0.984807753012208",  /* x0 */
                                "0",                   /* y0 */
                                "-0.173648177666930",  /* z0 */
                                "0",                   /* x1 */
                                "-1",                  /* y1 */
                                "0",                   /* z1 */
                                "-0.173648177666930",  /* x2 */
                                "0",                   /* y2 */
                                "0.984807753012208";   /* z2 */

And if I'm reading the iio-core code correctly the mount_matrix
sysfs attribute will contain a string with these 9 values
in text-format seperated by ","

3) Currently implementing orientation support in an iio driver
requires copy and pasting quite a bit of boiler plate, so
a question to the linux-iio list, has anyone though of an
easier way to do this. I really just want to be able to
pass say a single flag to iio_device_register and then
have the iio-core automatically call of_iio_read_mount_matrix()
and add mount_matrix ext_info.

Regards,

Hans


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

end of thread, other threads:[~2016-09-25  8:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-12 15:25 accelerometer orientation Hans de Goede
2016-09-12 15:39 ` Bastien Nocera
2016-09-12 16:15   ` Hans de Goede
2016-09-18 19:32     ` Jonathan Cameron
2016-09-19 14:14       ` Hans de Goede
2016-09-25  8:31         ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).