Re: [PATCH v3 2/3] iio:magnetometer:ak8975: mounting matrix support
From: Rob Herring <hidden>
Date: 2016-03-22 12:38:21
Also in:
linux-iio
On Mon, Mar 21, 2016 at 5:21 PM, Gregor Boirie [off-list ref] wrote:
Hi Rob, On Mon, Mar 21, 2016 at 09:58:46AM -0500, Rob Herring wrote:quoted
On Thu, Mar 17, 2016 at 11:43 AM, Gregor Boirie [off-list ref] wrote:quoted
Expose a rotation matrix to indicate userspace the chip placement with respect to the overall hardware system. This is needed to adjust coordinates sampled from a magnetometer chip when its position deviates from the main hardware system. Final coordinates computation is delegated to userspace since: * computation may involve floating point arithmetics ; * it allows an application to combine adjustments with arbitrary transformations. This 3 dimentional space rotation matrix is expressed as 3x3 array of strings to support floating point numbers. It may be retrieved from a "in_magn_matrix" sysfs attribute file. It is declared into ak8975 DTS entry as a "matrix" property.Why is the sysfs interface specific to ak8975?AFAIK, this is just the first IIO driver implementation relying on floating point numbers. Should a single driver be enough to justify a "generic" API, I suppose code could be factored out in a similar way to over sampling rate support. People could call this on a per-driver basis.
Given it is an ABI, yes I think so. We don't want to end up with a bunch of similar yet different interfaces.
quoted
Furthermore, why is it specific to magnetometer? Couldn't accelerometers need the same thing? There's a thread discussing a similar matrix on android-x86[1].Same may apply to gyro / accelero / imu and magnetometers at least. inv_mpu_core.c already implements such a rotation matrix exposed as 3x3 integers array. Should we be smart enough to keep this compatible with existing userspace apps ?
You have to maintain the ABI. If both interfaces can co-exist, then you can have both and mark the old one as deprecated. In time we can remove the old one.
quoted
quoted
diff --git a/Documentation/devicetree/bindings/iio/magnetometer/ak8975.txt b/Documentation/devicetree/bindings/iio/magnetometer/ak8975.txt index 34a3206..f936f86 100644 --- a/Documentation/devicetree/bindings/iio/magnetometer/ak8975.txt +++ b/Documentation/devicetree/bindings/iio/magnetometer/ak8975.txt@@ -9,6 +9,7 @@ Optional properties: - gpios : should be device tree identifier of the magnetometer DRDY pin - vdd-supply: an optional regulator that needs to be on to provide VDD + - matrix: an optional 3x3 mounting rotation matrixPerhaps "rotation-matrx" would be a better name in case there's ever any other matrix needed.What about "mounting-matrix" ?
Sure. Rob