mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Jan Remes <ciakval@gmail.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Joe Sandom" <joe.g.sandom@gmail.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Jan Remes" <jan.remes@mycroftmind.com>,
	"Andy Shevchenko" <andriy.shevchenko@intel.com>
Subject: Re: [PATCH v4 4/4] iio: light: tsl2591: improve lux calculation precision
Date: Thu, 26 Nov 2026 01:26:59 +0000	[thread overview]
Message-ID: <20261126012659.44b7f0d7@jic23-hlaptop> (raw)
In-Reply-To: <20261022-first-patch-v4-4-90b2fc6e8e28@mycroftmind.com>

On Thu, 22 Oct 2026 20:56:43 +0200
Jan Remes <ciakval@gmail.com> wrote:

> From: Jan Remes <jan.remes@mycroftmind.com>
> 
> The lux calculation computes the ratio CH1 / CH0 as a truncated integer
> (CH1 * 1000 / CH0) before using it. When CH1 is close to CH0, the
> truncation makes the result off by up to ~35%, e.g. CH0 = 56097,
> CH1 = 55973 at LOW gain and 100ms gives 1.517 lux instead of 1.118 lux.
> 
> The formula (CH0 - CH1) * (1 - CH1 / CH0) / CPL is equal to
> 
>    (CH0 - CH1)^2 * DF / (CH0 * ATIME_ms * AGAIN)
> 
> which needs no intermediate ratio. Compute it like that, with a single
> division at the end.
> 
> Also report the result in micro-lux instead of milli-lux. At MAX gain
> and 600ms one count is well below 1 mlx, so the milli-lux resolution
> throws away information. The numerator still fits into u64.
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Signed-off-by: Jan Remes <jan.remes@mycroftmind.com>

Applied patches 3-4 to the testing branch of iio.git

I just merged in rc4 so for 1 and 2 on which to base this.

Thanks,

Jonathan

      reply	other threads:[~2026-11-26  1:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 18:56 [PATCH v4 0/4] iio: light: tsl2591: fix lux calculation and precision, add I2C ID table, report saturation Jan Remes
2026-10-22 18:56 ` [PATCH v4 1/4] iio: light: tsl2591: don't divide by zero Jan Remes
2026-10-23  3:13   ` Jonathan Cameron
2026-10-22 18:56 ` [PATCH v4 2/4] iio: light: tsl2591: add I2C device ID table Jan Remes
2026-10-23  3:18   ` Jonathan Cameron
2026-10-22 18:56 ` [PATCH v4 3/4] iio: light: tsl2591: report saturation Jan Remes
2026-10-22 18:56 ` [PATCH v4 4/4] iio: light: tsl2591: improve lux calculation precision Jan Remes
2026-11-26  1:26   ` Jonathan Cameron [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=20261126012659.44b7f0d7@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=ciakval@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=jan.remes@mycroftmind.com \
    --cc=joe.g.sandom@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /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

all inboxes | Powered by JetHome®