iio: introduce mag_referenced
authorCosmin Tanislav <demonsingur@gmail.com>
Mon, 14 Feb 2022 07:38:06 +0000 (09:38 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 21 Feb 2022 19:33:05 +0000 (19:33 +0000)
Some accelerometers that support activity and inactivity
events also support a referenced mode, in which the
gravitational acceleration is taken as a point of
reference before comparing the acceleration to the
specified activity and inactivity magnitude.

For example, in the case of the ADXL367, for activity
detection, the formula is:

abs(acceleration - reference) > magnitude

Add a new event type that makes this behavior clear.

Signed-off-by: Cosmin Tanislav <cosmin.tanislav@analog.com>
Link: https://lore.kernel.org/r/20220214073810.781016-2-cosmin.tanislav@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/industrialio-event.c
include/uapi/linux/iio/types.h
tools/iio/iio_event_monitor.c

index d0732eac0f0aceefefef3e433da9abaf15dae097..ce8b102ce52fd63ec98c6265286b3d1b94d422cf 100644 (file)
@@ -230,6 +230,7 @@ static const char * const iio_ev_type_text[] = {
        [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive",
        [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive",
        [IIO_EV_TYPE_CHANGE] = "change",
+       [IIO_EV_TYPE_MAG_REFERENCED] = "mag_referenced",
 };
 
 static const char * const iio_ev_dir_text[] = {
index 48c13147c0a8707d82d809655ffdc450af982ce3..472cead10d8d63630687d93a49ebdd895add30e6 100644 (file)
@@ -104,6 +104,7 @@ enum iio_event_type {
        IIO_EV_TYPE_THRESH_ADAPTIVE,
        IIO_EV_TYPE_MAG_ADAPTIVE,
        IIO_EV_TYPE_CHANGE,
+       IIO_EV_TYPE_MAG_REFERENCED,
 };
 
 enum iio_event_direction {
index b94a16ba5c6c100ccf0a406f88c116525fdce059..2f4581658859979e82ecac61db23dc0c6b35bab7 100644 (file)
@@ -68,6 +68,7 @@ static const char * const iio_ev_type_text[] = {
        [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive",
        [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive",
        [IIO_EV_TYPE_CHANGE] = "change",
+       [IIO_EV_TYPE_MAG_REFERENCED] = "mag_referenced",
 };
 
 static const char * const iio_ev_dir_text[] = {