Skip to content

Commit 55aebeb

Browse files
Daniel Balutajic23
authored andcommitted
iio: core: Introduce IIO_ACTIVITY channel
This channel will be used for exposing information about activity composite sensors. Activities supported so far: * running * jogging * walking * still THRESHOLD 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 possible 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 Signed-off-by: Irina Tirdea <[email protected]> Signed-off-by: Daniel Baluta <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 356ae94 commit 55aebeb

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

Documentation/ABI/testing/sysfs-bus-iio

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,40 @@ Description:
790790
met before an event is generated. If direction is not
791791
specified then this period applies to both directions.
792792

793+
What: /sys/.../events/in_activity_still_thresh_rising_en
794+
What: /sys/.../events/in_activity_still_thresh_falling_en
795+
What: /sys/.../events/in_activity_walking_thresh_rising_en
796+
What: /sys/.../events/in_activity_walking_thresh_falling_en
797+
What: /sys/.../events/in_activity_jogging_thresh_rising_en
798+
What: /sys/.../events/in_activity_jogging_thresh_falling_en
799+
What: /sys/.../events/in_activity_running_thresh_rising_en
800+
What: /sys/.../events/in_activity_running_thresh_falling_en
801+
KernelVersion: 3.19
802+
803+
Description:
804+
Enables or disables activitity events. Depending on direction
805+
an event is generated when sensor ENTERS or LEAVES a given state.
806+
807+
What: /sys/.../events/in_activity_still_thresh_rising_value
808+
What: /sys/.../events/in_activity_still_thresh_falling_value
809+
What: /sys/.../events/in_activity_walking_thresh_rising_value
810+
What: /sys/.../events/in_activity_walking_thresh_falling_value
811+
What: /sys/.../events/in_activity_jogging_thresh_rising_value
812+
What: /sys/.../events/in_activity_jogging_thresh_falling_value
813+
What: /sys/.../events/in_activity_running_thresh_rising_value
814+
What: /sys/.../events/in_activity_running_thresh_falling_value
815+
KernelVersion: 3.19
816+
817+
Description:
818+
Confidence value (in units as percentage) to be used
819+
for deciding when an event should be generated. E.g for
820+
running: If the confidence value reported by the sensor
821+
is greater than in_activity_running_thresh_rising_value
822+
then the sensor ENTERS running state. Conversely, if the
823+
confidence value reported by the sensor is lower than
824+
in_activity_running_thresh_falling_value then the sensor
825+
is LEAVING running state.
826+
793827
What: /sys/.../iio:deviceX/events/in_accel_mag_en
794828
What: /sys/.../iio:deviceX/events/in_accel_mag_rising_en
795829
What: /sys/.../iio:deviceX/events/in_accel_mag_falling_en
@@ -956,6 +990,16 @@ Description:
956990
and the relevant _type attributes to establish the data storage
957991
format.
958992

993+
What: /sys/.../iio:deviceX/in_activity_still_input
994+
What: /sys/.../iio:deviceX/in_activity_walking_input
995+
What: /sys/.../iio:deviceX/in_activity_jogging_input
996+
What: /sys/.../iio:deviceX/in_activity_running_input
997+
KernelVersion: 3.19
998+
999+
Description:
1000+
This attribute is used to read the confidence for an activity
1001+
expressed in units as percentage.
1002+
9591003
What: /sys/.../iio:deviceX/in_anglvel_z_quadrature_correction_raw
9601004
KernelVersion: 2.6.38
9611005

drivers/iio/industrialio-core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static const char * const iio_chan_type_name_spec[] = {
7070
[IIO_CCT] = "cct",
7171
[IIO_PRESSURE] = "pressure",
7272
[IIO_HUMIDITYRELATIVE] = "humidityrelative",
73+
[IIO_ACTIVITY] = "activity",
7374
};
7475

7576
static const char * const iio_modifier_names[] = {
@@ -91,6 +92,10 @@ static const char * const iio_modifier_names[] = {
9192
[IIO_MOD_NORTH_TRUE] = "from_north_true",
9293
[IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp",
9394
[IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp",
95+
[IIO_MOD_RUNNING] = "running",
96+
[IIO_MOD_JOGGING] = "jogging",
97+
[IIO_MOD_WALKING] = "walking",
98+
[IIO_MOD_STILL] = "still",
9499
};
95100

96101
/* relies on pairs of these shared then separate */

include/linux/iio/types.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ enum iio_chan_type {
3030
IIO_CCT,
3131
IIO_PRESSURE,
3232
IIO_HUMIDITYRELATIVE,
33+
IIO_ACTIVITY,
3334
};
3435

3536
enum iio_modifier {
@@ -59,7 +60,11 @@ enum iio_modifier {
5960
IIO_MOD_NORTH_MAGN,
6061
IIO_MOD_NORTH_TRUE,
6162
IIO_MOD_NORTH_MAGN_TILT_COMP,
62-
IIO_MOD_NORTH_TRUE_TILT_COMP
63+
IIO_MOD_NORTH_TRUE_TILT_COMP,
64+
IIO_MOD_RUNNING,
65+
IIO_MOD_JOGGING,
66+
IIO_MOD_WALKING,
67+
IIO_MOD_STILL,
6368
};
6469

6570
enum iio_event_type {

0 commit comments

Comments
 (0)