iio: core: Introduce _zeropoint for differential channels
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 26 Jun 2022 12:29:32 +0000 (13:29 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 15 Aug 2022 21:30:01 +0000 (22:30 +0100)
commit5c64990b99aa91622cf044a9a2f7a78de8f770a2
tree7dd6a06389ed9d6bfc41acb2b65d5abf46b919e9
parent431e9147b4667d67399fe5db4f8203d55811951b
iio: core: Introduce _zeropoint for differential channels

Address an ABI gap for device where the offset of both lines in a
differential pair may be controlled so as to allow a wider range of
inputs, but without having any direct effect of the differential
measurement.

_offset cannot be used as to remain in line with existing usage,
userspace would be expected to apply it as (_raw + _offset) * _scale
whereas _zeropoint is not. i.e. If we were computing the differential
in software it would be.
((postive_raw + _zeropoint) - (negative_raw + zeropoint) + _offset) * _scale
= ((postive_raw - negative_raw) + _offset) * _scale
= (differential_raw + _offset) * _scale

Similarly calibbias is expected to tweak the measurement seen, not
the adjust the two lines of the differential pair.

Needed for in_capacitanceX-capacitanceY_zeropoint for the
AD7746 CDC driver.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220626122938.582107-12-jic23@kernel.org
Documentation/ABI/testing/sysfs-bus-iio
drivers/iio/industrialio-core.c
include/linux/iio/types.h