Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Petre Rodan <petre.rodan@subdimension.ro>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Jagath Jog J" <jagathjog1996@gmail.com>
Subject: Re: [PATCH 3/6] iio: accel: bma220: add tap detection
Date: Sun, 9 Nov 2025 12:41:25 +0000	[thread overview]
Message-ID: <20251109124125.2ab0d432@jic23-huawei> (raw)
In-Reply-To: <aQ09qTYr0gqlb0If@lipo.home.arpa>

On Fri, 7 Nov 2025 02:30:33 +0200
Petre Rodan <petre.rodan@subdimension.ro> wrote:

> On Sun, Nov 02, 2025 at 12:20:53PM +0000, Jonathan Cameron wrote:
> > On Sat, 1 Nov 2025 09:56:42 +0200
> > Petre Rodan <petre.rodan@subdimension.ro> wrote:
> >   
> > > Hello Jonathan,
> > > 
> > > thank you for the review.
> > > 
> > > On Sat, Oct 18, 2025 at 06:16:32PM +0100, Jonathan Cameron wrote:  
> > > > > +			ret = regmap_read(data->regmap, BMA220_REG_CONF3, &reg_val);
> > > > > +			if (ret)
> > > > > +				return ret;
> > > > > +			*val = FIELD_GET(BMA220_TT_DUR_MSK, reg_val);    
> > > > 
> > > > This needs to be in second if you are using duration. Is the register really in seconds?    
> > > 
> > > this IC has a very small number of bits that configure
> > > duration/hysteresis/threshold levels. it's between 2 and 6 for each
> > > of them. in the case of high and low G events the duration is not
> > > even directly defined as a time interval, but as a count of samples
> > > that are over a threshold value.  
> > 
> > The ABI is in seconds, so you have to deal with scaling wrt to the sampling
> > frequency at the time.  I know it can be a pain to do, but consistent userspace
> > is the aim and so we need to match the ABI.  
> 
> on this bma220 chip, when someone modifies the cut off frequency of the
> filter then the ic automatically adjusts the sampling rate. and this 
> sample rate is not exposed on any of the registers.
> since duration parameters are defined as a count of samples 
> and the sample rate looks to be unknown I don't see how I could
> adapt to an API that is based on a unit of seconds.

Does the datasheet document that relationship? Table 4 on the datasheet I looked
at to seems to give settling time but I think is only relevant to low power
modes that might not apply here.

Would be very odd if there is no way to establish the sampling frequency from
the settings configured.

> 
> > > I was hoping that simply passing along a unitless value between 0 and
> > > parameter_max would be enough to customize all the event parameters.
> > > this does mean that the driver makes the assumption that the user is
> > > familiar with the device datasheet and knows the number of bits every
> > > parameter has been allocated. should the driver provide a conversion
> > > table for tt_duration just like for _scale_table and
> > > _lpf_3dB_freq_Hz_table?  
> > 
> > Exactly.  
> 
> I was thinking today of a more analog-feeling API, one in which a variable that can take values linearly between min and max can be set to a percentage of it's scale. think of stereo systems - most of us don't want to set a precise amount of decibels of attenuation when operating the volume knob, we just want to set it lower or higher until a condition matches. in this API the primary unit of measurement would not be dBs but notches or ticks - calculated based on min, max and the native resolution of the control (how many bits are allocated for it in the ic's memory map). this has also the benefit of translating nicely when the control is rendered as a widget in a GUI. think about a 0 to 11 volume knob.
> is there anything like this already implemented? is there any merit to this idea?

ABI is fixed the day it is defined and I'm not keen to have what sounds like
a duplicate ABI.  We also need to if even vaguely possible have consistency across sensors.
If you do it on basis of range set, and one sensor oddly provides twice the range
of another, then a 5 on one is a 10 on that other.

Hence the only things where we can do this sort of percentage thing are where
the thing being controlled is a unit less ratio and hence a percentage type
control is the only possible units.

Thanks,

Jonathan


> 
>  I will shelve the event part of this driver for another time, just got some Honeywell pressure sensors that need a new driver.
> 
> best regards,
> peter


  reply	other threads:[~2025-11-09 12:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 16:42 [PATCH 0/6] iio: accel: bma220: add events Petre Rodan
2025-10-14 16:42 ` [PATCH 1/6] iio: accel: bma220: white space cleanup Petre Rodan
2025-10-18 16:55   ` Jonathan Cameron
2025-10-14 16:42 ` [PATCH 2/6] iio: accel: bma220: remove useless include Petre Rodan
2025-10-18 16:55   ` Jonathan Cameron
2025-10-14 16:42 ` [PATCH 3/6] iio: accel: bma220: add tap detection Petre Rodan
2025-10-18 17:16   ` Jonathan Cameron
2025-11-01  7:56     ` Petre Rodan
2025-11-02 12:20       ` Jonathan Cameron
2025-11-07  0:30         ` Petre Rodan
2025-11-09 12:41           ` Jonathan Cameron [this message]
2025-10-14 16:43 ` [PATCH 4/6] iio: accel: bma220: add low-g event detection Petre Rodan
2025-10-18 17:20   ` Jonathan Cameron
2025-10-18 17:22   ` Jonathan Cameron
2025-10-14 16:43 ` [PATCH 5/6] iio: accel: bma220: add high-g " Petre Rodan
2025-10-14 16:43 ` [PATCH 6/6] iio: accel: bma220: add any-motion detection Petre Rodan
2025-10-18 17:32   ` 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=20251109124125.2ab0d432@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jagathjog1996@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=petre.rodan@subdimension.ro \
    /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