From: Jonathan Cameron <jic23@kernel.org>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: "Alexandre Hamamdjian" <azkali.limited@gmail.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>, CTCaer <ctcaer@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, heikki.haikola@fi.rohmeurope.com
Subject: Re: [PATCH 1/2] dt-bindings: iio: light: Add ROHM BH1730FVC binding
Date: Tue, 12 May 2026 12:55:10 +0100 [thread overview]
Message-ID: <20260512125510.79c5298d@jic23-huawei> (raw)
In-Reply-To: <f05093df-663e-417b-a671-d627811e82de@gmail.com>
On Tue, 12 May 2026 07:42:46 +0300
Matti Vaittinen <mazziesaccount@gmail.com> wrote:
> On 11/05/2026 18:14, Jonathan Cameron wrote:
> > On Mon, 11 May 2026 13:43:56 +0300
> > Matti Vaittinen <mazziesaccount@gmail.com> wrote:
> >
> >> On 11/05/2026 11:22, Matti Vaittinen wrote:
> >>> Thanks for patches Alexandre!
> >>>
> >>> It's nice to see these upstreamed :)
> >>>
> >>> On 10/05/2026 21:09, Alexandre Hamamdjian wrote:
> >>>> From: CTCaer <ctcaer@gmail.com>
> >>>>
> >>>> Add a YAML binding for the ROHM BH1730FVC ambient light sensor.
> >>>> Documents the required compatible string, the als-vdd/als-vid
> >>>> regulators, and the rohm,integration-cycle, rohm,lux-multiplier,
> >>>> rohm,opt-win-coeff and rohm,gain-coeff calibration properties
> >>>> consumed by the driver.
> >>
> >> // snip
> >>
> >>>> + rohm,opt-win-coeff:
> >>>> + description:
> >>>> + Optical-window calibration coefficients. Specified as a flat
> >>>> list of
> >>>> + triplets <rc cv ci>, one triplet per window region, where rc is
> >>>> the
> >>>> + visible/IR ratio cutoff and cv/ci are the visible and IR weighting
> >>>> + factors used in that region.
> >>>> + $ref: /schemas/types.yaml#/definitions/uint32-matrix
> >>>> + items:
> >>>> + minItems: 3
> >>>> + maxItems: 3
> >>>
> >>> I am not sure if I read the driver patch (2/2) correctly, but if I did,
> >>> then these coefficients are used to compute Luxes out of the raw sensor
> >>> data. I believe it would help anyone integrating (or investigating) this
> >>> sensor, if you added the actual formula here as a comment. If I read
> >>> this right, the formula is _somehting_ like:
> >>>
> >>>
> >>> Lx = (cv[win] * ch0_data - ci[win] * ch1_data) / gain / int_time
> >>>
> >>> Here the cv[win] and ci[win] are selected from the opt-win-coeff -table,
> >>> depending on the measured ch1_data/ch0_data ratio, right?
> >>
> >> One thing came to my mind. This 'window' -approach for lux calculation
> >> is not too unique. For example the rohm-bu27034.c uses similar approach.
> >>
> >> The thing is that some of the sensors have more than 2 channels. (For
> >> example, the first version of BU27034 did. [That was BU27034NUC, which
> >> got cancelled when BU27034_A_NUC emerged]). These ICs may still may use
> >> similar approach of having light regions, determined by ratio of (2)
> >> channels. BUT, they may then have more than 2 coefficients / window.
> >>
> >> So, maybe this could be made generic enough so it could be re-used for
> >> such devices if needed? I am not sure if other manufacturers but ROHM
> >> does this in Lux computations - if yes, then it might be worth making
> >> this more generic and not just a ROHM property? Maybe Jonathan has some
> >> insight on other Lux computations.
> >
> > It used to be very common to have multiple sensor / window setups for
> > ambient light sensors - though perhaps less so on more modern devices
> > (we have one on list today where they just say use the green channel
> > of an RGB sensor - so there are more windows but not relevant to
> > illuminance measurement).
> >
> > Sometimes the window bit isn't well enough described in the datasheet
> > so we only dealt with the parts on the actual sensor package and those
> > were handled in driver rather than being in dt.
> >
> > What I'm not sure on here is how much of what is being described
> > is part of the 'chip' packaging - i.e. the bit that is constant for
> > all instances of this device and how much is part of the wider
> > device - i.e. the laptop / phone etc window infront of the sensor.
> >
> > The chip bit we shouldn't have dt, the other part we should and it
> > would indeed be interesting to work on a generalizing that description.
>
> Hm. I kind of agree. The constant, 'common for all sensors'
> -coefficients should probably be hard-coded as sensor defaults. The
> BH1730 data-sheet seems to be describing a set of coefficients. I
> suppose that's what comes from the packaging(?)
>
> And just to contradict myself...
>
> I can imagine two reasons to alter these coefficients:
>
> 1.(st) being what Jonathan described. Eg. having something like a lens
> or a glass or whatever, on top of the sensor. That can alter the light
> entering the sensor, and require change to the coefficients. And indeed,
> it would make sense to only describe this in the DT, because the sensor
> is already described. That'd mean the DT should only contain the
> 'coefficient delta' caused by <add the cause here>.
>
> 2. In theory, there could also be another reason. I bet the sensors are
> all 'individuals' to some extent. So, for something requiring very high
> accuracy, there could be some kind of calibration process at device
> manufacturing. This might produce more accurate, device specific
> coefficients. Considering this use-case, I am not 100% convinced it's
> "wrong" to be able to give the device-specific coefficients from the DT.
> (Because, here the coefficients really are a property of the device
> itself and aren't added by some external part).
Agreed this happens - but you can't really put it in DT as every device
then has it's own DT - which probably means an early boot firmware patching
the DT based on something in ROM or similar. Given that is usually impractical
we have handled this via firmware files - if no file, use defaults.
>
> And, if we consider allowing describing (the more accurate) device
> coefficients from the DT (for case 2), then it would just be simpler to
> always provide the "full coefficients" from the DT, no matter if they
> are caused by the device packaging or added lens/glass/XXX. And, as the
> infamous, and not even existing rohm,dh2228fv device shows, people do
> use the simplest solutions even when it isn't really right ;)
>
> So, I am tempted to suggest we just go with the flow, and allow
> describing the coefficients from the DT, without separating the source,
> (lens/glass/device-packaging) which is what this patch does. (If I read
> it right.) However, I would like to see a property which can be re-used
> by other devices as this seems to be pretty common. Yeah, it's probably
> not _right_, but it feels practical.
I'm fine with doing that if we are sure the coefficients are incorporating
windows in front of the sensor. I know that wasn't the case for some
of the previous devices we've covered - typically because they either
had pretty optically clear windows - or didn't have one at all.
>
> Well, this is just my 0.5 cents, and even I may change my opinion on
> this though :)
I thought that was just me ;)
>
> Yours,
> -- Matti
>
next prev parent reply other threads:[~2026-05-12 11:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-10 18:09 [PATCH 0/2] iio: light: Add ROHM BH1730FVC ambient light sensor driver Alexandre Hamamdjian via B4 Relay
2026-05-10 18:09 ` [PATCH 1/2] dt-bindings: iio: light: Add ROHM BH1730FVC binding Alexandre Hamamdjian via B4 Relay
2026-05-11 8:22 ` Matti Vaittinen
2026-05-11 10:43 ` Matti Vaittinen
2026-05-11 15:14 ` Jonathan Cameron
2026-05-12 4:42 ` Matti Vaittinen
2026-05-12 11:55 ` Jonathan Cameron [this message]
2026-05-11 15:20 ` Jonathan Cameron
2026-05-10 18:09 ` [PATCH 2/2] iio: light: bh1730: Add bh1730 light sensor driver Alexandre Hamamdjian via B4 Relay
2026-05-10 18:18 ` Andy Shevchenko
2026-05-10 18:20 ` Andy Shevchenko
[not found] ` <CAL5cOWuXAD7+rJEKB9FjnwdCjoUJK+WNKXZXt8tfnq1WLmv5eg@mail.gmail.com>
2026-05-11 7:31 ` Andy Shevchenko
2026-05-11 8:26 ` Matti Vaittinen
2026-05-11 10:17 ` Matti Vaittinen
2026-05-11 15:50 ` Jonathan Cameron
2026-05-10 18:13 ` [PATCH 0/2] iio: light: Add ROHM BH1730FVC ambient " Andy Shevchenko
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=20260512125510.79c5298d@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=azkali.limited@gmail.com \
--cc=conor+dt@kernel.org \
--cc=ctcaer@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=heikki.haikola@fi.rohmeurope.com \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=nuno.sa@analog.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