aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baluta <daniel.baluta@intel.com>2014-11-10 07:45:30 -0500
committerJonathan Cameron <jic23@kernel.org>2014-11-22 06:05:47 -0500
commit55aebeb926b6f93a540328e7ac770ef536b09b77 (patch)
tree2f672ff0a471b842d07af0e546547e16e2219ea0
parent356ae946f9945997213b19279bc2e84bb61cc26a (diff)
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 <irina.tirdea@intel.com> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio44
-rw-r--r--drivers/iio/industrialio-core.c5
-rw-r--r--include/linux/iio/types.h7
3 files changed, 55 insertions, 1 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 117521dbf2b3..7bf49ad8fd82 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -790,6 +790,40 @@ Description:
790 met before an event is generated. If direction is not 790 met before an event is generated. If direction is not
791 specified then this period applies to both directions. 791 specified then this period applies to both directions.
792 792
793What: /sys/.../events/in_activity_still_thresh_rising_en
794What: /sys/.../events/in_activity_still_thresh_falling_en
795What: /sys/.../events/in_activity_walking_thresh_rising_en
796What: /sys/.../events/in_activity_walking_thresh_falling_en
797What: /sys/.../events/in_activity_jogging_thresh_rising_en
798What: /sys/.../events/in_activity_jogging_thresh_falling_en
799What: /sys/.../events/in_activity_running_thresh_rising_en
800What: /sys/.../events/in_activity_running_thresh_falling_en
801KernelVersion: 3.19
802Contact: linux-iio@vger.kernel.org
803Description:
804 Enables or disables activitity events. Depending on direction
805 an event is generated when sensor ENTERS or LEAVES a given state.
806
807What: /sys/.../events/in_activity_still_thresh_rising_value
808What: /sys/.../events/in_activity_still_thresh_falling_value
809What: /sys/.../events/in_activity_walking_thresh_rising_value
810What: /sys/.../events/in_activity_walking_thresh_falling_value
811What: /sys/.../events/in_activity_jogging_thresh_rising_value
812What: /sys/.../events/in_activity_jogging_thresh_falling_value
813What: /sys/.../events/in_activity_running_thresh_rising_value
814What: /sys/.../events/in_activity_running_thresh_falling_value
815KernelVersion: 3.19
816Contact: linux-iio@vger.kernel.org
817Description:
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
793What: /sys/.../iio:deviceX/events/in_accel_mag_en 827What: /sys/.../iio:deviceX/events/in_accel_mag_en
794What: /sys/.../iio:deviceX/events/in_accel_mag_rising_en 828What: /sys/.../iio:deviceX/events/in_accel_mag_rising_en
795What: /sys/.../iio:deviceX/events/in_accel_mag_falling_en 829What: /sys/.../iio:deviceX/events/in_accel_mag_falling_en
@@ -956,6 +990,16 @@ Description:
956 and the relevant _type attributes to establish the data storage 990 and the relevant _type attributes to establish the data storage
957 format. 991 format.
958 992
993What: /sys/.../iio:deviceX/in_activity_still_input
994What: /sys/.../iio:deviceX/in_activity_walking_input
995What: /sys/.../iio:deviceX/in_activity_jogging_input
996What: /sys/.../iio:deviceX/in_activity_running_input
997KernelVersion: 3.19
998Contact: linux-iio@vger.kernel.org
999Description:
1000 This attribute is used to read the confidence for an activity
1001 expressed in units as percentage.
1002
959What: /sys/.../iio:deviceX/in_anglvel_z_quadrature_correction_raw 1003What: /sys/.../iio:deviceX/in_anglvel_z_quadrature_correction_raw
960KernelVersion: 2.6.38 1004KernelVersion: 2.6.38
961Contact: linux-iio@vger.kernel.org 1005Contact: linux-iio@vger.kernel.org
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index af3e76d652ba..e453ef9e0c36 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -70,6 +70,7 @@ static const char * const iio_chan_type_name_spec[] = {
70 [IIO_CCT] = "cct", 70 [IIO_CCT] = "cct",
71 [IIO_PRESSURE] = "pressure", 71 [IIO_PRESSURE] = "pressure",
72 [IIO_HUMIDITYRELATIVE] = "humidityrelative", 72 [IIO_HUMIDITYRELATIVE] = "humidityrelative",
73 [IIO_ACTIVITY] = "activity",
73}; 74};
74 75
75static const char * const iio_modifier_names[] = { 76static const char * const iio_modifier_names[] = {
@@ -91,6 +92,10 @@ static const char * const iio_modifier_names[] = {
91 [IIO_MOD_NORTH_TRUE] = "from_north_true", 92 [IIO_MOD_NORTH_TRUE] = "from_north_true",
92 [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp", 93 [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp",
93 [IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp", 94 [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",
94}; 99};
95 100
96/* relies on pairs of these shared then separate */ 101/* relies on pairs of these shared then separate */
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
index 4a2af8adf874..b3a241d53b54 100644
--- a/include/linux/iio/types.h
+++ b/include/linux/iio/types.h
@@ -30,6 +30,7 @@ enum iio_chan_type {
30 IIO_CCT, 30 IIO_CCT,
31 IIO_PRESSURE, 31 IIO_PRESSURE,
32 IIO_HUMIDITYRELATIVE, 32 IIO_HUMIDITYRELATIVE,
33 IIO_ACTIVITY,
33}; 34};
34 35
35enum iio_modifier { 36enum iio_modifier {
@@ -59,7 +60,11 @@ enum iio_modifier {
59 IIO_MOD_NORTH_MAGN, 60 IIO_MOD_NORTH_MAGN,
60 IIO_MOD_NORTH_TRUE, 61 IIO_MOD_NORTH_TRUE,
61 IIO_MOD_NORTH_MAGN_TILT_COMP, 62 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,
63}; 68};
64 69
65enum iio_event_type { 70enum iio_event_type {