Skip to content

Commit 835e699

Browse files
jaggu52jic23
authored andcommitted
iio: Add new event type gesture and use direction for single and double tap
Add new event type for tap called gesture and the direction can be used to differentiate single and double tap. This may be used by accelerometer sensors to express single and double tap events. For directional tap, modifiers like IIO_MOD_(X/Y/Z) can be used along with singletap and doubletap direction. Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com> Link: https://lore.kernel.org/r/20220831063117.4141-2-jagathjog1996@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 2bc9cd6 commit 835e699

File tree

5 files changed

+87
-2
lines changed

5 files changed

+87
-2
lines changed

Documentation/ABI/testing/sysfs-bus-iio

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,3 +2068,72 @@ Description:
20682068
individual channels. If multiple channels are enabled in a scan,
20692069
then the sampling_frequency of the scan may be computed from the
20702070
per channel sampling frequencies.
2071+
2072+
What: /sys/.../events/in_accel_gesture_singletap_en
2073+
What: /sys/.../events/in_accel_gesture_doubletap_en
2074+
KernelVersion: 6.1
2075+
Contact: linux-iio@vger.kernel.org
2076+
Description:
2077+
Device generates an event on a single or double tap.
2078+
2079+
What: /sys/.../events/in_accel_gesture_singletap_value
2080+
What: /sys/.../events/in_accel_gesture_doubletap_value
2081+
KernelVersion: 6.1
2082+
Contact: linux-iio@vger.kernel.org
2083+
Description:
2084+
Specifies the threshold value that the device is comparing
2085+
against to generate the tap gesture event. The lower
2086+
threshold value increases the sensitivity of tap detection.
2087+
Units and the exact meaning of value are device-specific.
2088+
2089+
What: /sys/.../events/in_accel_gesture_tap_value_available
2090+
KernelVersion: 6.1
2091+
Contact: linux-iio@vger.kernel.org
2092+
Description:
2093+
Lists all available threshold values which can be used to
2094+
modify the sensitivity of the tap detection.
2095+
2096+
What: /sys/.../events/in_accel_gesture_singletap_reset_timeout
2097+
What: /sys/.../events/in_accel_gesture_doubletap_reset_timeout
2098+
KernelVersion: 6.1
2099+
Contact: linux-iio@vger.kernel.org
2100+
Description:
2101+
Specifies the timeout value in seconds for the tap detector
2102+
to not to look for another tap event after the event as
2103+
occurred. Basically the minimum quiet time between the two
2104+
single-tap's or two double-tap's.
2105+
2106+
What: /sys/.../events/in_accel_gesture_tap_reset_timeout_available
2107+
KernelVersion: 6.1
2108+
Contact: linux-iio@vger.kernel.org
2109+
Description:
2110+
Lists all available tap reset timeout values. Units in seconds.
2111+
2112+
What: /sys/.../events/in_accel_gesture_doubletap_tap2_min_delay
2113+
KernelVersion: 6.1
2114+
Contact: linux-iio@vger.kernel.org
2115+
Description:
2116+
Specifies the minimum quiet time in seconds between the two
2117+
taps of a double tap.
2118+
2119+
What: /sys/.../events/in_accel_gesture_doubletap_tap2_min_delay_available
2120+
KernelVersion: 6.1
2121+
Contact: linux-iio@vger.kernel.org
2122+
Description:
2123+
Lists all available delay values between two taps in the double
2124+
tap. Units in seconds.
2125+
2126+
What: /sys/.../events/in_accel_gesture_tap_maxtomin_time
2127+
KernelVersion: 6.1
2128+
Contact: linux-iio@vger.kernel.org
2129+
Description:
2130+
Specifies the maximum time difference allowed between upper
2131+
and lower peak of tap to consider it as the valid tap event.
2132+
Units in seconds.
2133+
2134+
What: /sys/.../events/in_accel_gesture_tap_maxtomin_time_available
2135+
KernelVersion: 6.1
2136+
Contact: linux-iio@vger.kernel.org
2137+
Description:
2138+
Lists all available time values between upper peak to lower
2139+
peak. Units in seconds.

drivers/iio/industrialio-event.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,15 @@ static const char * const iio_ev_type_text[] = {
231231
[IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive",
232232
[IIO_EV_TYPE_CHANGE] = "change",
233233
[IIO_EV_TYPE_MAG_REFERENCED] = "mag_referenced",
234+
[IIO_EV_TYPE_GESTURE] = "gesture",
234235
};
235236

236237
static const char * const iio_ev_dir_text[] = {
237238
[IIO_EV_DIR_EITHER] = "either",
238239
[IIO_EV_DIR_RISING] = "rising",
239-
[IIO_EV_DIR_FALLING] = "falling"
240+
[IIO_EV_DIR_FALLING] = "falling",
241+
[IIO_EV_DIR_SINGLETAP] = "singletap",
242+
[IIO_EV_DIR_DOUBLETAP] = "doubletap",
240243
};
241244

242245
static const char * const iio_ev_info_text[] = {
@@ -247,6 +250,8 @@ static const char * const iio_ev_info_text[] = {
247250
[IIO_EV_INFO_HIGH_PASS_FILTER_3DB] = "high_pass_filter_3db",
248251
[IIO_EV_INFO_LOW_PASS_FILTER_3DB] = "low_pass_filter_3db",
249252
[IIO_EV_INFO_TIMEOUT] = "timeout",
253+
[IIO_EV_INFO_RESET_TIMEOUT] = "reset_timeout",
254+
[IIO_EV_INFO_TAP2_MIN_DELAY] = "tap2_min_delay",
250255
};
251256

252257
static enum iio_event_direction iio_ev_attr_dir(struct iio_dev_attr *attr)

include/linux/iio/types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ enum iio_event_info {
1717
IIO_EV_INFO_HIGH_PASS_FILTER_3DB,
1818
IIO_EV_INFO_LOW_PASS_FILTER_3DB,
1919
IIO_EV_INFO_TIMEOUT,
20+
IIO_EV_INFO_RESET_TIMEOUT,
21+
IIO_EV_INFO_TAP2_MIN_DELAY,
2022
};
2123

2224
#define IIO_VAL_INT 1

include/uapi/linux/iio/types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,16 @@ enum iio_event_type {
105105
IIO_EV_TYPE_MAG_ADAPTIVE,
106106
IIO_EV_TYPE_CHANGE,
107107
IIO_EV_TYPE_MAG_REFERENCED,
108+
IIO_EV_TYPE_GESTURE,
108109
};
109110

110111
enum iio_event_direction {
111112
IIO_EV_DIR_EITHER,
112113
IIO_EV_DIR_RISING,
113114
IIO_EV_DIR_FALLING,
114115
IIO_EV_DIR_NONE,
116+
IIO_EV_DIR_SINGLETAP,
117+
IIO_EV_DIR_DOUBLETAP,
115118
};
116119

117120
#endif /* _UAPI_IIO_TYPES_H_ */

tools/iio/iio_event_monitor.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,15 @@ static const char * const iio_ev_type_text[] = {
6969
[IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive",
7070
[IIO_EV_TYPE_CHANGE] = "change",
7171
[IIO_EV_TYPE_MAG_REFERENCED] = "mag_referenced",
72+
[IIO_EV_TYPE_GESTURE] = "gesture",
7273
};
7374

7475
static const char * const iio_ev_dir_text[] = {
7576
[IIO_EV_DIR_EITHER] = "either",
7677
[IIO_EV_DIR_RISING] = "rising",
77-
[IIO_EV_DIR_FALLING] = "falling"
78+
[IIO_EV_DIR_FALLING] = "falling",
79+
[IIO_EV_DIR_SINGLETAP] = "singletap",
80+
[IIO_EV_DIR_DOUBLETAP] = "doubletap",
7881
};
7982

8083
static const char * const iio_modifier_names[] = {
@@ -227,6 +230,7 @@ static bool event_is_known(struct iio_event_data *event)
227230
case IIO_EV_TYPE_THRESH_ADAPTIVE:
228231
case IIO_EV_TYPE_MAG_ADAPTIVE:
229232
case IIO_EV_TYPE_CHANGE:
233+
case IIO_EV_TYPE_GESTURE:
230234
break;
231235
default:
232236
return false;
@@ -236,6 +240,8 @@ static bool event_is_known(struct iio_event_data *event)
236240
case IIO_EV_DIR_EITHER:
237241
case IIO_EV_DIR_RISING:
238242
case IIO_EV_DIR_FALLING:
243+
case IIO_EV_DIR_SINGLETAP:
244+
case IIO_EV_DIR_DOUBLETAP:
239245
case IIO_EV_DIR_NONE:
240246
break;
241247
default:

0 commit comments

Comments
 (0)