From: Jonathan Cameron <jic23@kernel.org>
To: Daniel Schaefer via B4 Relay <devnull+dhs.frame.work@kernel.org>
Cc: dhs@frame.work, "Jiri Kosina" <jikos@kernel.org>,
"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-input@vger.kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Sven Vainküla" <sven@xn--vainkla-r2a.ee>,
linux@frame.work
Subject: Re: [PATCH] iio: hid-sensor: als: scale each channel individually
Date: Sun, 26 Jul 2026 00:18:42 +0100 [thread overview]
Message-ID: <20260726001842.5810e4d1@jic23-huawei> (raw)
In-Reply-To: <20260723-chromaticity-v1-1-5ef5746ace2a@frame.work>
On Thu, 23 Jul 2026 01:18:58 +0800
Daniel Schaefer via B4 Relay <devnull+dhs.frame.work@kernel.org> wrote:
> From: Daniel Schaefer <dhs@frame.work>
>
> Some sensors have multiple channels (not just brightness but color ALS
> sensors) with different scaling factors.
>
> Tested on Asus ProArt PX13 laptop by Sven.
The channels in this driver report IIO_CHAN_INFO_SCALE as shared by type.
That doesn't matter unless we get different scales on the two parts
of chromaticity and I'm assuming that isn't eh issue Sven has run into?
Assuming it is illuminance vs color temp (or both chromaticity channels together)
then the change here looks fine to me.
I'll queue it up on the testing branch of iio.git but more eyes welcome if
anyone has time to take a look.
A few little tweaks to the commit message. There was a bit of fuzz as well
whilst applying but all seemed like line changes due to other updates.
Thanks
Jonathan
>
> Signed-off-by: Daniel Schaefer <dhs@frame.work>
> Link: https://gitlab.freedesktop.org/hadess/iio-sensor-proxy/-/merge_requests/413
> Cc: Sven Vainküla <sven@xn--vainkla-r2a.ee>
Given you say Sven tested it, I've upgraded this to a Tested-by
and included a comment after that to say what it was tested on.
> Cc: Jiri Kosina <jikos@kernel.org>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: David Lechner <dlechner@baylibre.com>
> Cc: Nuno Sá <nuno.sa@analog.com>
> Cc: Andy Shevchenko <andy@kernel.org>
> Cc: linux-input@vger.kernel.org
> Cc: linux-iio@vger.kernel.org
> Cc: linux@frame.work
We don't really want to end up with all this list in the git log, so good
practice is to put a --- above them, so they end up in the region that is
cut out.
> ---
> drivers/iio/light/hid-sensor-als.c | 22 ++++++++++++----------
> 1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
> index 384572844162..232cb58e0a9f 100644
> --- a/drivers/iio/light/hid-sensor-als.c
> +++ b/drivers/iio/light/hid-sensor-als.c
> @@ -33,9 +33,9 @@ struct als_state {
> u32 illum[CHANNEL_SCAN_INDEX_MAX];
> aligned_s64 timestamp;
> } scan;
> - int scale_pre_decml;
> - int scale_post_decml;
> - int scale_precision;
> + int scale_pre_decml[CHANNEL_SCAN_INDEX_MAX];
> + int scale_post_decml[CHANNEL_SCAN_INDEX_MAX];
> + int scale_precision[CHANNEL_SCAN_INDEX_MAX];
> int value_offset;
> int num_channels;
> s64 timestamp;
> @@ -186,9 +186,11 @@ static int als_read_raw(struct iio_dev *indio_dev,
> ret_type = IIO_VAL_INT;
> break;
> case IIO_CHAN_INFO_SCALE:
> - *val = als_state->scale_pre_decml;
> - *val2 = als_state->scale_post_decml;
> - ret_type = als_state->scale_precision;
> + if (chan->scan_index >= CHANNEL_SCAN_INDEX_MAX)
> + return -EINVAL;
> + *val = als_state->scale_pre_decml[chan->scan_index];
> + *val2 = als_state->scale_post_decml[chan->scan_index];
> + ret_type = als_state->scale_precision[chan->scan_index];
> break;
> case IIO_CHAN_INFO_OFFSET:
> *val = als_state->value_offset;
> @@ -338,6 +340,10 @@ static int als_parse_report(struct platform_device *pdev,
> als_adjust_channel_bit_mask(channels, index, st->als[i].size);
> ++index;
>
> + st->scale_precision[i] = hid_sensor_format_scale(usage_id,
> + &st->als[i], &st->scale_pre_decml[i],
> + &st->scale_post_decml[i]);
> +
> dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index,
> st->als[i].report_id);
> }
> @@ -347,10 +353,6 @@ static int als_parse_report(struct platform_device *pdev,
> if (index)
> ret = 0;
>
> - st->scale_precision = hid_sensor_format_scale(usage_id,
> - &st->als[CHANNEL_SCAN_INDEX_INTENSITY],
> - &st->scale_pre_decml, &st->scale_post_decml);
> -
> return ret;
> }
>
>
> ---
> base-commit: 194a48576843858afcd9c00ed4f105ec2b398e6c
> change-id: 20260723-chromaticity-88fec417f00c
>
> Best regards,
prev parent reply other threads:[~2026-07-25 23:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 17:18 [PATCH] iio: hid-sensor: als: scale each channel individually Daniel Schaefer via B4 Relay
2026-07-22 17:35 ` sashiko-bot
2026-07-25 23:18 ` 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=20260726001842.5810e4d1@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=devnull+dhs.frame.work@kernel.org \
--cc=dhs@frame.work \
--cc=dlechner@baylibre.com \
--cc=jikos@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@frame.work \
--cc=nuno.sa@analog.com \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=sven@xn--vainkla-r2a.ee \
/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