From: Jonathan Cameron <jic23@kernel.org>
To: Erikas Bitovtas <xerikasxx@gmail.com>
Cc: "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>,
"Kevin Tsai" <ktsai@capellamicro.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht,
phone-devel@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: light: Add support for Capella cm36686 and cm36672p sensors
Date: Sat, 7 Feb 2026 16:26:43 +0000 [thread overview]
Message-ID: <20260207162643.5599a3ac@jic23-huawei> (raw)
In-Reply-To: <34824fc2-af03-48e3-98b8-04fae28c9a64@gmail.com>
On Wed, 4 Feb 2026 18:34:50 +0200
Erikas Bitovtas <xerikasxx@gmail.com> wrote:
> > I assume you have the hardware and can do a test to confirm this. :-)
>
> I tested the formula used in Xiaomi's driver in the mainline kernel and
> compared it against the downstream kernel, and the lux readings match between
> them. Therefore, I suppose this solution could be good for now.
> Although my formula for calculating scale is wrong - it should be inverse
> proportionate to integration time. So:
> 80ms -> 1.28
> 160ms -> 0.64 (what Xiaomi uses)
> 320ms -> 0.32
> 640ms -> 0.16
> This can be achieved by multiplying als_trans_ratio by integration time used in
> Xiaomi's driver, and then dividing by integration time we have set up at the
> given moment.
> For example, suppose we set our int time in mainline to 80ms
> 16 (als_trans_ration) * 16 (160ms / 10000) = 256
> 256 / 8 (80ms / 10000) = 32
> Starting here, we calculate based on how Xiaomi calculates scale for their values:
> 32 * 40000 = 1280000
> val = 1280000 / 1000000 = 1
> val2 = 1280000 % 1000000 = 280000
> And that leaves us with scale of 1.280000.
> Of course, comments on how we came to this value would be included as well.
Only think I'd add to this is that if we have numbers for
a sensor in a specific device, it's common for that devices
packaging to attenuate the measured light level a little.
For that reason we do sometimes have a tweak factor in DT.
Jonathan
next prev parent reply other threads:[~2026-02-07 16:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-01 17:03 [PATCH 0/2] iio: light: Add support for Capella cm36686 and cm36672p sensors Erikas Bitovtas
2026-02-01 17:03 ` [PATCH 1/2] dt-bindings: Add binding document for cm36686 Erikas Bitovtas
2026-02-01 18:45 ` David Lechner
2026-02-07 16:29 ` Jonathan Cameron
2026-02-01 17:03 ` [PATCH 2/2] iio: light: Add support for Capella cm36686 and cm36672p sensors Erikas Bitovtas
2026-02-01 18:45 ` David Lechner
2026-02-02 12:04 ` Erikas Bitovtas
2026-02-02 22:48 ` David Lechner
2026-02-03 15:41 ` Erikas Bitovtas
2026-02-03 16:36 ` David Lechner
2026-02-04 16:34 ` Erikas Bitovtas
2026-02-07 16:26 ` Jonathan Cameron [this message]
2026-02-07 16:43 ` 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=20260207162643.5599a3ac@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=ktsai@capellamicro.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=phone-devel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=xerikasxx@gmail.com \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/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