From: Jonathan Cameron <jic23@kernel.org>
To: Lothar Rubusch <l.rubusch@gmail.com>
Cc: lars@metafoo.de, Michael.Hennerich@analog.com,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
eraretuya@gmail.com
Subject: Re: [PATCH v3 06/15] iio: accel: adxl345: add single tap feature
Date: Sat, 15 Mar 2025 17:42:24 +0000 [thread overview]
Message-ID: <20250315174224.0be43524@jic23-huawei> (raw)
In-Reply-To: <CAFXKEHbV-PP8jLiW2+7Jc00Q_DWjoj==a7MOO=nE6_t-2wbCCQ@mail.gmail.com>
On Thu, 13 Mar 2025 17:29:08 +0100
Lothar Rubusch <l.rubusch@gmail.com> wrote:
> Hi Jonathan,
>
> I prepared, reorganized and tested a v4 patch set. Given that I see
> how busy you must be these days with current increased mail traffic
> just in IIO ML when I compare it to some years ago,
> I don't want to bother you too much.
Thanks! It's a travel heavy month which always messes with finding
time for reviews. Too much bored time on planes with not enough space
to open a laptop properly!
> Some particular doubts I will inline down below. If possible with your
> work flow and to avoid giving you extra work, I'd like to ask you to
> read the questions here, but to give your answers right to the
> v4 patch set (so, i.e. after having seen the current state of source).
> It also should make my points
> a bit clearer. Anyway, this is just my idea, since I'm always happy
> about any feedback!
I might reply there as well, but it's easy to put a few comments here.
>
> On Sun, Mar 2, 2025 at 1:14 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Thu, 20 Feb 2025 10:42:25 +0000
> > Lothar Rubusch <l.rubusch@gmail.com> wrote:
> >
> > > Add the single tap feature with a threshold in 62.5mg/LSB points and a
> > > scaled duration in us. Keep singletap threshold in regmap cache but
> > > the scaled value of duration in us as member variable.
> > >
> > > Both use IIO channels for individual enable of the x/y/z axis. Initializes
> > > threshold and duration with reasonable content. When an interrupt is
> > > caught it will be pushed to the according IIO channel.
> > >
> > > Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
> > > ---
> > > drivers/iio/accel/adxl345_core.c | 364 ++++++++++++++++++++++++++++++-
> > > 1 file changed, 362 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
> > > index 0cee81bc1877..d05593c0d513 100644
> > > --- a/drivers/iio/accel/adxl345_core.c
> > > +++ b/drivers/iio/accel/adxl345_core.c
> > > @@ -8,6 +8,7 @@
> > > */
> > >
> > > #include <linux/bitfield.h>
> > > +#include <linux/bitops.h>
> > > #include <linux/interrupt.h>
> > > #include <linux/module.h>
> > > #include <linux/property.h>
> > > @@ -17,6 +18,7 @@
> > > #include <linux/iio/iio.h>
> > > #include <linux/iio/sysfs.h>
> > > #include <linux/iio/buffer.h>
> > > +#include <linux/iio/events.h>
> > > #include <linux/iio/kfifo_buf.h>
> > >
> > > #include "adxl345.h"
> > > @@ -31,6 +33,33 @@
> > > #define ADXL345_INT1 0
> > > #define ADXL345_INT2 1
> > >
> > > +#define ADXL345_REG_TAP_AXIS_MSK GENMASK(2, 0)
> > This is a bit confusing. Here we have a mask for axis that
> > has 3 bits.
> > > +
> > > +enum adxl345_axis {
> > > + ADXL345_Z_EN = BIT(0),
> > > + ADXL345_Y_EN = BIT(1),
> > > + ADXL345_X_EN = BIT(2),
> > > + /* Suppress double tap detection if value > tap threshold */
> > > + ADXL345_TAP_SUPPRESS = BIT(3),
> > and here an enum that is closely related with 4.
>
> I see your point. There are several registers used in the sensor for
> directions. A status register for tap and activity directions, and a
> activity/inactivity direction register. For Tap, direction enables are
> stored using the suppress bit in the fourth position. All those
> locations use actually four bit. Partly the upper four, partly the
> lower four. That's why I use here four bit for reading and writing.
> The locations 0, 1, 2 then can be used directly. Location 3 only
> applies to tap detection.
>
> I'll keep this in v4 patches, and hope to understand you correctly
> that this is not a "real" issue?
I'd split the AXIS_MSK into two parts. One with just the axes
(make it the | of the 3 separate bits) and another one with suppress bit.
I'm not sure an enum really helps. Maybe better to just have defines.
> > > +
> > > +static int adxl345_read_event_value(struct iio_dev *indio_dev,
> > > + const struct iio_chan_spec *chan,
> > > + enum iio_event_type type,
> > > + enum iio_event_direction dir,
> > > + enum iio_event_info info,
> > > + int *val, int *val2)
> > > +{
> > > + struct adxl345_state *st = iio_priv(indio_dev);
> > > + unsigned int tap_threshold;
> > > + int ret;
> > > +
> > > + switch (type) {
> > > + case IIO_EV_TYPE_GESTURE:
> > > + switch (info) {
> > > + case IIO_EV_INFO_VALUE:
> > > + /*
> > > + * The scale factor is 62.5mg/LSB (i.e. 0xFF = 16g) but
> > > + * not applied here.
> >
> > Maybe say why.
> >
>
> Usually I did scaling for the time values. Time values is something I
> can understand someone
> rather wants to configure in corresponding time units, such as [ms],
> [us] or [s] rather than bit
> values. For [mg] values, franckly speaking, I imagine this is a bit overkill.
>
> The threshold quite often is rather expect to be higher or lower,
> depending a bit on variation of
> the measurements. In the context of this rather "cheap" sensor, I
> guess I'm not putting up a
> seismic instrument, but rather generic tap detection, freefall or
> general activity in a general
> purpose context such as gaming, or the like. Let me know if this
> assumption here is too lazy.
Generally event values would be matched to scale of _RAW but for a
gesture, it is indeed a rather vague thing. I'll take a look at
the new code and think about this a bit.
Jonathan
next prev parent reply other threads:[~2025-03-15 17:42 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 10:42 [PATCH v3 00/15] iio: accel: adxl345: add interrupt based sensor events Lothar Rubusch
2025-02-20 10:42 ` [PATCH v3 01/15] iio: accel: adxl345: reorganize measurement enable Lothar Rubusch
2025-02-20 10:42 ` [PATCH v3 02/15] iio: accel: adxl345: add debug register access Lothar Rubusch
2025-02-20 10:42 ` [PATCH v3 03/15] iio: accel: adxl345: reorganize irq handler Lothar Rubusch
2025-03-02 11:36 ` Jonathan Cameron
2025-02-20 10:42 ` [PATCH v3 04/15] iio: accel: adxl345: use regmap cache for INT mapping Lothar Rubusch
2025-03-02 11:45 ` Jonathan Cameron
2025-03-02 12:10 ` Jonathan Cameron
2025-03-09 11:33 ` Lothar Rubusch
2025-02-20 10:42 ` [PATCH v3 05/15] iio: accel: adxl345: move INT enable to regmap cache Lothar Rubusch
2025-03-02 11:49 ` Jonathan Cameron
2025-02-20 10:42 ` [PATCH v3 06/15] iio: accel: adxl345: add single tap feature Lothar Rubusch
2025-03-02 12:14 ` Jonathan Cameron
2025-03-13 16:29 ` Lothar Rubusch
2025-03-15 17:42 ` Jonathan Cameron [this message]
2025-02-20 10:42 ` [PATCH v3 07/15] iio: accel: adxl345: add double " Lothar Rubusch
2025-02-20 10:42 ` [PATCH v3 08/15] iio: accel: adxl345: add double tap suppress bit Lothar Rubusch
2025-03-02 12:17 ` Jonathan Cameron
2025-02-20 10:42 ` [PATCH v3 09/15] iio: accel: adxl345: add freefall feature Lothar Rubusch
2025-03-04 13:23 ` Jonathan Cameron
2025-03-13 16:34 ` Lothar Rubusch
2025-02-20 10:42 ` [PATCH v3 10/15] iio: accel: adxl345: extend sample frequency adjustments Lothar Rubusch
2025-03-04 13:36 ` Jonathan Cameron
2025-02-20 10:42 ` [PATCH v3 11/15] iio: accel: adxl345: add g-range configuration Lothar Rubusch
2025-03-04 13:40 ` Jonathan Cameron
2025-03-13 16:47 ` Lothar Rubusch
2025-03-15 17:47 ` Jonathan Cameron
2025-02-20 10:42 ` [PATCH v3 12/15] iio: accel: adxl345: add activity event feature Lothar Rubusch
2025-03-04 13:49 ` Jonathan Cameron
2025-03-11 10:55 ` Lothar Rubusch
2025-03-15 18:00 ` Jonathan Cameron
2025-02-20 10:42 ` [PATCH v3 13/15] iio: accel: adxl345: add inactivity feature Lothar Rubusch
2025-03-04 13:54 ` Jonathan Cameron
2025-02-20 10:42 ` [PATCH v3 14/15] iio: accel: adxl345: add coupling detection for activity/inactivity Lothar Rubusch
2025-03-04 13:59 ` Jonathan Cameron
2025-03-13 16:39 ` Lothar Rubusch
2025-02-20 10:42 ` [PATCH v3 15/15] docs: iio: add documentation for adxl345 driver Lothar Rubusch
2025-03-04 14:07 ` 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=20250315174224.0be43524@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=eraretuya@gmail.com \
--cc=l.rubusch@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox