From: Lothar Rubusch <l.rubusch@gmail.com>
To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
eraretuya@gmail.com, l.rubusch@gmail.com
Subject: [PATCH v1 07/12] iio: accel: adxl345: show tap status and direction
Date: Tue, 28 Jan 2025 12:00:55 +0000 [thread overview]
Message-ID: <20250128120100.205523-8-l.rubusch@gmail.com> (raw)
In-Reply-To: <20250128120100.205523-1-l.rubusch@gmail.com>
Provide information in the iio tap event about the tap direction. This
can be verified using 'iio_event_monior adxl345'. Reading out the
ACT_TAP_STATUS register is also in preparation for activity events.
Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
---
drivers/iio/accel/adxl345_core.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index 0d991f3ec10c..7831ec511941 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -800,17 +800,26 @@ static const struct iio_buffer_setup_ops adxl345_buffer_ops = {
.predisable = adxl345_buffer_predisable,
};
-static int adxl345_get_status(struct adxl345_state *st, unsigned int *int_stat)
+static int adxl345_get_status(struct adxl345_state *st, unsigned int *int_stat,
+ enum iio_modifier *act_tap_dir)
{
unsigned int regval;
bool check_tap_stat;
+ *act_tap_dir = IIO_NO_MOD;
check_tap_stat = FIELD_GET(ADXL345_REG_TAP_AXIS_MSK, st->tap_axis_ctrl) > 0;
if (check_tap_stat) {
/* ACT_TAP_STATUS should be read before clearing the interrupt */
if (regmap_read(st->regmap, ADXL345_REG_ACT_TAP_STATUS, ®val))
return -EINVAL;
+
+ if (FIELD_GET(ADXL345_Z_EN, regval) > 0)
+ *act_tap_dir = IIO_MOD_Z;
+ else if (FIELD_GET(ADXL345_Y_EN, regval) > 0)
+ *act_tap_dir = IIO_MOD_Y;
+ else if (FIELD_GET(ADXL345_X_EN, regval) > 0)
+ *act_tap_dir = IIO_MOD_X;
}
return regmap_read(st->regmap, ADXL345_REG_INT_SOURCE, int_stat);
@@ -835,7 +844,8 @@ static int adxl345_fifo_push(struct iio_dev *indio_dev,
return 0;
}
-static int adxl345_push_event(struct iio_dev *indio_dev, int int_stat)
+static int adxl345_push_event(struct iio_dev *indio_dev, int int_stat,
+ enum iio_modifier act_tap_dir)
{
s64 ts = iio_get_time_ns(indio_dev);
int ret;
@@ -843,7 +853,7 @@ static int adxl345_push_event(struct iio_dev *indio_dev, int int_stat)
if (FIELD_GET(ADXL345_INT_SINGLE_TAP, int_stat)) {
ret = iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL, 0,
- IIO_MOD_X_OR_Y_OR_Z,
+ act_tap_dir,
IIO_EV_TYPE_GESTURE,
IIO_EV_DIR_SINGLETAP),
ts);
@@ -866,12 +876,13 @@ static irqreturn_t adxl345_irq_handler(int irq, void *p)
struct iio_dev *indio_dev = p;
struct adxl345_state *st = iio_priv(indio_dev);
int int_stat;
+ enum iio_modifier act_tap_dir;
int samples;
- if (adxl345_get_status(st, &int_stat))
+ if (adxl345_get_status(st, &int_stat, &act_tap_dir))
return IRQ_NONE;
- if (adxl345_push_event(indio_dev, int_stat) == 0)
+ if (adxl345_push_event(indio_dev, int_stat, act_tap_dir) == 0)
return IRQ_HANDLED;
if (FIELD_GET(ADXL345_INT_WATERMARK, int_stat)) {
--
2.39.5
next prev parent reply other threads:[~2025-01-28 12:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-28 12:00 [PATCH v1 00/12] iio: accel: adxl345: add interrupt based sensor events Lothar Rubusch
2025-01-28 12:00 ` [PATCH v1 01/12] iio: accel: adxl345: migrate constants to core Lothar Rubusch
2025-02-01 16:35 ` Jonathan Cameron
2025-02-04 14:13 ` Lothar Rubusch
2025-02-04 14:46 ` Jonathan Cameron
2025-01-28 12:00 ` [PATCH v1 02/12] iio: accel: adxl345: reorganize measurement enable Lothar Rubusch
2025-02-01 16:37 ` Jonathan Cameron
2025-01-28 12:00 ` [PATCH v1 03/12] iio: accel: adxl345: add debug register access Lothar Rubusch
2025-01-28 12:00 ` [PATCH v1 04/12] iio: accel: adxl345: reorganize irq handler Lothar Rubusch
2025-02-01 16:43 ` Jonathan Cameron
2025-01-28 12:00 ` [PATCH v1 05/12] iio: accel: adxl345: improve access to the interrupt enable register Lothar Rubusch
2025-02-01 16:49 ` Jonathan Cameron
2025-01-28 12:00 ` [PATCH v1 06/12] iio: accel: adxl345: add single tap feature Lothar Rubusch
2025-02-01 17:02 ` Jonathan Cameron
2025-01-28 12:00 ` Lothar Rubusch [this message]
2025-02-01 17:09 ` [PATCH v1 07/12] iio: accel: adxl345: show tap status and direction Jonathan Cameron
2025-01-28 12:00 ` [PATCH v1 08/12] iio: accel: adxl345: add double tap feature Lothar Rubusch
2025-02-01 17:15 ` Jonathan Cameron
2025-01-28 12:00 ` [PATCH v1 09/12] iio: accel: adxl345: add double tap suppress bit Lothar Rubusch
2025-02-01 17:17 ` Jonathan Cameron
2025-01-28 12:00 ` [PATCH v1 10/12] iio: accel: adxl345: add freefall feature Lothar Rubusch
2025-02-01 17:22 ` Jonathan Cameron
2025-01-28 12:00 ` [PATCH v1 11/12] iio: accel: adxl345: add activity feature Lothar Rubusch
2025-02-01 17:27 ` Jonathan Cameron
2025-02-04 13:48 ` Lothar Rubusch
2025-01-28 12:01 ` [PATCH v1 12/12] iio: accel: adxl345: add inactivity feature Lothar Rubusch
2025-02-01 17:41 ` Jonathan Cameron
2025-02-01 17:48 ` [PATCH v1 00/12] iio: accel: adxl345: add interrupt based sensor events Jonathan Cameron
2025-02-04 13:40 ` Lothar Rubusch
2025-02-08 12:57 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250128120100.205523-8-l.rubusch@gmail.com \
--to=l.rubusch@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=eraretuya@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.