aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baluta <daniel.baluta@intel.com>2014-11-10 07:45:35 -0500
committerJonathan Cameron <jic23@kernel.org>2014-11-22 06:17:05 -0500
commit282a5663930ba79af9ec38884580c140fedf8aaa (patch)
tree4f8418e58093501166a4d5b84148112d726bde64
parent3e34e650db19708b1c27421e8d3d749a09adbb0c (diff)
iio: event_monitor: Add support for new channel types
We 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: thresh, direction: rising Event: time: 1412786530792974091, type: activity(walking), channel: 0, evtype: thresh, 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 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--drivers/staging/iio/Documentation/iio_event_monitor.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/staging/iio/Documentation/iio_event_monitor.c b/drivers/staging/iio/Documentation/iio_event_monitor.c
index 940ed2399e73..def236abcb3e 100644
--- a/drivers/staging/iio/Documentation/iio_event_monitor.c
+++ b/drivers/staging/iio/Documentation/iio_event_monitor.c
@@ -49,6 +49,8 @@ static const char * const iio_chan_type_name_spec[] = {
49 [IIO_CCT] = "cct", 49 [IIO_CCT] = "cct",
50 [IIO_PRESSURE] = "pressure", 50 [IIO_PRESSURE] = "pressure",
51 [IIO_HUMIDITYRELATIVE] = "humidityrelative", 51 [IIO_HUMIDITYRELATIVE] = "humidityrelative",
52 [IIO_ACTIVITY] = "activity",
53 [IIO_STEPS] = "steps",
52}; 54};
53 55
54static const char * const iio_ev_type_text[] = { 56static const char * const iio_ev_type_text[] = {
@@ -57,6 +59,7 @@ static const char * const iio_ev_type_text[] = {
57 [IIO_EV_TYPE_ROC] = "roc", 59 [IIO_EV_TYPE_ROC] = "roc",
58 [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive", 60 [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive",
59 [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive", 61 [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive",
62 [IIO_EV_TYPE_INSTANCE] = "instance",
60}; 63};
61 64
62static const char * const iio_ev_dir_text[] = { 65static const char * const iio_ev_dir_text[] = {
@@ -92,6 +95,10 @@ static const char * const iio_modifier_names[] = {
92 [IIO_MOD_NORTH_TRUE] = "from_north_true", 95 [IIO_MOD_NORTH_TRUE] = "from_north_true",
93 [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp", 96 [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp",
94 [IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp", 97 [IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp",
98 [IIO_MOD_RUNNING] = "running",
99 [IIO_MOD_JOGGING] = "jogging",
100 [IIO_MOD_WALKING] = "walking",
101 [IIO_MOD_STILL] = "still",
95}; 102};
96 103
97static bool event_is_known(struct iio_event_data *event) 104static bool event_is_known(struct iio_event_data *event)
@@ -121,6 +128,8 @@ static bool event_is_known(struct iio_event_data *event)
121 case IIO_CCT: 128 case IIO_CCT:
122 case IIO_PRESSURE: 129 case IIO_PRESSURE:
123 case IIO_HUMIDITYRELATIVE: 130 case IIO_HUMIDITYRELATIVE:
131 case IIO_ACTIVITY:
132 case IIO_STEPS:
124 break; 133 break;
125 default: 134 default:
126 return false; 135 return false;
@@ -154,6 +163,10 @@ static bool event_is_known(struct iio_event_data *event)
154 case IIO_MOD_NORTH_TRUE: 163 case IIO_MOD_NORTH_TRUE:
155 case IIO_MOD_NORTH_MAGN_TILT_COMP: 164 case IIO_MOD_NORTH_MAGN_TILT_COMP:
156 case IIO_MOD_NORTH_TRUE_TILT_COMP: 165 case IIO_MOD_NORTH_TRUE_TILT_COMP:
166 case IIO_MOD_RUNNING:
167 case IIO_MOD_JOGGING:
168 case IIO_MOD_WALKING:
169 case IIO_MOD_STILL:
157 break; 170 break;
158 default: 171 default:
159 return false; 172 return false;
@@ -165,6 +178,7 @@ static bool event_is_known(struct iio_event_data *event)
165 case IIO_EV_TYPE_ROC: 178 case IIO_EV_TYPE_ROC:
166 case IIO_EV_TYPE_THRESH_ADAPTIVE: 179 case IIO_EV_TYPE_THRESH_ADAPTIVE:
167 case IIO_EV_TYPE_MAG_ADAPTIVE: 180 case IIO_EV_TYPE_MAG_ADAPTIVE:
181 case IIO_EV_TYPE_INSTANCE:
168 break; 182 break;
169 default: 183 default:
170 return false; 184 return false;
@@ -174,6 +188,7 @@ static bool event_is_known(struct iio_event_data *event)
174 case IIO_EV_DIR_EITHER: 188 case IIO_EV_DIR_EITHER:
175 case IIO_EV_DIR_RISING: 189 case IIO_EV_DIR_RISING:
176 case IIO_EV_DIR_FALLING: 190 case IIO_EV_DIR_FALLING:
191 case IIO_EV_DIR_NONE:
177 break; 192 break;
178 default: 193 default:
179 return false; 194 return false;
@@ -214,9 +229,11 @@ static void print_event(struct iio_event_data *event)
214 else if (chan >= 0) 229 else if (chan >= 0)
215 printf("channel: %d, ", chan); 230 printf("channel: %d, ", chan);
216 231
217 printf("evtype: %s, direction: %s\n", 232 printf("evtype: %s", iio_ev_type_text[ev_type]);
218 iio_ev_type_text[ev_type], 233
219 iio_ev_dir_text[dir]); 234 if (dir != IIO_EV_DIR_NONE)
235 printf(", direction: %s", iio_ev_dir_text[dir]);
236 printf("\n");
220} 237}
221 238
222int main(int argc, char **argv) 239int main(int argc, char **argv)