From: Paul Kocialkowski <paulk@sys-base.io>
To: Mehdi Djait <mehdi.djait@linux.intel.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Jonathan Cameron <jic23@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.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>
Subject: Re: [PATCH 2/2] iio: light: Add support for the TI OPT4048 color sensor
Date: Wed, 4 Dec 2024 15:49:43 +0100 [thread overview]
Message-ID: <Z1BsBxsIKmQkHKmD@collins> (raw)
In-Reply-To: <2yc2igv2lxh3u4kmkz73httg3sp24ziagcoaa7unfupagji7zk@ezaue3umwe44>
[-- Attachment #1: Type: text/plain, Size: 3552 bytes --]
Hi Mehdi,
Glad to see you active here :)
Le Mon 02 Dec 24, 15:55, Mehdi Djait a écrit :
> Hello Paul :)
>
> On Mon, Dec 02, 2024 at 11:06:59AM +0000, Jonathan Cameron wrote:
> > On Sun, 1 Dec 2024 18:56:30 +0100
> > Paul Kocialkowski <paulk@sys-base.io> wrote:
> >
> > > Hi Jonathan,
> > >
> > > Le Sun 01 Dec 24, 11:55, Jonathan Cameron a écrit :
> > > > On Sat, 30 Nov 2024 18:42:12 +0100
> > > > Paul Kocialkowski <paulk@sys-base.io> wrote:
> > > >
> > > > > The Texas Instruments OPT4048 is a XYZ tristimulus color sensor,
> > > > > with an additional wide (visible + IR) channel.
> > > > >
> > > > > This driver implements support for all channels, with configurable
> > > > > integration time and auto-gain. Both direct reading and
> > > > > triggered-buffer modes are supported.
> > > > >
> > > > > Note that the Y channel is also reported as a separate illuminance
> > > > > channel, for which a scale is provided (following the datasheet) to
> > > > > convert it to lux units. Falling and rising thresholds are supported
> > > > > for this channel.
> > > > >
> > > > > The device's interrupt can be used to sample all channels at the end
> > > > > of conversion and is optional.
> > > > >
> > > > > Signed-off-by: Paul Kocialkowski <paulk@sys-base.io>
> > > > Hi Paul,
> > > >
> > > > Various comments inline. Most significant is that this seems to be
> > > > suitable for a simple dataready trigger that will make your various
> > > > interrupt and non interrupt flows more similar.
> > >
> > > And thanks for the fast review and insightful comments!
> > >
> > > I considered implementing a trigger in the driver, but the issue I found
> > > is that the trigger is expected to be called from hard irq context,
> > > while the new values are read in the bottom half.
> >
> > The trigger can be called from either the hard irq context or from
> > a thread. See iio_trigger_poll_nested()
> > There is a quirk that you then don't end up calling the registered
> > hard irq handler for the trigger so sometimes a bit of fiddly code
> > is needed to ensure timestamps etc are grabbed. Not sure that matters
> > here.
> >
>
> If the timestamps do matter: here is a (maybe relevant?) discussion for
> an issue I faced with timestamps for a driver that supports both FIFO
> and triggered buffer mode
>
> Please note that iio_trigger_poll_nested() was called
> iio_trigger_poll_chained() back in that discussion.
>
> https://lore.kernel.org/linux-iio/Y+6QoBLh1k82cJVN@carbian/
Thanks for the hint! I'll definitely look it up for details.
Cheers,
Paul
> > > I understand the triggered
> > > buffer callbacks are executed as a thread as well, so there would be race
> > > between the two which could result in previous values being returned.
> >
> > With the above nested call it is all run in the same thread
> > See handle_nested_irq() in particular the function docs.
> > https://elixir.bootlin.com/linux/v6.12.1/source/kernel/irq/chip.c#L459
> >
> > > So I concluded that it was more beneficial to preserve the synchronous reading
> > > mechanism over implementing the trigger.
> >
> > Definite preference for a trigger approach, but I may well still be missing
> > a detail.
>
> --
> Kind Regards
> Mehdi Djait
--
Paul Kocialkowski,
Independent contractor - sys-base - https://www.sys-base.io/
Free software developer - https://www.paulk.fr/
Expert in multimedia, graphics and embedded hardware support with Linux.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-12-04 14:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-30 17:42 [PATCH 1/2] dt-bindings: iio: Add TI OPT4048 color sensor bindings Paul Kocialkowski
2024-11-30 17:42 ` [PATCH 2/2] iio: light: Add support for the TI OPT4048 color sensor Paul Kocialkowski
2024-12-01 1:29 ` kernel test robot
2024-12-01 11:55 ` Jonathan Cameron
2024-12-01 17:56 ` Paul Kocialkowski
2024-12-02 11:06 ` Jonathan Cameron
2024-12-02 14:55 ` Mehdi Djait
2024-12-04 14:49 ` Paul Kocialkowski [this message]
2024-12-04 14:48 ` Paul Kocialkowski
2024-12-02 8:41 ` [PATCH 1/2] dt-bindings: iio: Add TI OPT4048 color sensor bindings Krzysztof Kozlowski
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=Z1BsBxsIKmQkHKmD@collins \
--to=paulk@sys-base.io \
--cc=Jonathan.Cameron@huawei.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mehdi.djait@linux.intel.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 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.