Introduce IIO interface for Android advanced features
Subsystems (3)
v2 cover Introduce IIO interface for Android advanced features
This patchset introduces a new interface for supporting some of the composite sensors in Android [1]. First supported sensors are activity and pedometer.
This is a follow up of the discussion about adding new channels to IIO initiated some time ago on IIO list [2].
A device that has the activity/pedometer functionality is Freescale's MMA9553L ([3]).
Because we don't have yet the hardware, to demonstrate these new channels we update iio_dummy kernel module and iio_event_monitor test program. We want to get an early feedback about extending the IIO interface in the correct direction.
[1] http://source.android.com/devices/sensors/composite_sensors.html
[2] http://marc.info/?l=linux-iio&m=138374342831057&w=2
[3] http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf
Changes since v1 (mostly based on comments from Jonathan)
* introduce TRANSITION event instead of MOTION to better represent multilevel state change
* remove pedometer channel type and steps modifier and replace it with steps channel type
* squashed together patches introducing channels and associated events
* introduced IIO_EV_DIR_NONE
* changed cover letter subject to reflect the changes
Daniel Baluta (4):
iio: dummy: Add virtual registers for dummy device
iio: core: Introduce IIO_ACTIVITY channel and TRANSITION event
iio: dummy: Demonstrate the usage of new channel types
iio: event_monitor: Add support for new channel types
Irina Tirdea (3):
iio: core: Introduce IIO_EV_DIR_NONE
iio: core: Introduce STEPS channel type, ENABLE mask and INSTANCE
event
iio: core: Introduce HEIGHT channel type
Documentation/ABI/testing/sysfs-bus-iio | 75 ++++++++ drivers/iio/industrialio-core.c | 8 + drivers/iio/industrialio-event.c | 14 +- .../staging/iio/Documentation/iio_event_monitor.c | 25 ++- drivers/staging/iio/iio_dummy_evgen.c | 16 ++ drivers/staging/iio/iio_dummy_evgen.h | 6 + drivers/staging/iio/iio_simple_dummy.c | 199 +++++++++++++++++++-- drivers/staging/iio/iio_simple_dummy.h | 7 + drivers/staging/iio/iio_simple_dummy_events.c | 61 ++++++- include/linux/iio/iio.h | 1 + include/linux/iio/types.h | 12 +- 11 files changed, 393 insertions(+), 31 deletions(-)
Signature · 1 line
1.9.1
RFC PATCH v2 1/7 iio: dummy: Add virtual registers for dummy device
We need a way to store events generated by iio_dummy_evgen module, in order to correctly process IRQs in iio_simple_dummy_events.
For the moment, we add two registers:
* id_reg - ID register, stores the source of the event
* id_data - DATA register, stores the type of the event
e.g echo 4 > /sys/bus/iio/devices/iio_evgen/poke2
id_reg 0x02, id_data 0x04
This means, event of type 4 was generated by fake device 2.
We currently use a hardcoded mapping of virtual events to IIO events.
--- drivers/staging/iio/iio_dummy_evgen.c | 16 ++++++++++++++++ drivers/staging/iio/iio_dummy_evgen.h | 6 ++++++ drivers/staging/iio/iio_simple_dummy.h | 2 ++ drivers/staging/iio/iio_simple_dummy_events.c | 23 ++++++++++++++++++----- 4 files changed, 42 insertions(+), 5 deletions(-)
drivers/staging/iio/iio_dummy_evgen.c +16 -0
@@ -33,6 +33,7 @@* @base: base of irq range * @enabled: mask of which irqs are enabled * @inuse: mask of which irqs are connected +* @regs: irq regs we are faking * @lock: protect the evgen state */ struct iio_dummy_eventgen {
@@ -40,6 +41,7 @@ struct iio_dummy_eventgen {int base;bool enabled[IIO_EVENTGEN_NO ];bool inuse[IIO_EVENTGEN_NO ]; +struct iio_dummy_regs regs[IIO_EVENTGEN_NO ];struct mutex lock; };
@@ -136,6 +138,12 @@ int iio_dummy_evgen_release_irq(int irq) }EXPORT_SYMBOL_GPL (iio_dummy_evgen_release_irq); +struct iio_dummy_regs *iio_dummy_evgen_get_regs (int irq) +{ +return &iio_evgen->regs[irq - iio_evgen->base]; +} +EXPORT_SYMBOL_GPL (iio_dummy_evgen_get_regs); +static void iio_dummy_evgen_free (void ) {irq_free_descs (iio_evgen->base,IIO_EVENTGEN_NO );
@@ -153,6 +161,14 @@ static ssize_t iio_evgen_poke(struct device *dev, size_t len) {struct iio_dev_attr *this_attr =to_iio_dev_attr (attr); +unsigned long event, ret; + + ret =kstrtoul (buf,10 , &event); +if (ret) +return ret; + + iio_evgen->regs[this_attr->address].reg_id = this_attr->address; + iio_evgen->regs[this_attr->address].reg_data = event;if (iio_evgen->enabled[this_attr->address])handle_nested_irq (iio_evgen->base + this_attr->address);
drivers/staging/iio/iio_dummy_evgen.h +6 -0
@@ -1,2 +1,8 @@ +struct iio_dummy_regs { +u32 reg_id; +u32 reg_data; +}; + +struct iio_dummy_regs *iio_dummy_evgen_get_regs (int irq);int iio_dummy_evgen_get_irq (void );int iio_dummy_evgen_release_irq (int irq);
drivers/staging/iio/iio_simple_dummy.h +2 -0
@@ -11,6 +11,7 @@#include <linux/kernel.h> struct iio_dummy_accel_calibscale ; +struct iio_dummy_regs ;/** * struct iio_dummy_state - device instance specific state.
@@ -33,6 +34,7 @@ struct iio_dummy_state {int accel_calibbias;const struct iio_dummy_accel_calibscale *accel_calibscale;struct mutex lock; +struct iio_dummy_regs *regs;#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS int event_irq;int event_val;
drivers/staging/iio/iio_simple_dummy_events.c +18 -5
@@ -148,12 +148,23 @@ int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,static irqreturn_t iio_simple_dummy_event_handler (int irq,void *private) {struct iio_dev *indio_dev = private; +struct iio_dummy_state *st =iio_priv (indio_dev); + +dev_dbg (&indio_dev->dev,"id %x event %x\n" , + st->regs->reg_id, st->regs->reg_data); + +switch (st->regs->reg_data) { +case 0 : +iio_push_event (indio_dev, +IIO_EVENT_CODE (IIO_VOLTAGE ,0 ,0 , +IIO_EV_DIR_RISING , +IIO_EV_TYPE_THRESH ,0 ,0 ,0 ), +iio_get_time_ns ()); +break ; +default : +break ; + } -iio_push_event (indio_dev, -IIO_EVENT_CODE (IIO_VOLTAGE ,0 ,0 , -IIO_EV_DIR_RISING , -IIO_EV_TYPE_THRESH ,0 ,0 ,0 ), -iio_get_time_ns ());return IRQ_HANDLED ; }
@@ -179,6 +190,8 @@ int iio_simple_dummy_events_register(struct iio_dev *indio_dev) ret = st->event_irq; goto error_ret; } + st->regs =iio_dummy_evgen_get_regs (st->event_irq); + ret = request_threaded_irq(st->event_irq, NULL, &iio_simple_dummy_event_handler,
Signature · 1 line
1.9.1
Re: [RFC PATCH v2 1/7] iio: dummy: Add virtual registers for dummy device
Quoted 10 lines · Daniel Baluta
We need a way to store events generated by
iio_dummy_evgenmodule, in order to correctly process IRQs iniio_simple_dummy_events.For the moment, we add two registers:
*
id_reg- ID register, stores the source of the event
*id_data- DATA register, stores the type of the evente.g echo 4 >
/sys/bus/iio/devices/iio_evgen/poke2
Quoted 8 lines
id_reg0x02,id_data0x04This means, event of type 4 was generated by fake device 2.
We currently use a hardcoded mapping of virtual events to IIO events.
Signed-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>
Applied to the togreg branch of iio.git.
Initially pushed out as testing for the autobuilders to play with it.
Quoted 131 lines
--- drivers/staging/iio/iio_dummy_evgen.c | 16 ++++++++++++++++ drivers/staging/iio/iio_dummy_evgen.h | 6 ++++++ drivers/staging/iio/iio_simple_dummy.h | 2 ++ drivers/staging/iio/iio_simple_dummy_events.c | 23 ++++++++++++++++++----- 4 files changed, 42 insertions(+), 5 deletions(-)drivers/staging/iio/iio_dummy_evgen.c +16
-0@@ -33,6 +33,7 @@* @base: base of irq range * @enabled: mask of which irqs are enabled * @inuse: mask of which irqs are connected +* @regs: irq regs we are faking * @lock: protect the evgen state */ struct iio_dummy_eventgen {@@ -40,6 +41,7 @@ struct iio_dummy_eventgen {int base;bool enabled[IIO_EVENTGEN_NO ];bool inuse[IIO_EVENTGEN_NO ]; +struct iio_dummy_regs regs[IIO_EVENTGEN_NO ];struct mutex lock; };@@ -136,6 +138,12 @@ int iio_dummy_evgen_release_irq(int irq) }EXPORT_SYMBOL_GPL (iio_dummy_evgen_release_irq); +struct iio_dummy_regs *iio_dummy_evgen_get_regs (int irq) +{ +return &iio_evgen->regs[irq - iio_evgen->base]; +} +EXPORT_SYMBOL_GPL (iio_dummy_evgen_get_regs); +static void iio_dummy_evgen_free (void ) {irq_free_descs (iio_evgen->base,IIO_EVENTGEN_NO );@@ -153,6 +161,14 @@ static ssize_t iio_evgen_poke(struct device *dev, size_t len) {struct iio_dev_attr *this_attr =to_iio_dev_attr (attr); +unsigned long event, ret; + + ret =kstrtoul (buf,10 , &event); +if (ret) +return ret; + + iio_evgen->regs[this_attr->address].reg_id = this_attr->address; + iio_evgen->regs[this_attr->address].reg_data = event;if (iio_evgen->enabled[this_attr->address])handle_nested_irq (iio_evgen->base + this_attr->address);drivers/staging/iio/iio_dummy_evgen.h +6
-0@@ -1,2 +1,8 @@ +struct iio_dummy_regs { +u32 reg_id; +u32 reg_data; +}; + +struct iio_dummy_regs *iio_dummy_evgen_get_regs (int irq);int iio_dummy_evgen_get_irq (void );int iio_dummy_evgen_release_irq (int irq);drivers/staging/iio/iio_simple_dummy.h +2
-0@@ -11,6 +11,7 @@#include <linux/kernel.h> struct iio_dummy_accel_calibscale ; +struct iio_dummy_regs ;/** * struct iio_dummy_state - device instance specific state. @@ -33,6 +34,7 @@ struct iio_dummy_state {int accel_calibbias;const struct iio_dummy_accel_calibscale *accel_calibscale;struct mutex lock; +struct iio_dummy_regs *regs;#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS int event_irq;int event_val;drivers/staging/iio/iio_simple_dummy_events.c +18
-5@@ -148,12 +148,23 @@ int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,static irqreturn_t iio_simple_dummy_event_handler (int irq,void *private) {struct iio_dev *indio_dev = private; +struct iio_dummy_state *st =iio_priv (indio_dev); + +dev_dbg (&indio_dev->dev,"id %x event %x\n" , + st->regs->reg_id, st->regs->reg_data); + +switch (st->regs->reg_data) { +case 0 : +iio_push_event (indio_dev, +IIO_EVENT_CODE (IIO_VOLTAGE ,0 ,0 , +IIO_EV_DIR_RISING , +IIO_EV_TYPE_THRESH ,0 ,0 ,0 ), +iio_get_time_ns ()); +break ; +default : +break ; + } -iio_push_event (indio_dev, -IIO_EVENT_CODE (IIO_VOLTAGE ,0 ,0 , -IIO_EV_DIR_RISING , -IIO_EV_TYPE_THRESH ,0 ,0 ,0 ), -iio_get_time_ns ());return IRQ_HANDLED ; }@@ -179,6 +190,8 @@ int iio_simple_dummy_events_register(struct iio_dev *indio_dev) ret = st->event_irq; goto error_ret; } + st->regs =iio_dummy_evgen_get_regs (st->event_irq); + ret = request_threaded_irq(st->event_irq, NULL, &iio_simple_dummy_event_handler,
Re: [RFC PATCH v2 1/7] iio: dummy: Add virtual registers for dummy device
Jonathan Cameron schrieb am 25.10.2014 20:55:
Quoted 13 lines · Daniel Baluta
Quoted 12 lines
We need a way to store events generated by
iio_dummy_evgenmodule, in order to correctly process IRQs iniio_simple_dummy_events.For the moment, we add two registers:
*
id_reg- ID register, stores the source of the event
*id_data- DATA register, stores the type of the evente.g echo 4 >
/sys/bus/iio/devices/iio_evgen/poke2
id_reg0x02,id_data0x04
Quoted 8 lines
Quoted 6 lines
This means, event of type 4 was generated by fake device 2.
We currently use a hardcoded mapping of virtual events to IIO events.
Signed-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>Applied to the togreg branch of iio.git.
Initially pushed out as testing for the autobuilders to play with it.
I think Daniel wanted to work on a V3 for (at least) this one, fixing variable type of ret from long to int in iio_evgen_poke(). Had spotted it in V1, when V2 was already sent out - sorry for that. See [1].
[1] http://marc.info/?l=linux-iio&m=141375116229102&w=2
Quoted 136 lines
Quoted 123 lines
--- drivers/staging/iio/iio_dummy_evgen.c | 16 ++++++++++++++++ drivers/staging/iio/iio_dummy_evgen.h | 6 ++++++ drivers/staging/iio/iio_simple_dummy.h | 2 ++ drivers/staging/iio/iio_simple_dummy_events.c | 23 ++++++++++++++++++----- 4 files changed, 42 insertions(+), 5 deletions(-)drivers/staging/iio/iio_dummy_evgen.c +16
-0@@ -33,6 +33,7 @@* @base: base of irq range * @enabled: mask of which irqs are enabled * @inuse: mask of which irqs are connected +* @regs: irq regs we are faking * @lock: protect the evgen state */ struct iio_dummy_eventgen {@@ -40,6 +41,7 @@ struct iio_dummy_eventgen {int base;bool enabled[IIO_EVENTGEN_NO ];bool inuse[IIO_EVENTGEN_NO ]; +struct iio_dummy_regs regs[IIO_EVENTGEN_NO ];struct mutex lock; };@@ -136,6 +138,12 @@ int iio_dummy_evgen_release_irq(int irq) }EXPORT_SYMBOL_GPL (iio_dummy_evgen_release_irq); +struct iio_dummy_regs *iio_dummy_evgen_get_regs (int irq) +{ +return &iio_evgen->regs[irq - iio_evgen->base]; +} +EXPORT_SYMBOL_GPL (iio_dummy_evgen_get_regs); +static void iio_dummy_evgen_free (void ) {irq_free_descs (iio_evgen->base,IIO_EVENTGEN_NO );@@ -153,6 +161,14 @@ static ssize_t iio_evgen_poke(struct device *dev, size_t len) {struct iio_dev_attr *this_attr =to_iio_dev_attr (attr); +unsigned long event, ret; + + ret =kstrtoul (buf,10 , &event); +if (ret) +return ret; + + iio_evgen->regs[this_attr->address].reg_id = this_attr->address; + iio_evgen->regs[this_attr->address].reg_data = event;if (iio_evgen->enabled[this_attr->address])handle_nested_irq (iio_evgen->base + this_attr->address);drivers/staging/iio/iio_dummy_evgen.h +6
-0@@ -1,2 +1,8 @@ +struct iio_dummy_regs { +u32 reg_id; +u32 reg_data; +}; + +struct iio_dummy_regs *iio_dummy_evgen_get_regs (int irq);int iio_dummy_evgen_get_irq (void );int iio_dummy_evgen_release_irq (int irq);drivers/staging/iio/iio_simple_dummy.h +2
-0@@ -11,6 +11,7 @@#include <linux/kernel.h> struct iio_dummy_accel_calibscale ; +struct iio_dummy_regs ;/** * struct iio_dummy_state - device instance specific state. @@ -33,6 +34,7 @@ struct iio_dummy_state {int accel_calibbias;const struct iio_dummy_accel_calibscale *accel_calibscale;struct mutex lock; +struct iio_dummy_regs *regs;#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS int event_irq;int event_val;drivers/staging/iio/iio_simple_dummy_events.c +16
-5@@ -148,12 +148,23 @@ int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,static irqreturn_t iio_simple_dummy_event_handler (int irq,void *private) {struct iio_dev *indio_dev = private; +struct iio_dummy_state *st =iio_priv (indio_dev); + +dev_dbg (&indio_dev->dev,"id %x event %x\n" , + st->regs->reg_id, st->regs->reg_data); + +switch (st->regs->reg_data) { +case 0 : +iio_push_event (indio_dev, +IIO_EVENT_CODE (IIO_VOLTAGE ,0 ,0 , +IIO_EV_DIR_RISING , +IIO_EV_TYPE_THRESH ,0 ,0 ,0 ), +iio_get_time_ns ()); +break ; +default : +break ; + } -iio_push_event (indio_dev, -IIO_EVENT_CODE (IIO_VOLTAGE ,0 ,0 , -IIO_EV_DIR_RISING , -IIO_EV_TYPE_THRESH ,0 ,0 ,0 ), -iio_get_time_ns ());return IRQ_HANDLED ; }drivers/staging/iio/iio_simple_dummy_events.c int iio_simple_dummy_events_register(struct iio_dev *indio_dev) · line 197
Quoted 8 lines
drivers/staging/iio/iio_simple_dummy_events.c +2
-0@@ -179,6 +190,8 @@ int iio_simple_dummy_events_register(struct iio_dev *indio_dev) ret = st->event_irq; goto error_ret; } + st->regs =iio_dummy_evgen_get_regs (st->event_irq); + ret = request_threaded_irq(st->event_irq, NULL, &iio_simple_dummy_event_handler,--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerRe: [RFC PATCH v2 1/7] iio: dummy: Add virtual registers for dummy device
Quoted 18 lines · Hartmut Knaack
Jonathan Cameron schrieb am 25.10.2014 20:55:
Quoted 17 lines · Daniel Baluta
Quoted 16 lines
We need a way to store events generated by
iio_dummy_evgenmodule, in order to correctly process IRQs iniio_simple_dummy_events.For the moment, we add two registers:
*
id_reg- ID register, stores the source of the event
*id_data- DATA register, stores the type of the evente.g echo 4 >
/sys/bus/iio/devices/iio_evgen/poke2
id_reg0x02,id_data0x04This means, event of type 4 was generated by fake device 2.
We currently use a hardcoded mapping of virtual events to IIO events.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>Applied to the togreg branch of iio.git.
Initially pushed out as testing for the autobuilders to play with it.I think Daniel wanted to work on a V3 for (at least) this one, fixing variable type of ret from long to int in
iio_evgen_poke(). Had spotted it in V1, when V2 was already sent out - sorry for that. See [1].
Backed out. Thanks for letting me know.
Quoted 138 lines
Quoted 137 lines
Quoted 124 lines
--- drivers/staging/iio/iio_dummy_evgen.c | 16 ++++++++++++++++ drivers/staging/iio/iio_dummy_evgen.h | 6 ++++++ drivers/staging/iio/iio_simple_dummy.h | 2 ++ drivers/staging/iio/iio_simple_dummy_events.c | 23 ++++++++++++++++++----- 4 files changed, 42 insertions(+), 5 deletions(-)drivers/staging/iio/iio_dummy_evgen.c +16
-0@@ -33,6 +33,7 @@* @base: base of irq range * @enabled: mask of which irqs are enabled * @inuse: mask of which irqs are connected +* @regs: irq regs we are faking * @lock: protect the evgen state */ struct iio_dummy_eventgen {@@ -40,6 +41,7 @@ struct iio_dummy_eventgen {int base;bool enabled[IIO_EVENTGEN_NO ];bool inuse[IIO_EVENTGEN_NO ]; +struct iio_dummy_regs regs[IIO_EVENTGEN_NO ];struct mutex lock; };@@ -136,6 +138,12 @@ int iio_dummy_evgen_release_irq(int irq) }EXPORT_SYMBOL_GPL (iio_dummy_evgen_release_irq); +struct iio_dummy_regs *iio_dummy_evgen_get_regs (int irq) +{ +return &iio_evgen->regs[irq - iio_evgen->base]; +} +EXPORT_SYMBOL_GPL (iio_dummy_evgen_get_regs); +static void iio_dummy_evgen_free (void ) {irq_free_descs (iio_evgen->base,IIO_EVENTGEN_NO );@@ -153,6 +161,14 @@ static ssize_t iio_evgen_poke(struct device *dev, size_t len) {struct iio_dev_attr *this_attr =to_iio_dev_attr (attr); +unsigned long event, ret; + + ret =kstrtoul (buf,10 , &event); +if (ret) +return ret; + + iio_evgen->regs[this_attr->address].reg_id = this_attr->address; + iio_evgen->regs[this_attr->address].reg_data = event;if (iio_evgen->enabled[this_attr->address])handle_nested_irq (iio_evgen->base + this_attr->address);drivers/staging/iio/iio_dummy_evgen.h +6
-0@@ -1,2 +1,8 @@ +struct iio_dummy_regs { +u32 reg_id; +u32 reg_data; +}; + +struct iio_dummy_regs *iio_dummy_evgen_get_regs (int irq);int iio_dummy_evgen_get_irq (void );int iio_dummy_evgen_release_irq (int irq);drivers/staging/iio/iio_simple_dummy.h +2
-0@@ -11,6 +11,7 @@#include <linux/kernel.h> struct iio_dummy_accel_calibscale ; +struct iio_dummy_regs ;/** * struct iio_dummy_state - device instance specific state. @@ -33,6 +34,7 @@ struct iio_dummy_state {int accel_calibbias;const struct iio_dummy_accel_calibscale *accel_calibscale;struct mutex lock; +struct iio_dummy_regs *regs;#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS int event_irq;int event_val;drivers/staging/iio/iio_simple_dummy_events.c +16
-5@@ -148,12 +148,23 @@ int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,static irqreturn_t iio_simple_dummy_event_handler (int irq,void *private) {struct iio_dev *indio_dev = private; +struct iio_dummy_state *st =iio_priv (indio_dev); + +dev_dbg (&indio_dev->dev,"id %x event %x\n" , + st->regs->reg_id, st->regs->reg_data); + +switch (st->regs->reg_data) { +case 0 : +iio_push_event (indio_dev, +IIO_EVENT_CODE (IIO_VOLTAGE ,0 ,0 , +IIO_EV_DIR_RISING , +IIO_EV_TYPE_THRESH ,0 ,0 ,0 ), +iio_get_time_ns ()); +break ; +default : +break ; + } -iio_push_event (indio_dev, -IIO_EVENT_CODE (IIO_VOLTAGE ,0 ,0 , -IIO_EV_DIR_RISING , -IIO_EV_TYPE_THRESH ,0 ,0 ,0 ), -iio_get_time_ns ());return IRQ_HANDLED ; }drivers/staging/iio/iio_simple_dummy_events.c int iio_simple_dummy_events_register(struct iio_dev *indio_dev) · line 197
Quoted 8 lines
drivers/staging/iio/iio_simple_dummy_events.c +2
-0@@ -179,6 +190,8 @@ int iio_simple_dummy_events_register(struct iio_dev *indio_dev) ret = st->event_irq; goto error_ret; } + st->regs =iio_dummy_evgen_get_regs (st->event_irq); + ret = request_threaded_irq(st->event_irq, NULL, &iio_simple_dummy_event_handler,--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2 1/7] iio: dummy: Add virtual registers for dummy device
In reply to Hartmut KnaackQuoted 16 lines · Hartmut Knaack
Jonathan Cameron schrieb am 25.10.2014 20:55:
Quoted 15 lines · Daniel Baluta
Quoted 14 lines
We need a way to store events generated by
iio_dummy_evgenmodule, in order to correctly process IRQs iniio_simple_dummy_events.For the moment, we add two registers:
*
id_reg- ID register, stores the source of the event
*id_data- DATA register, stores the type of the evente.g echo 4 >
/sys/bus/iio/devices/iio_evgen/poke2
id_reg0x02,id_data0x04This means, event of type 4 was generated by fake device 2.
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
We currently use a hardcoded mapping of virtual events to IIO events.
Signed-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>Applied to the togreg branch of iio.git.
Initially pushed out as testing for the autobuilders to play with it.I think Daniel wanted to work on a V3 for (at least) this one, fixing variable type of ret from long to int in
iio_evgen_poke(). Had spotted it in V1, when V2 was already sent out - sorry for that. See [1].
Correct, I was just waiting on feedback for other patches.
I will send v3 as soon as possible.
thanks,
Daniel.
RFC PATCH v2 2/7 iio: core: Introduce IIO_ACTIVITY channel and TRANSITION event
In reply to Daniel BalutaThis channel will be used for exposing information about activity composite sensors. Activities supported so far:
* running
* jogging
* walking
* still
TRANSITION event is used to signal a change in the activity state.
We associate a confidence interval for each activity expressed as a percentage from 0 to 100.
* 0, means the sensor IS NOT reporting that activity.
* 100, means the sensor IS reporting that activity.
Users of this interface have two possibile means to gather information about the ongoing activities.
1. Event based, via event file descriptor
* sensor may report an event when ENTERING an activity or LEAVING an activity based on a threshold value.
* drivers will wake up applications waiting data on the event fd
2. Polling, by reading the sysfs associated attribute files:
* /sys/bus/iio/devices/iio:device0/in_activity_running_input
expressed as percentage confidence value from 0 to 100.
This will offer an interface for Android significant motion composite sensor defined here:
http://source.android.com/devices/sensors/composite_sensors.html
Activities listed above are supported by Freescale's MMA9553 sensor:
http://freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf
--- Documentation/ABI/testing/sysfs-bus-iio | 44 +++++++++++++++++++++++++++++++++ drivers/iio/industrialio-core.c | 5 ++++ drivers/iio/industrialio-event.c | 1 + include/linux/iio/types.h | 8 +++++- 4 files changed, 57 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-iio +44 -0
@@ -776,6 +776,40 @@ Description: met before an event is generated. If direction is not specified then this period applies to both directions. +What: /sys/.../events/in_activity_still_transition_rising_en +What: /sys/.../events/in_activity_still_transition_falling_en +What: /sys/.../events/in_activity_walking_transition_rising_en +What: /sys/.../events/in_activity_walking_transition_falling_en +What: /sys/.../events/in_activity_jogging_transition_rising_en +What: /sys/.../events/in_activity_jogging_transition_falling_en +What: /sys/.../events/in_activity_running_transition_rising_en +What: /sys/.../events/in_activity_running_transition_falling_en +KernelVersion: 3.19 +Contact: [email protected] +Description: + Enables or disables activitity events. Depending on direction + an event is generated when sensor ENTERS or LEAVES a given state. + +What: /sys/.../events/in_activity_still_transition_rising_value +What: /sys/.../events/in_activity_still_transition_falling_value +What: /sys/.../events/in_activity_walking_transition_rising_value +What: /sys/.../events/in_activity_walking_transition_falling_value +What: /sys/.../events/in_activity_jogging_transition_rising_value +What: /sys/.../events/in_activity_jogging_transition_falling_value +What: /sys/.../events/in_activity_running_transition_rising_value +What: /sys/.../events/in_activity_running_transition_falling_value +KernelVersion: 3.19 +Contact: [email protected] +Description: + Confidence value (in units as percentage) to be used + for deciding when an event should be generated. E.g for + running: If the confidence value reported by the sensor + is greater then in_activity_running_transition_rising_value + then the sensor ENTERS running state. Conversely, if the + confidence value reported by the sensor is lower than + in_activity_running_transition_rising_value then the sensor + is LEAVING running state. + What: /sys/.../iio:deviceX/events/in_accel_mag_en What: /sys/.../iio:deviceX/events/in_accel_mag_rising_en What: /sys/.../iio:deviceX/events/in_accel_mag_falling_en
@@ -942,6 +976,16 @@ Description: and the relevant _type attributes to establish the data storage format. +What: /sys/.../iio:deviceX/in_activity_still_input +What: /sys/.../iio:deviceX/in_activity_walking_input +What: /sys/.../iio:deviceX/in_activity_jogging_input +What: /sys/.../iio:deviceX/in_activity_running_input +KernelVersion: 3.19 +Contact: [email protected] +Description: + This attribute is used to read the confidence for an activity + expressed in units as percentage. + What: /sys/.../iio:deviceX/in_anglvel_z_quadrature_correction_raw KernelVersion: 2.6.38 Contact: [email protected]
drivers/iio/industrialio-core.c +5 -0
@@ -70,6 +70,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_CCT] = "cct", [IIO_PRESSURE] = "pressure", [IIO_HUMIDITYRELATIVE] = "humidityrelative", + [IIO_ACTIVITY] = "activity", };static const char *const iio_modifier_names[] = {
@@ -91,6 +92,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_NORTH_TRUE] = "from_north_true", [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp", [IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp", + [IIO_MOD_RUNNING] = "running", + [IIO_MOD_JOGGING] = "jogging", + [IIO_MOD_WALKING] = "walking", + [IIO_MOD_STILL] = "still", };/* relies on pairs of these shared then separate */
drivers/iio/industrialio-event.c +1 -0
@@ -197,6 +197,7 @@ static const char * const iio_ev_type_text[] = { [IIO_EV_TYPE_ROC] = "roc", [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive", [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive", + [IIO_EV_TYPE_TRANSITION] = "transition", };static const char *const iio_ev_dir_text[] = {
include/linux/iio/types.h +7 -1
@@ -30,6 +30,7 @@ enum iio_chan_type {IIO_CCT ,IIO_PRESSURE ,IIO_HUMIDITYRELATIVE , + IIO_ACTIVITY, }; enum iio_modifier {
@@ -59,7 +60,11 @@ enum iio_modifier {IIO_MOD_NORTH_MAGN ,IIO_MOD_NORTH_TRUE ,IIO_MOD_NORTH_MAGN_TILT_COMP , -IIO_MOD_NORTH_TRUE_TILT_COMP +IIO_MOD_NORTH_TRUE_TILT_COMP , +IIO_MOD_RUNNING , +IIO_MOD_JOGGING , +IIO_MOD_WALKING , + IIO_MOD_STILL, }; enum iio_event_type {
@@ -68,6 +73,7 @@ enum iio_event_type {IIO_EV_TYPE_ROC ,IIO_EV_TYPE_THRESH_ADAPTIVE ,IIO_EV_TYPE_MAG_ADAPTIVE , + IIO_EV_TYPE_TRANSITION, }; enum iio_event_info {
Signature · 1 line
1.9.1
Jonathan Cameron
maintainerRe: [RFC PATCH v2 2/7] iio: core: Introduce IIO_ACTIVITY channel and TRANSITION event
Quoted 31 lines · Daniel Baluta
This channel will be used for exposing information about activity composite sensors. Activities supported so far:
* running
* jogging
* walking
* stillTRANSITION event is used to signal a change in the activity state.
We associate a confidence interval for each activity expressed as a percentage from 0 to 100.
* 0, means the sensor IS NOT reporting that activity.
* 100, means the sensor IS reporting that activity.Users of this interface have two possibile means to gather information about the ongoing activities.
1. Event based, via event file descriptor
* sensor may report an event when ENTERING an activity or LEAVING an activity based on a threshold value.
* drivers will wake up applications waiting data on the event fd2. Polling, by reading the sysfs associated attribute files:
* /sys/bus/iio/devices/iio:device0/in_activity_running_input
expressed as percentage confidence value from 0 to 100.This will offer an interface for Android significant motion composite sensor defined here:
http://source.android.com/devices/sensors/composite_sensors.html
Quoted 5 lines
Activities listed above are supported by Freescale's MMA9553 sensor:
http://freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdfSigned-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>
I don't see why we need the transition event. A transition is simply a threshold rising (or falling) event much like any other - just on a confidence interval.
So it would be possible to be interested in the confidence that are not sitting rising above 20% on the basis that some other sensor needs enabling.
See below for resulting suggestions.
Other than that little point this looks good to me.
Quoted 12 lines
--- Documentation/ABI/testing/sysfs-bus-iio | 44 +++++++++++++++++++++++++++++++++ drivers/iio/industrialio-core.c | 5 ++++ drivers/iio/industrialio-event.c | 1 + include/linux/iio/types.h | 8 +++++- 4 files changed, 57 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-bus-iio +0
-0
Documentation/ABI/testing/sysfs-bus-iio Description: · line 779
Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-iio +1
-0@@ -776,6 +776,40 @@ Description: met before an event is generated. If direction is not specified then this period applies to both directions. +What: /sys/.../events/in_activity_still_transition_rising_en
What: /sys/.../events/in_activity_threshold_rising_en
Documentation/ABI/testing/sysfs-bus-iio Description: · line 780
Quoted 1 line
Documentation/ABI/testing/sysfs-bus-iio +1
-0+What: /sys/.../events/in_activity_still_transition_falling_en
What: /sys/.../events/in_activity_threshold_falling_en
etc
Documentation/ABI/testing/sysfs-bus-iio Description: · line 793
Quoted 13 lines
Documentation/ABI/testing/sysfs-bus-iio +13
-0+What: /sys/.../events/in_activity_walking_transition_rising_en +What: /sys/.../events/in_activity_walking_transition_falling_en +What: /sys/.../events/in_activity_jogging_transition_rising_en +What: /sys/.../events/in_activity_jogging_transition_falling_en +What: /sys/.../events/in_activity_running_transition_rising_en +What: /sys/.../events/in_activity_running_transition_falling_en +KernelVersion: 3.19 +Contact: [email protected] +Description: + Enables or disables activitity events. Depending on direction + an event is generated when sensor ENTERS or LEAVES a given state. + +What: /sys/.../events/in_activity_still_transition_rising_value
What: /sys/.../events/in_activity_still_threshold_rising_value etc
Quoted 108 lines
Documentation/ABI/testing/sysfs-bus-iio +29
-0+What: /sys/.../events/in_activity_still_transition_falling_value +What: /sys/.../events/in_activity_walking_transition_rising_value +What: /sys/.../events/in_activity_walking_transition_falling_value +What: /sys/.../events/in_activity_jogging_transition_rising_value +What: /sys/.../events/in_activity_jogging_transition_falling_value +What: /sys/.../events/in_activity_running_transition_rising_value +What: /sys/.../events/in_activity_running_transition_falling_value +KernelVersion: 3.19 +Contact: [email protected] +Description: + Confidence value (in units as percentage) to be used + for deciding when an event should be generated. E.g for + running: If the confidence value reported by the sensor + is greater then in_activity_running_transition_rising_value + then the sensor ENTERS running state. Conversely, if the + confidence value reported by the sensor is lower than + in_activity_running_transition_rising_value then the sensor + is LEAVING running state. + What: /sys/.../iio:deviceX/events/in_accel_mag_en What: /sys/.../iio:deviceX/events/in_accel_mag_rising_en What: /sys/.../iio:deviceX/events/in_accel_mag_falling_en@@ -942,6 +976,16 @@ Description: and the relevant _type attributes to establish the data storage format. +What: /sys/.../iio:deviceX/in_activity_still_input +What: /sys/.../iio:deviceX/in_activity_walking_input +What: /sys/.../iio:deviceX/in_activity_jogging_input +What: /sys/.../iio:deviceX/in_activity_running_input +KernelVersion: 3.19 +Contact: [email protected] +Description: + This attribute is used to read the confidence for an activity + expressed in units as percentage. + What: /sys/.../iio:deviceX/in_anglvel_z_quadrature_correction_raw KernelVersion: 2.6.38 Contact: [email protected]drivers/iio/industrialio-core.c +5
-0@@ -70,6 +70,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_CCT] = "cct", [IIO_PRESSURE] = "pressure", [IIO_HUMIDITYRELATIVE] = "humidityrelative", + [IIO_ACTIVITY] = "activity", };static const char *const iio_modifier_names[] = {@@ -91,6 +92,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_NORTH_TRUE] = "from_north_true", [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp", [IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp", + [IIO_MOD_RUNNING] = "running", + [IIO_MOD_JOGGING] = "jogging", + [IIO_MOD_WALKING] = "walking", + [IIO_MOD_STILL] = "still", };/* relies on pairs of these shared then separate */ drivers/iio/industrialio-event.c +1
-0@@ -197,6 +197,7 @@ static const char * const iio_ev_type_text[] = { [IIO_EV_TYPE_ROC] = "roc", [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive", [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive", + [IIO_EV_TYPE_TRANSITION] = "transition", };static const char *const iio_ev_dir_text[] = {include/linux/iio/types.h +7
-1@@ -30,6 +30,7 @@ enum iio_chan_type {IIO_CCT ,IIO_PRESSURE ,IIO_HUMIDITYRELATIVE , + IIO_ACTIVITY, }; enum iio_modifier {@@ -59,7 +60,11 @@ enum iio_modifier {IIO_MOD_NORTH_MAGN ,IIO_MOD_NORTH_TRUE ,IIO_MOD_NORTH_MAGN_TILT_COMP , -IIO_MOD_NORTH_TRUE_TILT_COMP +IIO_MOD_NORTH_TRUE_TILT_COMP , +IIO_MOD_RUNNING , +IIO_MOD_JOGGING , +IIO_MOD_WALKING , + IIO_MOD_STILL, }; enum iio_event_type {@@ -68,6 +73,7 @@ enum iio_event_type {IIO_EV_TYPE_ROC ,IIO_EV_TYPE_THRESH_ADAPTIVE ,IIO_EV_TYPE_MAG_ADAPTIVE , + IIO_EV_TYPE_TRANSITION, }; enum iio_event_info {
Re: [RFC PATCH v2 2/7] iio: core: Introduce IIO_ACTIVITY channel and TRANSITION event
Quoted 38 lines · Jonathan Cameron
Quoted 31 lines · Daniel Baluta
This channel will be used for exposing information about activity composite sensors. Activities supported so far:
* running
* jogging
* walking
* stillTRANSITION event is used to signal a change in the activity state.
We associate a confidence interval for each activity expressed as a percentage from 0 to 100.
* 0, means the sensor IS NOT reporting that activity.
* 100, means the sensor IS reporting that activity.Users of this interface have two possibile means to gather information about the ongoing activities.
1. Event based, via event file descriptor
* sensor may report an event when ENTERING an activity or LEAVING an activity based on a threshold value.
* drivers will wake up applications waiting data on the event fd2. Polling, by reading the sysfs associated attribute files:
* /sys/bus/iio/devices/iio:device0/in_activity_running_input
expressed as percentage confidence value from 0 to 100.This will offer an interface for Android significant motion composite sensor defined here:
http://source.android.com/devices/sensors/composite_sensors.htmlQuoted 5 lines
Activities listed above are supported by Freescale's MMA9553 sensor:
http://freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdfSigned-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>
Quoted 7 lines
I don't see why we need the transition event. A transition is simply a threshold rising (or falling) event much like any other - just on a confidence interval.
So it would be possible to be interested in the confidence that are not sitting rising above 20% on the basis that some other sensor needs enabling.
Using a THRESHOLD event type also work for us.
Quoted 18 lines
See below for resulting suggestions.
Other than that little point this looks good to me.
Quoted 15 lines
--- Documentation/ABI/testing/sysfs-bus-iio | 44 +++++++++++++++++++++++++++++++++ drivers/iio/industrialio-core.c | 5 ++++ drivers/iio/industrialio-event.c | 1 + include/linux/iio/types.h | 8 +++++- 4 files changed, 57 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-bus-iio +0
-0@@ -776,6 +776,40 @@ Description: met before an event is generated. If direction is not specified then this period applies to both directions.
Quoted 2 lines
Documentation/ABI/testing/sysfs-bus-iio Description: · line 779
Quoted 1 line
Documentation/ABI/testing/sysfs-bus-iio +1
-0+What: /sys/.../events/in_activity_still_transition_rising_enWhat:
/sys/.../events/in_activity_threshold_rising_en
Shouldn't this be:
What: /sys/.../events/in_activity_still_threshold_rising_en ?
Perhaps, one needs to enable events per activity type.
Quoted 2 lines
Documentation/ABI/testing/sysfs-bus-iio Description: · line 780
Quoted 1 line
Documentation/ABI/testing/sysfs-bus-iio +1
-0+What: /sys/.../events/in_activity_still_transition_falling_enWhat:
/sys/.../events/in_activity_threshold_falling_en
Also, here:
What: /sys/.../events/in_activity_still_threshold_falling_en
Quoted 15 lines
etc
Documentation/ABI/testing/sysfs-bus-iio Description: · line 793
Quoted 13 lines
Documentation/ABI/testing/sysfs-bus-iio +13
-0+What: /sys/.../events/in_activity_walking_transition_rising_en +What: /sys/.../events/in_activity_walking_transition_falling_en +What: /sys/.../events/in_activity_jogging_transition_rising_en +What: /sys/.../events/in_activity_jogging_transition_falling_en +What: /sys/.../events/in_activity_running_transition_rising_en +What: /sys/.../events/in_activity_running_transition_falling_en +KernelVersion: 3.19 +Contact: [email protected] +Description: + Enables or disables activitity events. Depending on direction + an event is generated when sensor ENTERS or LEAVES a given state. + +What: /sys/.../events/in_activity_still_transition_rising_valueWhat:
/sys/.../events/in_activity_still_threshold_rising_valueetc
This looks good to me :)
Quoted 112 lines
Quoted 101 lines
Documentation/ABI/testing/sysfs-bus-iio +29
-0+What: /sys/.../events/in_activity_still_transition_falling_value +What: /sys/.../events/in_activity_walking_transition_rising_value +What: /sys/.../events/in_activity_walking_transition_falling_value +What: /sys/.../events/in_activity_jogging_transition_rising_value +What: /sys/.../events/in_activity_jogging_transition_falling_value +What: /sys/.../events/in_activity_running_transition_rising_value +What: /sys/.../events/in_activity_running_transition_falling_value +KernelVersion: 3.19 +Contact: [email protected] +Description: + Confidence value (in units as percentage) to be used + for deciding when an event should be generated. E.g for + running: If the confidence value reported by the sensor + is greater then in_activity_running_transition_rising_value + then the sensor ENTERS running state. Conversely, if the + confidence value reported by the sensor is lower than + in_activity_running_transition_rising_value then the sensor + is LEAVING running state. + What: /sys/.../iio:deviceX/events/in_accel_mag_en What: /sys/.../iio:deviceX/events/in_accel_mag_rising_en What: /sys/.../iio:deviceX/events/in_accel_mag_falling_en@@ -942,6 +976,16 @@ Description: and the relevant _type attributes to establish the data storage format. +What: /sys/.../iio:deviceX/in_activity_still_input +What: /sys/.../iio:deviceX/in_activity_walking_input +What: /sys/.../iio:deviceX/in_activity_jogging_input +What: /sys/.../iio:deviceX/in_activity_running_input +KernelVersion: 3.19 +Contact: [email protected] +Description: + This attribute is used to read the confidence for an activity + expressed in units as percentage. + What: /sys/.../iio:deviceX/in_anglvel_z_quadrature_correction_raw KernelVersion: 2.6.38 Contact: [email protected]drivers/iio/industrialio-core.c +5
-0@@ -70,6 +70,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_CCT] = "cct", [IIO_PRESSURE] = "pressure", [IIO_HUMIDITYRELATIVE] = "humidityrelative", + [IIO_ACTIVITY] = "activity", };static const char *const iio_modifier_names[] = {@@ -91,6 +92,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_NORTH_TRUE] = "from_north_true", [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp", [IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp", + [IIO_MOD_RUNNING] = "running", + [IIO_MOD_JOGGING] = "jogging", + [IIO_MOD_WALKING] = "walking", + [IIO_MOD_STILL] = "still", };/* relies on pairs of these shared then separate */ drivers/iio/industrialio-event.c +1
-0@@ -197,6 +197,7 @@ static const char * const iio_ev_type_text[] = { [IIO_EV_TYPE_ROC] = "roc", [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive", [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive", + [IIO_EV_TYPE_TRANSITION] = "transition", };static const char *const iio_ev_dir_text[] = {include/linux/iio/types.h +6
-1@@ -30,6 +30,7 @@ enum iio_chan_type {IIO_CCT ,IIO_PRESSURE ,IIO_HUMIDITYRELATIVE , + IIO_ACTIVITY, }; enum iio_modifier {@@ -59,7 +60,11 @@ enum iio_modifier {IIO_MOD_NORTH_MAGN ,IIO_MOD_NORTH_TRUE ,IIO_MOD_NORTH_MAGN_TILT_COMP , -IIO_MOD_NORTH_TRUE_TILT_COMP +IIO_MOD_NORTH_TRUE_TILT_COMP , +IIO_MOD_RUNNING , +IIO_MOD_JOGGING , +IIO_MOD_WALKING , + IIO_MOD_STILL, }; enum iio_event_type {include/linux/iio/types.h enum iio_event_type { · line 79
Quoted 7 lines
include/linux/iio/types.h +1
-0@@ -68,6 +73,7 @@ enum iio_event_type {IIO_EV_TYPE_ROC ,IIO_EV_TYPE_THRESH_ADAPTIVE ,IIO_EV_TYPE_MAG_ADAPTIVE , + IIO_EV_TYPE_TRANSITION, }; enum iio_event_info {--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerRe: [RFC PATCH v2 2/7] iio: core: Introduce IIO_ACTIVITY channel and TRANSITION event
Quoted 67 lines · Daniel Baluta
Quoted 38 lines · Jonathan Cameron
Quoted 31 lines · Daniel Baluta
This channel will be used for exposing information about activity composite sensors. Activities supported so far:
* running
* jogging
* walking
* stillTRANSITION event is used to signal a change in the activity state.
We associate a confidence interval for each activity expressed as a percentage from 0 to 100.
* 0, means the sensor IS NOT reporting that activity.
* 100, means the sensor IS reporting that activity.Users of this interface have two possibile means to gather information about the ongoing activities.
1. Event based, via event file descriptor
* sensor may report an event when ENTERING an activity or LEAVING an activity based on a threshold value.
* drivers will wake up applications waiting data on the event fd2. Polling, by reading the sysfs associated attribute files:
* /sys/bus/iio/devices/iio:device0/in_activity_running_input
expressed as percentage confidence value from 0 to 100.This will offer an interface for Android significant motion composite sensor defined here:
http://source.android.com/devices/sensors/composite_sensors.htmlQuoted 5 lines
Activities listed above are supported by Freescale's MMA9553 sensor:
http://freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdfSigned-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>Quoted 7 lines
I don't see why we need the transition event. A transition is simply a threshold rising (or falling) event much like any other - just on a confidence interval.
So it would be possible to be interested in the confidence that are not sitting rising above 20% on the basis that some other sensor needs enabling.
Using a THRESHOLD event type also work for us.
Quoted 18 lines
See below for resulting suggestions.
Other than that little point this looks good to me.
Quoted 15 lines
--- Documentation/ABI/testing/sysfs-bus-iio | 44 +++++++++++++++++++++++++++++++++ drivers/iio/industrialio-core.c | 5 ++++ drivers/iio/industrialio-event.c | 1 + include/linux/iio/types.h | 8 +++++- 4 files changed, 57 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-bus-iio +0
-0@@ -776,6 +776,40 @@ Description: met before an event is generated. If direction is not specified then this period applies to both directions.
Quoted 8 lines
Quoted 2 lines
Documentation/ABI/testing/sysfs-bus-iio Description: · line 779
Quoted 1 line
Documentation/ABI/testing/sysfs-bus-iio +1
-0+What: /sys/.../events/in_activity_still_transition_rising_enWhat:
/sys/.../events/in_activity_threshold_rising_enShouldn't this be:
What:
/sys/.../events/in_activity_still_threshold_rising_en?Perhaps, one needs to enable events per activity type.
Absolutely.
Quoted 137 lines
Quoted 3 lines
Documentation/ABI/testing/sysfs-bus-iio Description: · line 780
Quoted 2 lines
Documentation/ABI/testing/sysfs-bus-iio +1
-0+What: /sys/.../events/in_activity_still_transition_falling_enWhat:
/sys/.../events/in_activity_threshold_falling_enAlso, here:
What:
/sys/.../events/in_activity_still_threshold_falling_enQuoted 15 lines
etc
Documentation/ABI/testing/sysfs-bus-iio Description: · line 793
Quoted 13 lines
Documentation/ABI/testing/sysfs-bus-iio +13
-0+What: /sys/.../events/in_activity_walking_transition_rising_en +What: /sys/.../events/in_activity_walking_transition_falling_en +What: /sys/.../events/in_activity_jogging_transition_rising_en +What: /sys/.../events/in_activity_jogging_transition_falling_en +What: /sys/.../events/in_activity_running_transition_rising_en +What: /sys/.../events/in_activity_running_transition_falling_en +KernelVersion: 3.19 +Contact: [email protected] +Description: + Enables or disables activitity events. Depending on direction + an event is generated when sensor ENTERS or LEAVES a given state. + +What: /sys/.../events/in_activity_still_transition_rising_valueWhat:
/sys/.../events/in_activity_still_threshold_rising_valueetcThis looks good to me :)
Quoted 112 lines
Quoted 101 lines
Documentation/ABI/testing/sysfs-bus-iio +29
-0+What: /sys/.../events/in_activity_still_transition_falling_value +What: /sys/.../events/in_activity_walking_transition_rising_value +What: /sys/.../events/in_activity_walking_transition_falling_value +What: /sys/.../events/in_activity_jogging_transition_rising_value +What: /sys/.../events/in_activity_jogging_transition_falling_value +What: /sys/.../events/in_activity_running_transition_rising_value +What: /sys/.../events/in_activity_running_transition_falling_value +KernelVersion: 3.19 +Contact: [email protected] +Description: + Confidence value (in units as percentage) to be used + for deciding when an event should be generated. E.g for + running: If the confidence value reported by the sensor + is greater then in_activity_running_transition_rising_value + then the sensor ENTERS running state. Conversely, if the + confidence value reported by the sensor is lower than + in_activity_running_transition_rising_value then the sensor + is LEAVING running state. + What: /sys/.../iio:deviceX/events/in_accel_mag_en What: /sys/.../iio:deviceX/events/in_accel_mag_rising_en What: /sys/.../iio:deviceX/events/in_accel_mag_falling_en@@ -942,6 +976,16 @@ Description: and the relevant _type attributes to establish the data storage format. +What: /sys/.../iio:deviceX/in_activity_still_input +What: /sys/.../iio:deviceX/in_activity_walking_input +What: /sys/.../iio:deviceX/in_activity_jogging_input +What: /sys/.../iio:deviceX/in_activity_running_input +KernelVersion: 3.19 +Contact: [email protected] +Description: + This attribute is used to read the confidence for an activity + expressed in units as percentage. + What: /sys/.../iio:deviceX/in_anglvel_z_quadrature_correction_raw KernelVersion: 2.6.38 Contact: [email protected]drivers/iio/industrialio-core.c +5
-0@@ -70,6 +70,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_CCT] = "cct", [IIO_PRESSURE] = "pressure", [IIO_HUMIDITYRELATIVE] = "humidityrelative", + [IIO_ACTIVITY] = "activity", };static const char *const iio_modifier_names[] = {@@ -91,6 +92,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_NORTH_TRUE] = "from_north_true", [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp", [IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp", + [IIO_MOD_RUNNING] = "running", + [IIO_MOD_JOGGING] = "jogging", + [IIO_MOD_WALKING] = "walking", + [IIO_MOD_STILL] = "still", };/* relies on pairs of these shared then separate */ drivers/iio/industrialio-event.c +1
-0@@ -197,6 +197,7 @@ static const char * const iio_ev_type_text[] = { [IIO_EV_TYPE_ROC] = "roc", [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive", [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive", + [IIO_EV_TYPE_TRANSITION] = "transition", };static const char *const iio_ev_dir_text[] = {include/linux/iio/types.h +6
-1@@ -30,6 +30,7 @@ enum iio_chan_type {IIO_CCT ,IIO_PRESSURE ,IIO_HUMIDITYRELATIVE , + IIO_ACTIVITY, }; enum iio_modifier {@@ -59,7 +60,11 @@ enum iio_modifier {IIO_MOD_NORTH_MAGN ,IIO_MOD_NORTH_TRUE ,IIO_MOD_NORTH_MAGN_TILT_COMP , -IIO_MOD_NORTH_TRUE_TILT_COMP +IIO_MOD_NORTH_TRUE_TILT_COMP , +IIO_MOD_RUNNING , +IIO_MOD_JOGGING , +IIO_MOD_WALKING , + IIO_MOD_STILL, }; enum iio_event_type {include/linux/iio/types.h enum iio_event_type { · line 79
Quoted 7 lines
include/linux/iio/types.h +1
-0@@ -68,6 +73,7 @@ enum iio_event_type {IIO_EV_TYPE_ROC ,IIO_EV_TYPE_THRESH_ADAPTIVE ,IIO_EV_TYPE_MAG_ADAPTIVE , + IIO_EV_TYPE_TRANSITION, }; enum iio_event_info {--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH v2 3/7 iio: core: Introduce IIO_EV_DIR_NONE
In reply to Daniel BalutaFrom: Irina Tirdea <[email protected]>
For some events (e.g.: step detector) a direction does not make sense.
Add IIO_EV_DIR_NONE to be used with such events and generate sysfs event attributes that do not contain direction.
--- drivers/iio/industrialio-event.c | 12 +++++++++--- include/linux/iio/types.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/iio/industrialio-event.c +9 -3
@@ -328,9 +328,15 @@ static int iio_device_add_event(struct iio_dev *indio_dev,for_each_set_bit (i, mask,sizeof (*mask)*8 ) {if (i >=ARRAY_SIZE (iio_ev_info_text))return -EINVAL ; - postfix =kasprintf (GFP_KERNEL ,"%s_%s_%s" , - iio_ev_type_text[type], iio_ev_dir_text[dir], - iio_ev_info_text[i]); +if (dir !=IIO_EV_DIR_NONE ) + postfix =kasprintf (GFP_KERNEL ,"%s_%s_%s" , + iio_ev_type_text[type], + iio_ev_dir_text[dir], + iio_ev_info_text[i]); +else + postfix =kasprintf (GFP_KERNEL ,"%s_%s" , + iio_ev_type_text[type], + iio_ev_info_text[i]);if (postfix ==NULL )return -ENOMEM ;
include/linux/iio/types.h +1 -0
@@ -87,6 +87,7 @@ enum iio_event_direction {IIO_EV_DIR_EITHER ,IIO_EV_DIR_RISING ,IIO_EV_DIR_FALLING , + IIO_EV_DIR_NONE, };#define IIO_VAL_INT 1
Signature · 1 line
1.9.1
Jonathan Cameron
maintainerRe: [RFC PATCH v2 3/7] iio: core: Introduce IIO_EV_DIR_NONE
Quoted 9 lines · Daniel Baluta
From: Irina Tirdea <[email protected]>
For some events (e.g.: step detector) a direction does not make sense.
Add
IIO_EV_DIR_NONEto be used with such events and generate sysfs event attributes that do not contain direction.Signed-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>
Happy with this one.
J
Quoted 41 lines
--- drivers/iio/industrialio-event.c | 12 +++++++++--- include/linux/iio/types.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-)drivers/iio/industrialio-event.c +9
-3@@ -328,9 +328,15 @@ static int iio_device_add_event(struct iio_dev *indio_dev,for_each_set_bit (i, mask,sizeof (*mask)*8 ) {if (i >=ARRAY_SIZE (iio_ev_info_text))return -EINVAL ; - postfix =kasprintf (GFP_KERNEL ,"%s_%s_%s" , - iio_ev_type_text[type], iio_ev_dir_text[dir], - iio_ev_info_text[i]); +if (dir !=IIO_EV_DIR_NONE ) + postfix =kasprintf (GFP_KERNEL ,"%s_%s_%s" , + iio_ev_type_text[type], + iio_ev_dir_text[dir], + iio_ev_info_text[i]); +else + postfix =kasprintf (GFP_KERNEL ,"%s_%s" , + iio_ev_type_text[type], + iio_ev_info_text[i]);if (postfix ==NULL )return -ENOMEM ;include/linux/iio/types.h +1
-0@@ -87,6 +87,7 @@ enum iio_event_direction {IIO_EV_DIR_EITHER ,IIO_EV_DIR_RISING ,IIO_EV_DIR_FALLING , + IIO_EV_DIR_NONE, };#define IIO_VAL_INT 1
RFC PATCH v2 4/7 iio: core: Introduce STEPS channel type, ENABLE mask and INSTANCE event
In reply to Daniel BalutaFrom: Irina Tirdea <[email protected]>
These changes are needed to support the functionality of a pedometer. A pedometer has two basic functionalities: step counter and step detector.
The step counter needs to be enabled and then it will count the steps in its hardware register. Whenever the application needs to check the step count, it will read the step counter register. To support the step counter a new channel type STEPS is added. Since the pedometer needs to be enabled first so that the hardware can count and store the steps, we need a specific ENABLE channel info mask.
The step detector will generate an interrupt each time a step is detected. To support this functionality we add a new event type INSTANCE.
For more information on the Android requirements for step counter and step detector see:
http://source.android.com/devices/sensors/composite_sensors.html#counter
and http://source.android.com/devices/sensors/composite_sensors.html#detector.
A device that has the pedometer functionality this interface needs to support is Freescale's MMA9553L:
http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf
--- Documentation/ABI/testing/sysfs-bus-iio | 22 ++++++++++++++++++++++ drivers/iio/industrialio-core.c | 2 ++ drivers/iio/industrialio-event.c | 1 + include/linux/iio/iio.h | 1 + include/linux/iio/types.h | 2 ++ 5 files changed, 28 insertions(+)
Documentation/ABI/testing/sysfs-bus-iio +22 -0
@@ -842,6 +842,13 @@ Description: number or direction is not specified, applies to all channels of this type. +What: /sys/.../events/in_steps_instance_en +KernelVersion: 3.19 +Contact: [email protected] +Description: + Enables or disables step detection. Each time the user takes a step an + event of this type will be generated. + What: /sys/bus/iio/devices/iio:deviceX/trigger/current_trigger KernelVersion: 2.6.35 Contact: [email protected]
@@ -1072,3 +1079,18 @@ Contact: [email protected] Description: Raw value of rotation from true/magnetic north measured with or without compensation from tilt sensors. + +What: /sys/.../iio:deviceX/in_steps_enable +KernelVersion: 3.19 +Contact: [email protected] +Description: + Activates the step counter. After activation, the number of steps + taken by the user will be counted in hardware and exported through + in_steps_input. + +What: /sys/.../iio:deviceX/in_steps_input +KernelVersion: 3.19 +Contact: [email protected] +Description: + This attribute is used to read the number of steps taken by the user + since the last reboot while activated.
drivers/iio/industrialio-core.c +2 -0
@@ -71,6 +71,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_PRESSURE] = "pressure", [IIO_HUMIDITYRELATIVE] = "humidityrelative", [IIO_ACTIVITY] = "activity", + [IIO_STEPS] = "steps", };static const char *const iio_modifier_names[] = {
@@ -118,6 +119,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_HARDWAREGAIN] = "hardwaregain", [IIO_CHAN_INFO_HYSTERESIS] = "hysteresis", [IIO_CHAN_INFO_INT_TIME] = "integration_time", + [IIO_CHAN_INFO_ENABLE] = "en", };/**
drivers/iio/industrialio-event.c +1 -0
@@ -198,6 +198,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_TRANSITION] = "transition", + [IIO_EV_TYPE_INSTANCE] = "instance", };static const char *const iio_ev_dir_text[] = {
include/linux/iio/iio.h +1 -0
@@ -37,6 +37,7 @@ enum iio_chan_info_enum {IIO_CHAN_INFO_HARDWAREGAIN ,IIO_CHAN_INFO_HYSTERESIS ,IIO_CHAN_INFO_INT_TIME , + IIO_CHAN_INFO_ENABLE, }; enum iio_shared_by {
include/linux/iio/types.h +2 -0
@@ -31,6 +31,7 @@ enum iio_chan_type {IIO_PRESSURE ,IIO_HUMIDITYRELATIVE ,IIO_ACTIVITY , + IIO_STEPS, }; enum iio_modifier {
@@ -74,6 +75,7 @@ enum iio_event_type {IIO_EV_TYPE_THRESH_ADAPTIVE ,IIO_EV_TYPE_MAG_ADAPTIVE ,IIO_EV_TYPE_TRANSITION , + IIO_EV_TYPE_INSTANCE, }; enum iio_event_info {
Signature · 1 line
1.9.1
Re: [RFC PATCH v2 4/7] iio: core: Introduce STEPS channel type, ENABLE mask and INSTANCE event
Daniel Baluta schrieb am 09.10.2014 14:39:
Quoted 12 lines
From: Irina Tirdea <[email protected]>
These changes are needed to support the functionality of a pedometer. A pedometer has two basic functionalities: step counter and step detector.
The step counter needs to be enabled and then it will count the steps in its hardware register. Whenever the application needs to check the step count, it will read the step counter register. To support the step counter a new channel type STEPS is added. Since the pedometer needs to be enabled first so that the hardware can count and store the steps, we need a specific ENABLE channel info mask.
Quoted 3 lines
The step detector will generate an interrupt each time a step is detected. To support this functionality we add a new event type INSTANCE.
Hi,
I was wondering, if it would be better to name this channel somehow more generic. What you are actually counting are some pulses, and only the implementation of the hardware leads to the interpretation of these pulses as for example steps. Other devices for this category would be pulse counters - either stand alone, or as part of SoCs. Some use cases I could think of are: liquid/gas flow measurements, engine rotation/RPM counts, object counts, ... Any opinions?
Thanks
Hartmut
Quoted 121 lines
For more information on the Android requirements for step counter and step detector see:
http://source.android.com/devices/sensors/composite_sensors.html#counter
and http://source.android.com/devices/sensors/composite_sensors.html#detector.A device that has the pedometer functionality this interface needs to support is Freescale's MMA9553L:
http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdfSigned-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>--- Documentation/ABI/testing/sysfs-bus-iio | 22 ++++++++++++++++++++++ drivers/iio/industrialio-core.c | 2 ++ drivers/iio/industrialio-event.c | 1 + include/linux/iio/iio.h | 1 + include/linux/iio/types.h | 2 ++ 5 files changed, 28 insertions(+)Documentation/ABI/testing/sysfs-bus-iio +22
-0@@ -842,6 +842,13 @@ Description: number or direction is not specified, applies to all channels of this type. +What: /sys/.../events/in_steps_instance_en +KernelVersion: 3.19 +Contact: [email protected] +Description: + Enables or disables step detection. Each time the user takes a step an + event of this type will be generated. + What: /sys/bus/iio/devices/iio:deviceX/trigger/current_trigger KernelVersion: 2.6.35 Contact: [email protected]@@ -1072,3 +1079,18 @@ Contact: [email protected] Description: Raw value of rotation from true/magnetic north measured with or without compensation from tilt sensors. + +What: /sys/.../iio:deviceX/in_steps_enable +KernelVersion: 3.19 +Contact: [email protected] +Description: + Activates the step counter. After activation, the number of steps + taken by the user will be counted in hardware and exported through + in_steps_input. + +What: /sys/.../iio:deviceX/in_steps_input +KernelVersion: 3.19 +Contact: [email protected] +Description: + This attribute is used to read the number of steps taken by the user + since the last reboot while activated.drivers/iio/industrialio-core.c +2
-0@@ -71,6 +71,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_PRESSURE] = "pressure", [IIO_HUMIDITYRELATIVE] = "humidityrelative", [IIO_ACTIVITY] = "activity", + [IIO_STEPS] = "steps", };static const char *const iio_modifier_names[] = {@@ -118,6 +119,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_HARDWAREGAIN] = "hardwaregain", [IIO_CHAN_INFO_HYSTERESIS] = "hysteresis", [IIO_CHAN_INFO_INT_TIME] = "integration_time", + [IIO_CHAN_INFO_ENABLE] = "en", };/** drivers/iio/industrialio-event.c +1
-0@@ -198,6 +198,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_TRANSITION] = "transition", + [IIO_EV_TYPE_INSTANCE] = "instance", };static const char *const iio_ev_dir_text[] = {include/linux/iio/iio.h +1
-0@@ -37,6 +37,7 @@ enum iio_chan_info_enum {IIO_CHAN_INFO_HARDWAREGAIN ,IIO_CHAN_INFO_HYSTERESIS ,IIO_CHAN_INFO_INT_TIME , + IIO_CHAN_INFO_ENABLE, }; enum iio_shared_by {include/linux/iio/types.h +2
-0@@ -31,6 +31,7 @@ enum iio_chan_type {IIO_PRESSURE ,IIO_HUMIDITYRELATIVE ,IIO_ACTIVITY , + IIO_STEPS, }; enum iio_modifier {@@ -74,6 +75,7 @@ enum iio_event_type {IIO_EV_TYPE_THRESH_ADAPTIVE ,IIO_EV_TYPE_MAG_ADAPTIVE ,IIO_EV_TYPE_TRANSITION , + IIO_EV_TYPE_INSTANCE, }; enum iio_event_info {
Jonathan Cameron
maintainerRe: [RFC PATCH v2 4/7] iio: core: Introduce STEPS channel type, ENABLE mask and INSTANCE event
Quoted 13 lines · Hartmut Knaack
Daniel Baluta schrieb am 09.10.2014 14:39:
Quoted 12 lines
From: Irina Tirdea <[email protected]>
These changes are needed to support the functionality of a pedometer. A pedometer has two basic functionalities: step counter and step detector.
The step counter needs to be enabled and then it will count the steps in its hardware register. Whenever the application needs to check the step count, it will read the step counter register. To support the step counter a new channel type STEPS is added. Since the pedometer needs to be enabled first so that the hardware can count and store the steps, we need a specific ENABLE channel info mask.
Quoted 7 lines
Quoted 3 lines
The step detector will generate an interrupt each time a step is detected. To support this functionality we add a new event type INSTANCE.
Hi,
I was wondering, if it would be better to name this channel somehow more generic. What you are actually counting are some pulses, and only the implementation of the hardware leads to the interpretation of these pulses as for example steps. Other devices for this category would be pulse counters - either stand alone, or as part of SoCs. Some use cases I could think of are: liquid/gas flow measurements, engine rotation/RPM counts, object counts, ... Any opinions?
I agree there might be potential here for a broader interface... RPM however
would be a rotational speed measurement and hence in radians / second or radians if just a count of pulses off an encoder.
We have just recently had a human pulse counter as well which is another count.
The question to my mind is do we gain anything by making it more generic? Does it help userspace? Chances of having many applications that don't care about the difference between steps and other pulse counts is probably low so right now I'm (slightly) falling on the side of have these more specific counts.
So what does everyone else think?
Jonathan
Quoted 130 lines
Thanks
Hartmut
Quoted 114 lines
For more information on the Android requirements for step counter and step detector see:
http://source.android.com/devices/sensors/composite_sensors.html#counter
and http://source.android.com/devices/sensors/composite_sensors.html#detector.A device that has the pedometer functionality this interface needs to support is Freescale's MMA9553L:
http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdfSigned-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>--- Documentation/ABI/testing/sysfs-bus-iio | 22 ++++++++++++++++++++++ drivers/iio/industrialio-core.c | 2 ++ drivers/iio/industrialio-event.c | 1 + include/linux/iio/iio.h | 1 + include/linux/iio/types.h | 2 ++ 5 files changed, 28 insertions(+)Documentation/ABI/testing/sysfs-bus-iio +22
-0@@ -842,6 +842,13 @@ Description: number or direction is not specified, applies to all channels of this type. +What: /sys/.../events/in_steps_instance_en +KernelVersion: 3.19 +Contact: [email protected] +Description: + Enables or disables step detection. Each time the user takes a step an + event of this type will be generated. + What: /sys/bus/iio/devices/iio:deviceX/trigger/current_trigger KernelVersion: 2.6.35 Contact: [email protected]@@ -1072,3 +1079,18 @@ Contact: [email protected] Description: Raw value of rotation from true/magnetic north measured with or without compensation from tilt sensors. + +What: /sys/.../iio:deviceX/in_steps_enable +KernelVersion: 3.19 +Contact: [email protected] +Description: + Activates the step counter. After activation, the number of steps + taken by the user will be counted in hardware and exported through + in_steps_input. + +What: /sys/.../iio:deviceX/in_steps_input +KernelVersion: 3.19 +Contact: [email protected] +Description: + This attribute is used to read the number of steps taken by the user + since the last reboot while activated.drivers/iio/industrialio-core.c +2
-0@@ -71,6 +71,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_PRESSURE] = "pressure", [IIO_HUMIDITYRELATIVE] = "humidityrelative", [IIO_ACTIVITY] = "activity", + [IIO_STEPS] = "steps", };static const char *const iio_modifier_names[] = {@@ -118,6 +119,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_HARDWAREGAIN] = "hardwaregain", [IIO_CHAN_INFO_HYSTERESIS] = "hysteresis", [IIO_CHAN_INFO_INT_TIME] = "integration_time", + [IIO_CHAN_INFO_ENABLE] = "en", };/** drivers/iio/industrialio-event.c +1
-0@@ -198,6 +198,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_TRANSITION] = "transition", + [IIO_EV_TYPE_INSTANCE] = "instance", };static const char *const iio_ev_dir_text[] = {include/linux/iio/iio.h +1
-0@@ -37,6 +37,7 @@ enum iio_chan_info_enum {IIO_CHAN_INFO_HARDWAREGAIN ,IIO_CHAN_INFO_HYSTERESIS ,IIO_CHAN_INFO_INT_TIME , + IIO_CHAN_INFO_ENABLE, }; enum iio_shared_by {include/linux/iio/types.h +1
-0@@ -31,6 +31,7 @@ enum iio_chan_type {IIO_PRESSURE ,IIO_HUMIDITYRELATIVE ,IIO_ACTIVITY , + IIO_STEPS, }; enum iio_modifier {include/linux/iio/types.h enum iio_event_type { · line 81
Quoted 7 lines
include/linux/iio/types.h +1
-0@@ -74,6 +75,7 @@ enum iio_event_type {IIO_EV_TYPE_THRESH_ADAPTIVE ,IIO_EV_TYPE_MAG_ADAPTIVE ,IIO_EV_TYPE_TRANSITION , + IIO_EV_TYPE_INSTANCE, }; enum iio_event_info {--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH v2 4/7] iio: core: Introduce STEPS channel type, ENABLE mask and INSTANCE event
Quoted 28 lines · Jonathan Cameron
Quoted 13 lines · Hartmut Knaack
Daniel Baluta schrieb am 09.10.2014 14:39:
Quoted 12 lines
From: Irina Tirdea <[email protected]>
These changes are needed to support the functionality of a pedometer. A pedometer has two basic functionalities: step counter and step detector.
The step counter needs to be enabled and then it will count the steps in its hardware register. Whenever the application needs to check the step count, it will read the step counter register. To support the step counter a new channel type STEPS is added. Since the pedometer needs to be enabled first so that the hardware can count and store the steps, we need a specific ENABLE channel info mask.
Quoted 7 lines
Quoted 3 lines
The step detector will generate an interrupt each time a step is detected. To support this functionality we add a new event type INSTANCE.
Hi,
I was wondering, if it would be better to name this channel somehow more generic. What you are actually counting are some pulses, and only the implementation of the hardware leads to the interpretation of these pulses as for example steps. Other devices for this category would be pulse counters - either stand alone, or as part of SoCs. Some use cases I could think of are: liquid/gas flow measurements, engine rotation/RPM counts, object counts, ... Any opinions?I agree there might be potential here for a broader interface... RPM however
would be a rotational speed measurement and hence in radians / second or radians if just a count of pulses off an encoder.We have just recently had a human pulse counter as well which is another count.
Quoted 7 lines
The question to my mind is do we gain anything by making it more generic? Does it help userspace? Chances of having many applications that don't care about the difference between steps and other pulse counts is probably low so right now I'm (slightly) falling on the side of have these more specific counts.
So what does everyone else think?
I think making this more generic might confuse the users. Having this more specific makes the interface very clear about who should use it.
Daniel.
Jonathan Cameron
maintainerRe: [RFC PATCH v2 4/7] iio: core: Introduce STEPS channel type, ENABLE mask and INSTANCE event
In reply to Daniel BalutaQuoted 5 lines · Daniel Baluta
From: Irina Tirdea <[email protected]>
These changes are needed to support the functionality of a pedometer. A pedometer has two basic functionalities: step counter and step detector.
Quoted 7 lines
The step counter needs to be enabled and then it will count the steps in its hardware register. Whenever the application needs to check the step count, it will read the step counter register. To support the step counter a new channel type STEPS is added. Since the pedometer needs to be enabled first so that the hardware can count and store the steps,
we need a specific ENABLE channel info mask.
Perhaps enable and zero? (thus a second hit on it would reset the counter?) Actually you have to wonder why these don't free run and just let userspace do the subtraction. Would make things slightly simpler all round. Chances are we'll soon get a device that does exactly that but then I suppose that just doesn't supply an 'enable' attribute.
Quoted 3 lines
The step detector will generate an interrupt each time a step is detected. To support this functionality we add a new event type INSTANCE.
Hmm. Other option on this would be to use it as a trigger and do buffered output
of the steps counter. However, I think the approach you have is preferable.
I wonder if instance is the best name. Not that I've come up with a better
one. Btw, drop the RFC probably at this point as I suspect it means some of my keen reviewers aren't reading the patches yet ;) I think you are rapidly progressing beyond the RFC stage anyway!
Quoted 70 lines
For more information on the Android requirements for step counter and step detector see:
http://source.android.com/devices/sensors/composite_sensors.html#counter
and http://source.android.com/devices/sensors/composite_sensors.html#detector.A device that has the pedometer functionality this interface needs to support is Freescale's MMA9553L:
http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdfSigned-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>--- Documentation/ABI/testing/sysfs-bus-iio | 22 ++++++++++++++++++++++ drivers/iio/industrialio-core.c | 2 ++ drivers/iio/industrialio-event.c | 1 + include/linux/iio/iio.h | 1 + include/linux/iio/types.h | 2 ++ 5 files changed, 28 insertions(+)Documentation/ABI/testing/sysfs-bus-iio +22
-0@@ -842,6 +842,13 @@ Description: number or direction is not specified, applies to all channels of this type. +What: /sys/.../events/in_steps_instance_en +KernelVersion: 3.19 +Contact: [email protected] +Description: + Enables or disables step detection. Each time the user takes a step an + event of this type will be generated. + What: /sys/bus/iio/devices/iio:deviceX/trigger/current_trigger KernelVersion: 2.6.35 Contact: [email protected]@@ -1072,3 +1079,18 @@ Contact: [email protected] Description: Raw value of rotation from true/magnetic north measured with or without compensation from tilt sensors. + +What: /sys/.../iio:deviceX/in_steps_enable +KernelVersion: 3.19 +Contact: [email protected] +Description: + Activates the step counter. After activation, the number of steps + taken by the user will be counted in hardware and exported through + in_steps_input. + +What: /sys/.../iio:deviceX/in_steps_input +KernelVersion: 3.19 +Contact: [email protected] +Description: + This attribute is used to read the number of steps taken by the user + since the last reboot while activated.drivers/iio/industrialio-core.c +1
-0@@ -71,6 +71,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_PRESSURE] = "pressure", [IIO_HUMIDITYRELATIVE] = "humidityrelative", [IIO_ACTIVITY] = "activity", + [IIO_STEPS] = "steps", };static const char *const iio_modifier_names[] = {
drivers/iio/industrialio-core.c static const char * const iio_chan_info_postfix[] = { · line 122
Quoted 4 lines
drivers/iio/industrialio-core.c +1
-0@@ -118,6 +119,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_HARDWAREGAIN] = "hardwaregain", [IIO_CHAN_INFO_HYSTERESIS] = "hysteresis", [IIO_CHAN_INFO_INT_TIME] = "integration_time", + [IIO_CHAN_INFO_ENABLE] = "en",
you have en here and enable in the docs.
Quoted 48 lines
drivers/iio/industrialio-core.c +0
-0};/** drivers/iio/industrialio-event.c +1
-0@@ -198,6 +198,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_TRANSITION] = "transition", + [IIO_EV_TYPE_INSTANCE] = "instance", };static const char *const iio_ev_dir_text[] = {include/linux/iio/iio.h +1
-0@@ -37,6 +37,7 @@ enum iio_chan_info_enum {IIO_CHAN_INFO_HARDWAREGAIN ,IIO_CHAN_INFO_HYSTERESIS ,IIO_CHAN_INFO_INT_TIME , + IIO_CHAN_INFO_ENABLE, }; enum iio_shared_by {include/linux/iio/types.h +2
-0@@ -31,6 +31,7 @@ enum iio_chan_type {IIO_PRESSURE ,IIO_HUMIDITYRELATIVE ,IIO_ACTIVITY , + IIO_STEPS, }; enum iio_modifier {@@ -74,6 +75,7 @@ enum iio_event_type {IIO_EV_TYPE_THRESH_ADAPTIVE ,IIO_EV_TYPE_MAG_ADAPTIVE ,IIO_EV_TYPE_TRANSITION , + IIO_EV_TYPE_INSTANCE, }; enum iio_event_info {
RFC PATCH v2 5/7 iio: core: Introduce HEIGHT channel type
In reply to Daniel BalutaFrom: Irina Tirdea <[email protected]>
Some devices need the height of the user to compute various parameters. One of this devices is Freescale's MMA9553L
(http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf)
that needs the height of the user to compute the stride length which is used further to determine distance, speed and activity type.
Introduce a new channel type HEIGHT to export these values.
--- Documentation/ABI/testing/sysfs-bus-iio | 9 +++++++++ drivers/iio/industrialio-core.c | 1 + include/linux/iio/types.h | 1 + 3 files changed, 11 insertions(+)
Documentation/ABI/testing/sysfs-bus-iio +9 -0
@@ -256,6 +256,7 @@ What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_scale What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale What: /sys/bus/iio/devices/iio:deviceX/in_accel_peak_scale What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_scale +What: /sys/bus/iio/devices/iio:deviceX/in_height_scale What: /sys/bus/iio/devices/iio:deviceX/in_magn_scale What: /sys/bus/iio/devices/iio:deviceX/in_magn_x_scale What: /sys/bus/iio/devices/iio:deviceX/in_magn_y_scale
@@ -1010,6 +1011,14 @@ Description: For a list of available output power modes read in_accel_power_mode_available. +What: /sys/.../iio:deviceX/in_height_input +What: /sys/.../iio:deviceX/in_height_raw +KernelVersion: 3.17 +Contact: [email protected] +Description: + This attribute is used to set and read the user's height. + Units after application of scale are centimeters. + What: /sys/bus/iio/devices/iio:deviceX/store_eeprom KernelVersion: 3.4.0 Contact: [email protected]
drivers/iio/industrialio-core.c +1 -0
@@ -72,6 +72,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_HUMIDITYRELATIVE] = "humidityrelative", [IIO_ACTIVITY] = "activity", [IIO_STEPS] = "steps", + [IIO_HEIGHT] = "height", };static const char *const iio_modifier_names[] = {
include/linux/iio/types.h +1 -0
@@ -32,6 +32,7 @@ enum iio_chan_type {IIO_HUMIDITYRELATIVE ,IIO_ACTIVITY ,IIO_STEPS , + IIO_HEIGHT, }; enum iio_modifier {
Signature · 1 line
1.9.1
Jonathan Cameron
maintainerRe: [RFC PATCH v2 5/7] iio: core: Introduce HEIGHT channel type
Quoted 9 lines · Daniel Baluta
From: Irina Tirdea <[email protected]>
Some devices need the height of the user to compute various parameters. One of this devices is Freescale's MMA9553L
(http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf)
that needs the height of the user to compute the stride length which is used further to determine distance, speed and activity type.Introduce a new channel type HEIGHT to export these values.
Now I'd love to make this generic asin_distance_z_input etc but I guess that's pretty confusing for users ;) Sadly altitude is going to be even more confusing.
I wonder if we should make this more explicit and have it as in_steps_calibheight (repeated for all the channels whose computation it effects). It's really a parameter of those channels rather than on its own.
It should be out_height_input etc given you are setting it (like a trim DAC on some ADC setup)
The there is an implication as that you are changing the users height which, whilst it would be 'interesting', is probably the wrong impression!
*laughs* Maybe you were right to keep this an RFC for now ;)
Quoted 61 lines
Signed-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>--- Documentation/ABI/testing/sysfs-bus-iio | 9 +++++++++ drivers/iio/industrialio-core.c | 1 + include/linux/iio/types.h | 1 + 3 files changed, 11 insertions(+)Documentation/ABI/testing/sysfs-bus-iio +9
-0@@ -256,6 +256,7 @@ What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_scale What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale What: /sys/bus/iio/devices/iio:deviceX/in_accel_peak_scale What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_scale +What: /sys/bus/iio/devices/iio:deviceX/in_height_scale What: /sys/bus/iio/devices/iio:deviceX/in_magn_scale What: /sys/bus/iio/devices/iio:deviceX/in_magn_x_scale What: /sys/bus/iio/devices/iio:deviceX/in_magn_y_scale@@ -1010,6 +1011,14 @@ Description: For a list of available output power modes read in_accel_power_mode_available. +What: /sys/.../iio:deviceX/in_height_input +What: /sys/.../iio:deviceX/in_height_raw +KernelVersion: 3.17 +Contact: [email protected] +Description: + This attribute is used to set and read the user's height. + Units after application of scale are centimeters. + What: /sys/bus/iio/devices/iio:deviceX/store_eeprom KernelVersion: 3.4.0 Contact: [email protected]drivers/iio/industrialio-core.c +1
-0@@ -72,6 +72,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_HUMIDITYRELATIVE] = "humidityrelative", [IIO_ACTIVITY] = "activity", [IIO_STEPS] = "steps", + [IIO_HEIGHT] = "height", };static const char *const iio_modifier_names[] = {include/linux/iio/types.h +1
-0@@ -32,6 +32,7 @@ enum iio_chan_type {IIO_HUMIDITYRELATIVE ,IIO_ACTIVITY ,IIO_STEPS , + IIO_HEIGHT, }; enum iio_modifier {
RFC PATCH v2 6/7 iio: dummy: Demonstrate the usage of new channel types
In reply to Daniel BalutaAdds support for the new channel types in the dummy driver:
* a new channel IIO_ACTIVITY
* two state transition events (running and walking)
* a new channel IIO_STEPS and support for reading and writing pedometer step counter
* step detect event
* a new channel IIO_HEIGHT and support for reading and writing height
--- drivers/staging/iio/iio_simple_dummy.c | 199 +++++++++++++++++++++++--- drivers/staging/iio/iio_simple_dummy.h | 5 + drivers/staging/iio/iio_simple_dummy_events.c | 38 +++++ 3 files changed, 223 insertions(+), 19 deletions(-)
drivers/staging/iio/iio_simple_dummy.c +180 -19
@@ -69,6 +69,34 @@ static const struct iio_event_spec iio_dummy_event = { .mask_separate = BIT(IIO_EV_INFO_VALUE) | BIT(IIO_EV_INFO_ENABLE), }; +/* +* simple step detect event - triggered when a step is detected +*/ +static const struct iio_event_spec step_detect_event = { + .type =IIO_EV_TYPE_INSTANCE , + .dir =IIO_EV_DIR_NONE , + .mask_separate =BIT (IIO_EV_INFO_ENABLE ), +}; + +/* +* simple transition event - triggered when the reported running confidence +* value rises above a threshold value +*/ +static const struct iio_event_spec iio_running_event = { + .type =IIO_EV_TYPE_TRANSITION , + .dir =IIO_EV_DIR_RISING , + .mask_separate =BIT (IIO_EV_INFO_VALUE ) |BIT (IIO_EV_INFO_ENABLE ), +}; + +/* +* simple transition event - triggered when the reported walking confidence +* value falls under a threshold value +*/ +static const struct iio_event_spec iio_walking_event = { + .type =IIO_EV_TYPE_TRANSITION , + .dir =IIO_EV_DIR_FALLING , + .mask_separate =BIT (IIO_EV_INFO_VALUE ) |BIT (IIO_EV_INFO_ENABLE ), +};#endif /*
@@ -215,6 +243,42 @@ static const struct iio_chan_spec iio_dummy_channels[] = { .indexed = 1, .channel = 0, }, + { + .type = IIO_STEPS, + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_ENABLE), + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + .scan_index =-1 , +#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS + .event_spec = &step_detect_event, + .num_event_specs = 1, +#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ + }, + { + .type =IIO_HEIGHT , + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), + .scan_index = -1, + }, + { + .type =IIO_ACTIVITY , + .modified = 1, + .channel2 = IIO_MOD_RUNNING, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), +#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS + .event_spec = &iio_running_event, + .num_event_specs = 1, +#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ + }, + { + .type =IIO_ACTIVITY , + .modified = 1, + .channel2 = IIO_MOD_WALKING, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), +#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS + .event_spec = &iio_walking_event, + .num_event_specs = 1, +#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ + }, };/**
@@ -259,6 +323,34 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, *val = st->accel_val; ret =IIO_VAL_INT ;break ; +case IIO_HEIGHT : + *val = st->height; + ret =IIO_VAL_INT ; +break ; +default : +break ; + } +break ; +case IIO_CHAN_INFO_PROCESSED : +switch (chan->type) { +case IIO_STEPS : + *val = st->steps; + ret =IIO_VAL_INT ; +break ; +case IIO_ACTIVITY : +switch (chan->channel2) { +case IIO_MOD_RUNNING : + *val = st->activity_running; + ret =IIO_VAL_INT ; +break ; +case IIO_MOD_WALKING : + *val = st->activity_walking; + ret =IIO_VAL_INT ; +break ; +default : +break ; + } +break ;default :break ; }
@@ -269,18 +361,29 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, ret =IIO_VAL_INT ;break ;case IIO_CHAN_INFO_SCALE : -switch (chan->differential) { -case 0 : -/* only single ended adc -> 0.001333 */ - *val =0 ; - *val2 =1333 ; - ret =IIO_VAL_INT_PLUS_MICRO ; +switch (chan->type) { +case IIO_VOLTAGE : +switch (chan->differential) { +case 0 : +/* only single ended adc -> 0.001333 */ + *val =0 ; + *val2 =1333 ; + ret =IIO_VAL_INT_PLUS_MICRO ; +break ; +case 1 : +/* all differential adc channels -> +* 0.000001344 */ + *val =0 ; + *val2 =1344 ; + ret =IIO_VAL_INT_PLUS_NANO ; + } +break ; +case IIO_HEIGHT : + *val =1 ; + ret =IIO_VAL_INT ; +break ; +default :break ; -case 1 : -/* all differential adc channels -> 0.000001344 */ - *val =0 ; - *val2 =1344 ; - ret =IIO_VAL_INT_PLUS_NANO ; }break ;case IIO_CHAN_INFO_CALIBBIAS :
@@ -298,6 +401,16 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, *val2 =33 ; ret =IIO_VAL_INT_PLUS_NANO ;break ; +case IIO_CHAN_INFO_ENABLE : +switch (chan->type) { +case IIO_STEPS : + *val = st->steps_enabled; + ret =IIO_VAL_INT ; +break ; +default : +break ; + } +break ;default :break ; }
@@ -330,14 +443,50 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev,switch (mask) {case IIO_CHAN_INFO_RAW : -if (chan->output ==0 ) +switch (chan->type) { +case IIO_VOLTAGE : +if (chan->output ==0 ) +return -EINVAL ; + +/* Locking not required as writing single value */ +mutex_lock (&st->lock); + st->dac_val = val; +mutex_unlock (&st->lock); +return 0 ; +case IIO_HEIGHT : +mutex_lock (&st->lock); + st->height = val; +mutex_unlock (&st->lock); +return 0 ; +default :return -EINVAL ; - -/* Locking not required as writing single value */ -mutex_lock (&st->lock); - st->dac_val = val; -mutex_unlock (&st->lock); -return 0 ; + } +case IIO_CHAN_INFO_PROCESSED : +switch (chan->type) { +case IIO_STEPS : +mutex_lock (&st->lock); + st->steps = val; +mutex_unlock (&st->lock); +return 0 ; +case IIO_ACTIVITY : +if (val <0 ) + val =0 ; +if (val >100 ) + val =100 ; +switch (chan->channel2) { +case IIO_MOD_RUNNING : + st->activity_running = val; +return 0 ; +case IIO_MOD_WALKING : + st->activity_walking = val; +return 0 ; +default : +return -EINVAL ; + } +break ; +default : +return -EINVAL ; + }case IIO_CHAN_INFO_CALIBSCALE :mutex_lock (&st->lock);/* Compare against table - hard matching here */
@@ -356,7 +505,16 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev, st->accel_calibbias = val;mutex_unlock (&st->lock);return 0 ; - +case IIO_CHAN_INFO_ENABLE : +switch (chan->type) { +case IIO_STEPS : +mutex_lock (&st->lock); + st->steps_enabled = val; +mutex_unlock (&st->lock); +return 0 ; +default : +return -EINVAL ; + }default :return -EINVAL ; }
@@ -395,6 +553,9 @@ static int iio_dummy_init_device(struct iio_dev *indio_dev) st->accel_val =34 ; st->accel_calibbias =-7 ; st->accel_calibscale = &dummy_scales[0 ]; + st->steps =47 ; + st->activity_running =98 ; + st->activity_walking =4 ;return 0 ; }
drivers/staging/iio/iio_simple_dummy.h +5 -0
@@ -32,9 +32,14 @@ struct iio_dummy_state {int differential_adc_val[2 ];int accel_val;int accel_calibbias; +int activity_running; +int activity_walking;const struct iio_dummy_accel_calibscale *accel_calibscale;struct mutex lock;struct iio_dummy_regs *regs; +int steps_enabled; +int steps; +int height;#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS int event_irq;int event_val;
drivers/staging/iio/iio_simple_dummy_events.c +38 -0
@@ -66,12 +66,23 @@ int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,*/ switch (chan->type) {case IIO_VOLTAGE : +case IIO_ACTIVITY :switch (type) {case IIO_EV_TYPE_THRESH :if (dir ==IIO_EV_DIR_RISING ) st->event_en = state;else return -EINVAL ; +case IIO_EV_TYPE_TRANSITION : + st->event_en = state; +break ; +default : +return -EINVAL ; + } +case IIO_STEPS : +switch (type) { +case IIO_EV_TYPE_INSTANCE : + st->event_en = state;break ;default :return -EINVAL ;
@@ -161,6 +172,33 @@ static irqreturn_t iio_simple_dummy_event_handler(int irq, void *private) IIO_EV_TYPE_THRESH, 0, 0, 0), iio_get_time_ns());break ; +case 1 : +if (st->activity_running > st->event_val) +iio_push_event (indio_dev, +IIO_EVENT_CODE (IIO_ACTIVITY ,0 , +IIO_MOD_RUNNING , +IIO_EV_DIR_RISING , +IIO_EV_TYPE_TRANSITION , +0 ,0 ,0 ), +iio_get_time_ns ()); +break ; +case 2 : +if (st->activity_walking < st->event_val) +iio_push_event (indio_dev, +IIO_EVENT_CODE (IIO_ACTIVITY ,0 , +IIO_MOD_WALKING , +IIO_EV_DIR_FALLING , +IIO_EV_TYPE_TRANSITION , +0 ,0 ,0 ), +iio_get_time_ns ()); +break ; +case 3 : +iio_push_event (indio_dev, +IIO_EVENT_CODE (IIO_STEPS ,0 ,IIO_NO_MOD , +IIO_EV_DIR_NONE , +IIO_EV_TYPE_INSTANCE ,0 ,0 ,0 ), +iio_get_time_ns ()); +break ;default :break ; }
Signature · 1 line
1.9.1
Jonathan Cameron
maintainerRe: [RFC PATCH v2 6/7] iio: dummy: Demonstrate the usage of new channel types
Quoted 11 lines · Daniel Baluta
Adds support for the new channel types in the dummy driver:
* a new channelIIO_ACTIVITY
* two state transition events (running and walking)
* a new channelIIO_STEPSand support for reading and writing pedometer step counter
* step detect event
* a new channelIIO_HEIGHTand support for reading and writing heightSigned-off-by Irina Tirdea <[email protected]>Signed-off-by Daniel Baluta <[email protected]>
This looks fine, allowing for changes due to suggestions / discussions about earlier patches.
Quoted 349 lines
--- drivers/staging/iio/iio_simple_dummy.c | 199 +++++++++++++++++++++++--- drivers/staging/iio/iio_simple_dummy.h | 5 + drivers/staging/iio/iio_simple_dummy_events.c | 38 +++++ 3 files changed, 223 insertions(+), 19 deletions(-)drivers/staging/iio/iio_simple_dummy.c +180
-19@@ -69,6 +69,34 @@ static const struct iio_event_spec iio_dummy_event = { .mask_separate = BIT(IIO_EV_INFO_VALUE) | BIT(IIO_EV_INFO_ENABLE), }; +/* +* simple step detect event - triggered when a step is detected +*/ +static const struct iio_event_spec step_detect_event = { + .type =IIO_EV_TYPE_INSTANCE , + .dir =IIO_EV_DIR_NONE , + .mask_separate =BIT (IIO_EV_INFO_ENABLE ), +}; + +/* +* simple transition event - triggered when the reported running confidence +* value rises above a threshold value +*/ +static const struct iio_event_spec iio_running_event = { + .type =IIO_EV_TYPE_TRANSITION , + .dir =IIO_EV_DIR_RISING , + .mask_separate =BIT (IIO_EV_INFO_VALUE ) |BIT (IIO_EV_INFO_ENABLE ), +}; + +/* +* simple transition event - triggered when the reported walking confidence +* value falls under a threshold value +*/ +static const struct iio_event_spec iio_walking_event = { + .type =IIO_EV_TYPE_TRANSITION , + .dir =IIO_EV_DIR_FALLING , + .mask_separate =BIT (IIO_EV_INFO_VALUE ) |BIT (IIO_EV_INFO_ENABLE ), +};#endif /* @@ -215,6 +243,42 @@ static const struct iio_chan_spec iio_dummy_channels[] = { .indexed = 1, .channel = 0, }, + { + .type = IIO_STEPS, + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_ENABLE), + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + .scan_index =-1 , +#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS + .event_spec = &step_detect_event, + .num_event_specs = 1, +#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ + }, + { + .type =IIO_HEIGHT , + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), + .scan_index = -1, + }, + { + .type =IIO_ACTIVITY , + .modified = 1, + .channel2 = IIO_MOD_RUNNING, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), +#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS + .event_spec = &iio_running_event, + .num_event_specs = 1, +#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ + }, + { + .type =IIO_ACTIVITY , + .modified = 1, + .channel2 = IIO_MOD_WALKING, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), +#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS + .event_spec = &iio_walking_event, + .num_event_specs = 1, +#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ + }, };/** @@ -259,6 +323,34 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, *val = st->accel_val; ret =IIO_VAL_INT ;break ; +case IIO_HEIGHT : + *val = st->height; + ret =IIO_VAL_INT ; +break ; +default : +break ; + } +break ; +case IIO_CHAN_INFO_PROCESSED : +switch (chan->type) { +case IIO_STEPS : + *val = st->steps; + ret =IIO_VAL_INT ; +break ; +case IIO_ACTIVITY : +switch (chan->channel2) { +case IIO_MOD_RUNNING : + *val = st->activity_running; + ret =IIO_VAL_INT ; +break ; +case IIO_MOD_WALKING : + *val = st->activity_walking; + ret =IIO_VAL_INT ; +break ; +default : +break ; + } +break ;default :break ; }@@ -269,18 +361,29 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, ret =IIO_VAL_INT ;break ;case IIO_CHAN_INFO_SCALE : -switch (chan->differential) { -case 0 : -/* only single ended adc -> 0.001333 */ - *val =0 ; - *val2 =1333 ; - ret =IIO_VAL_INT_PLUS_MICRO ; +switch (chan->type) { +case IIO_VOLTAGE : +switch (chan->differential) { +case 0 : +/* only single ended adc -> 0.001333 */ + *val =0 ; + *val2 =1333 ; + ret =IIO_VAL_INT_PLUS_MICRO ; +break ; +case 1 : +/* all differential adc channels -> +* 0.000001344 */ + *val =0 ; + *val2 =1344 ; + ret =IIO_VAL_INT_PLUS_NANO ; + } +break ; +case IIO_HEIGHT : + *val =1 ; + ret =IIO_VAL_INT ; +break ; +default :break ; -case 1 : -/* all differential adc channels -> 0.000001344 */ - *val =0 ; - *val2 =1344 ; - ret =IIO_VAL_INT_PLUS_NANO ; }break ;case IIO_CHAN_INFO_CALIBBIAS :@@ -298,6 +401,16 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, *val2 =33 ; ret =IIO_VAL_INT_PLUS_NANO ;break ; +case IIO_CHAN_INFO_ENABLE : +switch (chan->type) { +case IIO_STEPS : + *val = st->steps_enabled; + ret =IIO_VAL_INT ; +break ; +default : +break ; + } +break ;default :break ; }@@ -330,14 +443,50 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev,switch (mask) {case IIO_CHAN_INFO_RAW : -if (chan->output ==0 ) +switch (chan->type) { +case IIO_VOLTAGE : +if (chan->output ==0 ) +return -EINVAL ; + +/* Locking not required as writing single value */ +mutex_lock (&st->lock); + st->dac_val = val; +mutex_unlock (&st->lock); +return 0 ; +case IIO_HEIGHT : +mutex_lock (&st->lock); + st->height = val; +mutex_unlock (&st->lock); +return 0 ; +default :return -EINVAL ; - -/* Locking not required as writing single value */ -mutex_lock (&st->lock); - st->dac_val = val; -mutex_unlock (&st->lock); -return 0 ; + } +case IIO_CHAN_INFO_PROCESSED : +switch (chan->type) { +case IIO_STEPS : +mutex_lock (&st->lock); + st->steps = val; +mutex_unlock (&st->lock); +return 0 ; +case IIO_ACTIVITY : +if (val <0 ) + val =0 ; +if (val >100 ) + val =100 ; +switch (chan->channel2) { +case IIO_MOD_RUNNING : + st->activity_running = val; +return 0 ; +case IIO_MOD_WALKING : + st->activity_walking = val; +return 0 ; +default : +return -EINVAL ; + } +break ; +default : +return -EINVAL ; + }case IIO_CHAN_INFO_CALIBSCALE :mutex_lock (&st->lock);/* Compare against table - hard matching here */ @@ -356,7 +505,16 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev, st->accel_calibbias = val;mutex_unlock (&st->lock);return 0 ; - +case IIO_CHAN_INFO_ENABLE : +switch (chan->type) { +case IIO_STEPS : +mutex_lock (&st->lock); + st->steps_enabled = val; +mutex_unlock (&st->lock); +return 0 ; +default : +return -EINVAL ; + }default :return -EINVAL ; }@@ -395,6 +553,9 @@ static int iio_dummy_init_device(struct iio_dev *indio_dev) st->accel_val =34 ; st->accel_calibbias =-7 ; st->accel_calibscale = &dummy_scales[0 ]; + st->steps =47 ; + st->activity_running =98 ; + st->activity_walking =4 ;return 0 ; }drivers/staging/iio/iio_simple_dummy.h +5
-0@@ -32,9 +32,14 @@ struct iio_dummy_state {int differential_adc_val[2 ];int accel_val;int accel_calibbias; +int activity_running; +int activity_walking;const struct iio_dummy_accel_calibscale *accel_calibscale;struct mutex lock;struct iio_dummy_regs *regs; +int steps_enabled; +int steps; +int height;#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS int event_irq;int event_val;drivers/staging/iio/iio_simple_dummy_events.c +38
-0@@ -66,12 +66,23 @@ int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,*/ switch (chan->type) {case IIO_VOLTAGE : +case IIO_ACTIVITY :switch (type) {case IIO_EV_TYPE_THRESH :if (dir ==IIO_EV_DIR_RISING ) st->event_en = state;else return -EINVAL ; +case IIO_EV_TYPE_TRANSITION : + st->event_en = state; +break ; +default : +return -EINVAL ; + } +case IIO_STEPS : +switch (type) { +case IIO_EV_TYPE_INSTANCE : + st->event_en = state;break ;default :return -EINVAL ;@@ -161,6 +172,33 @@ static irqreturn_t iio_simple_dummy_event_handler(int irq, void *private) IIO_EV_TYPE_THRESH, 0, 0, 0), iio_get_time_ns());break ; +case 1 : +if (st->activity_running > st->event_val) +iio_push_event (indio_dev, +IIO_EVENT_CODE (IIO_ACTIVITY ,0 , +IIO_MOD_RUNNING , +IIO_EV_DIR_RISING , +IIO_EV_TYPE_TRANSITION , +0 ,0 ,0 ), +iio_get_time_ns ()); +break ; +case 2 : +if (st->activity_walking < st->event_val) +iio_push_event (indio_dev, +IIO_EVENT_CODE (IIO_ACTIVITY ,0 , +IIO_MOD_WALKING , +IIO_EV_DIR_FALLING , +IIO_EV_TYPE_TRANSITION , +0 ,0 ,0 ), +iio_get_time_ns ()); +break ; +case 3 : +iio_push_event (indio_dev, +IIO_EVENT_CODE (IIO_STEPS ,0 ,IIO_NO_MOD , +IIO_EV_DIR_NONE , +IIO_EV_TYPE_INSTANCE ,0 ,0 ,0 ), +iio_get_time_ns ()); +break ;default :break ; }
RFC PATCH v2 7/7 iio: event_monitor: Add support for new channel types
In reply to Daniel BalutaWe have the following testing scenario:
$ insmod iio_dummy_evgen.ko $ insmod iio_dummy.ko
./iio_event_monitor /dev/iio:device0
Event: time: 1412786467971335337, type: activity(running), channel: 0, evtype: transition, direction:
rising
Event: time: 1412786530792974091, type: activity(walking), channel: 0, evtype: transition, direction:
falling
Event: time: 1412764319184761765, type: steps, channel: 0, evtype: instance
$ echo 1 > /sys/bus/iio/devices/iio_evgen/poke_ev0 $ echo 2 > /sys/bus/iio/devices/iio_evgen/poke_ev0 $ echo 3 > /sys/bus/iio/devices/iio_evgen/poke_ev0
--- .../staging/iio/Documentation/iio_event_monitor.c | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/staging/iio/Documentation/iio_event_monitor.c +22 -3
@@ -49,6 +49,8 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_CCT] = "cct", [IIO_PRESSURE] = "pressure", [IIO_HUMIDITYRELATIVE] = "humidityrelative", + [IIO_ACTIVITY] = "activity", + [IIO_STEPS] = "steps", };static const char *const iio_ev_type_text[] = {
@@ -57,6 +59,8 @@ static const char * const iio_ev_type_text[] = { [IIO_EV_TYPE_ROC] = "roc", [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive", [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive", + [IIO_EV_TYPE_TRANSITION] = "transition", + [IIO_EV_TYPE_INSTANCE] = "instance", };static const char *const iio_ev_dir_text[] = {
@@ -79,6 +83,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_LIGHT_RED] = "red", [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", + [IIO_MOD_RUNNING] = "running", + [IIO_MOD_JOGGING] = "jogging", + [IIO_MOD_WALKING] = "walking", + [IIO_MOD_STILL] = "still", };static bool event_is_known (struct iio_event_data *event)
@@ -108,6 +116,8 @@ static bool event_is_known(struct iio_event_data *event)case IIO_CCT :case IIO_PRESSURE :case IIO_HUMIDITYRELATIVE : +case IIO_ACTIVITY : +case IIO_STEPS :break ;default :return false;
@@ -126,6 +136,10 @@ static bool event_is_known(struct iio_event_data *event)case IIO_MOD_LIGHT_RED :case IIO_MOD_LIGHT_GREEN :case IIO_MOD_LIGHT_BLUE : +case IIO_MOD_RUNNING : +case IIO_MOD_JOGGING : +case IIO_MOD_WALKING : +case IIO_MOD_STILL :break ;default :return false;
@@ -137,6 +151,8 @@ static bool event_is_known(struct iio_event_data *event)case IIO_EV_TYPE_ROC :case IIO_EV_TYPE_THRESH_ADAPTIVE :case IIO_EV_TYPE_MAG_ADAPTIVE : +case IIO_EV_TYPE_TRANSITION : +case IIO_EV_TYPE_INSTANCE :break ;default :return false;
@@ -146,6 +162,7 @@ static bool event_is_known(struct iio_event_data *event)case IIO_EV_DIR_EITHER :case IIO_EV_DIR_RISING :case IIO_EV_DIR_FALLING : +case IIO_EV_DIR_NONE :break ;default :return false;
@@ -186,9 +203,11 @@ static void print_event(struct iio_event_data *event)else if (chan >=0 )printf ("channel: %d, " , chan); -printf ("evtype: %s, direction: %s\n" , - iio_ev_type_text[ev_type], - iio_ev_dir_text[dir]); +printf ("evtype: %s" , iio_ev_type_text[ev_type]); + +if (dir !=IIO_EV_DIR_NONE ) +printf (", direction: %s" , iio_ev_dir_text[dir]); +printf ("\n" ); }int main (int argc,char **argv)
Signature · 1 line
1.9.1