From: Mikael Gonella-Bolduc <mgonellabolduc@dimonoff.com>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Mikael Gonella-Bolduc via B4 Relay
<devnull+mgonellabolduc.dimonoff.com@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Mikael Gonella-Bolduc <m.gonella.bolduc@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
Hugo Villeneuve <hvilleneuve@dimonoff.com>
Subject: Re: [PATCH 2/2] iio: light: Add APDS9160 ALS & Proximity sensor driver
Date: Fri, 6 Dec 2024 11:20:33 -0500 [thread overview]
Message-ID: <Z1MkUcNPXmRpWD3A@uva.nl> (raw)
In-Reply-To: <7194cce7-5082-4df5-8599-186c2e39c599@gmail.com>
On Thu, Dec 05, 2024 at 11:42:21AM +0200, Matti Vaittinen wrote:
> On 02/12/2024 10:22, Matti Vaittinen wrote:
> > Hi Jonathan & Mikael,
> >
> > On 01/12/2024 15:20, Jonathan Cameron wrote:
> > >
> > > > > > +};
> > > > > > +MODULE_DEVICE_TABLE(of, apds9160_of_match);
> > > > > > +
> > > > > > +static struct i2c_driver apds9160_driver = {
> > > > > > + .driver = {
> > > > > > + .name = APDS9160_DRIVER_NAME,
> > > > > > + .owner = THIS_MODULE,
> > > > > > + .of_match_table = apds9160_of_match,
> > > > > > + },
> > > > > > + .probe = apds9160_probe,
> > > > > > + .remove = apds9160_remove,
> > > > > > + .id_table = apds9160_id,
> > > > > > +};
> > > > First, regarding the integration time/gain/scale parameters. I
> > > > took a look at the datasheet again as there is a table
> > > > provided to get lux/count (scale?) for the ALS sensor depending
> > > > on gain and integration time.
> > > >
> > > > It looks like the correlation in the table is almost linear but
> > > > it's not as there is a loss of precision.
> > > > For example, at 1x gain with integration time 100ms the
> > > > lux/count is 0.819 but at 3x the table is stating 0.269 instead
> > > > of exepected 0.273.
> > > >
> > > > Is it still possible to use the gts helpers in that case?
> > >
> > > Ah. Probably not if it goes non linear. Matti? (+CC)
> >
> > Disclaimer - I didn't go through the patch and I just respond from the
> > top of my head :) So, please take my words with a pinch of salt.
> >
> > AFAIR, it is not required that the impact of integration time is
> > _linear_ through the range. The "multiplication factor" can be set for
> > each integration time separately. So, it is perfectly Ok to say:
> >
> > time 1 => multiply by 1
> > time 2 => multiply by 2
> > time 10 => multiply by 9 <= not linear, as linear would be 10.
> > time 15 => multiply by 15
> >
> > ...
> >
> > The notable limitation of _current_ implementation is that the
> > "multiplication factor" needs to be integer. So, this may result loss of
> > accuracy.
>
> // Snip.
>
> I ended up re-reading this mail as a result of running some of my
> public-inbox scripts...
>
> ...and I noticed that the non linear correlation was not about integration
> time, but about gain. Eg, if I now read you right, the integration time is
> kept constant 100mS, and gain is changed from 1x => 3x, which actually did
> not bring 3x gain to the lux/count values.
>
> If this is the case, then the GTS helpers aren't likely to help you much.
> Sorry.
>
>
> Yours,
> -- Matti
Hi,
Thank you for the feedback.
The datasheet is not very clear on why exactly the correlation is almost linear.
I assume it is probably to compensate for some inaccuracies and that's why they
provide the table instead of a linear formula.
I took the approach to let the user control the integration time and I ajust
the available scales depending on the selected integration time.
I kept the hardware gain read-only, as you suggested, for debugging purposes.
See changes in v2.
Best regards,
Mikael
prev parent reply other threads:[~2024-12-06 16:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 20:36 [PATCH 0/2] Add support for Avago/Broadcom APDS9160 Mikael Gonella-Bolduc via B4 Relay
2024-11-19 20:36 ` [PATCH 1/2] dt-bindings: iio: light: Add APDS9160 binding Mikael Gonella-Bolduc via B4 Relay
2024-11-20 17:18 ` Conor Dooley
2024-11-20 17:23 ` Krzysztof Kozlowski
2024-11-20 20:26 ` Mikael Gonella-Bolduc
2024-11-21 7:52 ` Krzysztof Kozlowski
2024-11-20 17:22 ` Krzysztof Kozlowski
2024-11-24 19:26 ` Jonathan Cameron
2024-11-19 20:36 ` [PATCH 2/2] iio: light: Add APDS9160 ALS & Proximity sensor driver Mikael Gonella-Bolduc via B4 Relay
2024-11-20 17:33 ` Krzysztof Kozlowski
2024-11-21 12:12 ` Javier Carrasco
2024-11-22 15:09 ` kernel test robot
2024-11-24 21:15 ` Jonathan Cameron
2024-11-27 22:11 ` Mikael Gonella-Bolduc
2024-12-01 13:20 ` Jonathan Cameron
2024-12-02 8:22 ` Matti Vaittinen
2024-12-05 9:42 ` Matti Vaittinen
2024-12-06 16:20 ` Mikael Gonella-Bolduc [this message]
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=Z1MkUcNPXmRpWD3A@uva.nl \
--to=mgonellabolduc@dimonoff.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=devnull+mgonellabolduc.dimonoff.com@kernel.org \
--cc=hvilleneuve@dimonoff.com \
--cc=jic23@kernel.org \
--cc=justinstitt@google.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=m.gonella.bolduc@gmail.com \
--cc=mazziesaccount@gmail.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=robh@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